1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_AttributeStudyProperties_i.cxx
21 // Author : Sergey RUIN
25 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
26 #include "SALOMEDS.hxx"
29 #define CREATION_MODE_NOTDEFINED 0
30 #define CREATION_MODE_SCRATCH 1
31 #define CREATION_MODE_COPY 2
33 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName)
35 SALOMEDS::Locker lock;
37 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->ChangeCreatorName((char*)theName);
40 char* SALOMEDS_AttributeStudyProperties_i::GetUserName()
42 SALOMEDS::Locker lock;
43 string S = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreatorName();
44 CORBA::String_var c_s = CORBA::string_dup(S.c_str());
48 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
54 SALOMEDS::Locker lock;
56 SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
58 if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
60 aProp->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
63 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
66 CORBA::Long& theMonth,
69 SALOMEDS::Locker lock;
75 if (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationDate(aMinute, aHour, aDay, aMonth, aYear)) {
86 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode)
88 SALOMEDS::Locker lock;
90 SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
91 if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
92 else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
93 else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
96 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode()
98 SALOMEDS::Locker lock;
99 CORBA::String_var c_s;
100 switch (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationMode()) {
101 case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
102 case CREATION_MODE_COPY: c_s = "copy from"; break;
108 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified)
110 SALOMEDS::Locker lock;
111 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetModified(theModified);
114 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified()
116 SALOMEDS::Locker lock;
117 return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsModified();
120 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified()
122 SALOMEDS::Locker lock;
123 return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetModified();
126 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked)
128 SALOMEDS::Locker lock;
129 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetLocked(theLocked);
132 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
134 SALOMEDS::Locker lock;
135 return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsLocked();
138 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
139 CORBA::Long theMinute,
142 CORBA::Long theMonth,
145 SALOMEDS::Locker lock;
147 SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
148 aProp->SetModification((char*)theName, (int)theMinute, (int)theHour,
149 (int)theDay, (int)theMonth, (int)theYear);
152 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
153 SALOMEDS::LongSeq_out theMinutes,
154 SALOMEDS::LongSeq_out theHours,
155 SALOMEDS::LongSeq_out theDays,
156 SALOMEDS::LongSeq_out theMonths,
157 SALOMEDS::LongSeq_out theYears,
158 CORBA::Boolean theWithCreator)
160 SALOMEDS::Locker lock;
161 vector<string> aNames;
162 vector<int> aMinutes, aHours, aDays, aMonths, aYears;
163 SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
164 aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
165 int aLength = aNames.size();
166 int aRetLength = aLength - ((theWithCreator) ? 0 : 1);
167 theNames = new SALOMEDS::StringSeq;
168 theMinutes = new SALOMEDS::LongSeq;
169 theHours = new SALOMEDS::LongSeq;
170 theDays = new SALOMEDS::LongSeq;
171 theMonths = new SALOMEDS::LongSeq;
172 theYears = new SALOMEDS::LongSeq;
173 theNames->length(aRetLength);
174 theMinutes->length(aRetLength);
175 theHours->length(aRetLength);
176 theDays->length(aRetLength);
177 theMonths->length(aRetLength);
178 theYears->length(aRetLength);
179 int a = 0, ind = ((theWithCreator) ? 1 : 2);
180 for (; ind <= aLength; a++, ind++) {
181 (*theNames)[a] = CORBA::string_dup(aNames[ind-1].c_str());
182 (*theMinutes)[a] = aMinutes[ind-1];
183 (*theHours)[a] = aHours[ind-1];
184 (*theDays)[a] = aDays[ind-1];
185 (*theMonths)[a] = aMonths[ind-1];
186 (*theYears)[a] = aYears[ind-1];