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/
20 // File : SALOMEDS_AttributeStudyProperties_i.cxx
21 // Author : Sergey RUIN
25 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
26 #include "SALOMEDS.hxx"
27 #include <TColStd_HSequenceOfExtendedString.hxx>
28 #include <TColStd_HSequenceOfInteger.hxx>
29 #include <TCollection_ExtendedString.hxx>
33 #define CREATION_MODE_NOTDEFINED 0
34 #define CREATION_MODE_SCRATCH 1
35 #define CREATION_MODE_COPY 2
37 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName)
39 SALOMEDS::Locker lock;
41 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->ChangeCreatorName((char*)theName);
44 char* SALOMEDS_AttributeStudyProperties_i::GetUserName()
46 SALOMEDS::Locker lock;
47 TCollection_ExtendedString S =
48 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreatorName();
49 CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
53 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
59 SALOMEDS::Locker lock;
61 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp =
62 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
64 if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
65 TCollection_ExtendedString S;
66 aProp->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
69 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
72 CORBA::Long& theMonth,
75 SALOMEDS::Locker lock;
76 Standard_Integer aMinute;
77 Standard_Integer aHour;
78 Standard_Integer aDay;
79 Standard_Integer aMonth;
80 Standard_Integer aYear;
81 if (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast
82 (_impl)->GetCreationDate(aMinute, aHour, aDay, aMonth, aYear)) {
90 return Standard_False;
93 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode)
95 SALOMEDS::Locker lock;
97 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp =
98 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
99 if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
100 else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
101 else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
104 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode()
106 SALOMEDS::Locker lock;
107 CORBA::String_var c_s;
108 switch (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreationMode()) {
109 case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
110 case CREATION_MODE_COPY: c_s = "copy from"; break;
116 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified)
118 SALOMEDS::Locker lock;
119 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetModified(theModified);
122 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified()
124 SALOMEDS::Locker lock;
125 return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsModified();
128 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified()
130 SALOMEDS::Locker lock;
131 return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetModified();
134 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked)
136 SALOMEDS::Locker lock;
137 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetLocked(theLocked);
140 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
142 SALOMEDS::Locker lock;
143 return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsLocked();
146 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
147 CORBA::Long theMinute,
150 CORBA::Long theMonth,
153 SALOMEDS::Locker lock;
155 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp =
156 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
157 aProp->SetModification((char*)theName, (int)theMinute, (int)theHour,
158 (int)theDay, (int)theMonth, (int)theYear);
161 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
162 SALOMEDS::LongSeq_out theMinutes,
163 SALOMEDS::LongSeq_out theHours,
164 SALOMEDS::LongSeq_out theDays,
165 SALOMEDS::LongSeq_out theMonths,
166 SALOMEDS::LongSeq_out theYears,
167 CORBA::Boolean theWithCreator)
169 SALOMEDS::Locker lock;
170 Handle(TColStd_HSequenceOfExtendedString) aNames;
171 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
172 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp =
173 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
174 aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
175 int aLength = aNames->Length();
176 int aRetLength = aLength - ((theWithCreator) ? 0 : 1);
177 theNames = new SALOMEDS::StringSeq;
178 theMinutes = new SALOMEDS::LongSeq;
179 theHours = new SALOMEDS::LongSeq;
180 theDays = new SALOMEDS::LongSeq;
181 theMonths = new SALOMEDS::LongSeq;
182 theYears = new SALOMEDS::LongSeq;
183 theNames->length(aRetLength);
184 theMinutes->length(aRetLength);
185 theHours->length(aRetLength);
186 theDays->length(aRetLength);
187 theMonths->length(aRetLength);
188 theYears->length(aRetLength);
189 int a = 0, ind = ((theWithCreator) ? 1 : 2);
190 for (; ind <= aLength; a++, ind++) {
191 (*theNames)[a] = CORBA::string_dup(TCollection_AsciiString(aNames->Value(ind)).ToCString());
192 (*theMinutes)[a] = aMinutes->Value(ind);
193 (*theHours)[a] = aHours->Value(ind);
194 (*theDays)[a] = aDays->Value(ind);
195 (*theMonths)[a] = aMonths->Value(ind);
196 (*theYears)[a] = aYears->Value(ind);