Salome HOME
updated copyright message
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeStudyProperties_i.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOMEDS_AttributeStudyProperties_i.cxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
28 #include "SALOMEDS.hxx"
29
30 #define CREATION_MODE_NOTDEFINED 0
31 #define CREATION_MODE_SCRATCH 1
32 #define CREATION_MODE_COPY 2
33
34 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName)
35 {
36   SALOMEDS::Locker lock;
37   CheckLocked();
38   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->ChangeCreatorName((char*)theName);
39 }
40
41 char* SALOMEDS_AttributeStudyProperties_i::GetUserName()
42 {
43   SALOMEDS::Locker lock;
44   std::string S = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreatorName();
45   CORBA::String_var c_s = CORBA::string_dup(S.c_str());
46   return c_s._retn();
47 }
48
49 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
50                                                           CORBA::Long theHour,
51                                                           CORBA::Long theDay,
52                                                           CORBA::Long theMonth,
53                                                           CORBA::Long theYear)
54 {
55   SALOMEDS::Locker lock;
56   CheckLocked();
57   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
58   int aTmp;
59   if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
60   std::string S;
61   aProp->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
62 }
63
64 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
65                                                                     CORBA::Long& theHour,
66                                                                     CORBA::Long& theDay,
67                                                                     CORBA::Long& theMonth,
68                                                                     CORBA::Long& theYear)
69 {
70   SALOMEDS::Locker lock;
71   int aMinute;
72   int aHour;
73   int aDay;
74   int aMonth;
75   int aYear;
76   if (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationDate(aMinute, aHour, aDay, aMonth, aYear)) {
77     theMinute = aMinute;
78     theHour = aHour;
79     theDay = aDay;
80     theMonth = aMonth;
81     theYear = aYear;
82     return true;
83   }
84   return false;
85 }
86
87 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode)
88 {
89   SALOMEDS::Locker lock;
90   CheckLocked();
91   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
92   if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
93   else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
94   else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
95 }
96
97 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode()
98 {
99   SALOMEDS::Locker lock;
100   CORBA::String_var c_s;
101   switch (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationMode()) {
102   case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
103   case CREATION_MODE_COPY: c_s = "copy from"; break;
104   default: c_s = "";
105   }
106   return c_s._retn();
107 }
108
109 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified)
110 {
111   SALOMEDS::Locker lock;
112   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetModified(theModified);
113 }
114
115 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified()
116 {
117   SALOMEDS::Locker lock;
118   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsModified();
119 }
120
121 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified()
122 {
123   SALOMEDS::Locker lock;
124   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetModified();
125 }
126
127 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked)
128 {
129   SALOMEDS::Locker lock;
130   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetLocked(theLocked);
131 }
132
133 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
134 {
135   SALOMEDS::Locker lock;
136   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsLocked();
137 }
138
139 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
140                                                           CORBA::Long theMinute,
141                                                           CORBA::Long theHour,
142                                                           CORBA::Long theDay,
143                                                           CORBA::Long theMonth,
144                                                           CORBA::Long theYear)
145 {
146   SALOMEDS::Locker lock;
147   CheckLocked();
148   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
149   aProp->SetModification((char*)theName, (int)theMinute, (int)theHour,
150                          (int)theDay, (int)theMonth, (int)theYear);
151 }
152
153 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
154                                                                SALOMEDS::LongSeq_out theMinutes,
155                                                                SALOMEDS::LongSeq_out theHours,
156                                                                SALOMEDS::LongSeq_out theDays,
157                                                                SALOMEDS::LongSeq_out theMonths,
158                                                                SALOMEDS::LongSeq_out theYears,
159                                                                CORBA::Boolean theWithCreator)
160 {
161   SALOMEDS::Locker lock;
162   std::vector<std::string> aNames;
163   std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
164   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
165   aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
166   int aLength = (int)aNames.size(); //!< TODO: conversion from size_t to int
167   int aRetLength = aLength - ((theWithCreator) ? 0 : 1);
168   theNames = new SALOMEDS::StringSeq;
169   theMinutes = new SALOMEDS::LongSeq;
170   theHours = new SALOMEDS::LongSeq;
171   theDays = new SALOMEDS::LongSeq;
172   theMonths = new SALOMEDS::LongSeq;
173   theYears = new SALOMEDS::LongSeq;
174   theNames->length(aRetLength);
175   theMinutes->length(aRetLength);
176   theHours->length(aRetLength);
177   theDays->length(aRetLength);
178   theMonths->length(aRetLength);
179   theYears->length(aRetLength);
180   int a = 0, ind = ((theWithCreator) ? 1 : 2);
181   for (; ind <= aLength; a++, ind++) {
182     (*theNames)[a] = CORBA::string_dup(aNames[ind-1].c_str());
183     (*theMinutes)[a] = aMinutes[ind-1];
184     (*theHours)[a] = aHours[ind-1];
185     (*theDays)[a] = aDays[ind-1];
186     (*theMonths)[a] = aMonths[ind-1];
187     (*theYears)[a] = aYears[ind-1];
188   }
189 }
190
191 void SALOMEDS_AttributeStudyProperties_i::SetComment(const char* theComment)
192 {
193   SALOMEDS::Locker lock;
194   CheckLocked();
195   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetComment(std::string(theComment));
196 }
197
198 char* SALOMEDS_AttributeStudyProperties_i::GetComment()
199 {
200   SALOMEDS::Locker lock;
201   std::string C = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetComment();
202   CORBA::String_var c_s = CORBA::string_dup(C.c_str());
203   return c_s._retn();
204 }
205
206 void SALOMEDS_AttributeStudyProperties_i::SetUnits(const char* theUnits)
207 {
208   SALOMEDS::Locker lock;
209   CheckLocked();
210   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetUnits(std::string(theUnits));
211 }
212
213 char* SALOMEDS_AttributeStudyProperties_i::GetUnits()
214 {
215   SALOMEDS::Locker lock;
216   std::string U = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetUnits();
217   CORBA::String_var c_s = CORBA::string_dup(U.c_str());
218   return c_s._retn();
219 }
220
221 SALOMEDS::StringSeq* SALOMEDS_AttributeStudyProperties_i::GetStoredComponents()
222 {
223   SALOMEDS::Locker lock;
224   std::vector<std::string> components = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetStoredComponents();
225   SALOMEDS::StringSeq_var c_components = new SALOMEDS::StringSeq();
226   c_components->length((CORBA::ULong)components.size()); //!< TODO: conversion from size_t to CORBA::ULong
227   for (int i = 0; i < (int)components.size(); i++) { //TODO: mismatch signed/unsigned
228     c_components[i] = CORBA::string_dup(components[i].c_str());
229   }
230   return c_components._retn();
231 }
232
233 char* SALOMEDS_AttributeStudyProperties_i::GetComponentVersion(const char* theComponent)
234 {
235   SALOMEDS::Locker lock;
236   std::string version = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetComponentVersion(theComponent);
237   CORBA::String_var c_version = CORBA::string_dup(version.c_str());
238   return c_version._retn();
239 }
240
241 SALOMEDS::StringSeq* SALOMEDS_AttributeStudyProperties_i::GetComponentVersions(const char* theComponent)
242 {
243   SALOMEDS::Locker lock;
244   std::vector<std::string> versions = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetComponentVersions(theComponent);
245   SALOMEDS::StringSeq_var c_versions = new SALOMEDS::StringSeq();
246   c_versions->length((CORBA::ULong)versions.size()); //!< TODO: conversion from size_t to CORBA::ULong
247   for (int i = 0; i < (int)versions.size(); i++) { //TODO: mismatch signed/unsigned
248     c_versions[i] = CORBA::string_dup(versions[i].c_str());
249   }
250   return c_versions._retn();
251 }