Salome HOME
149fa20946594235f350d21f74944d1549d5fddd
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeStudyProperties_i.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDS_AttributeStudyProperties_i.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
26 #include "SALOMEDS.hxx"
27 using namespace std;
28
29 #define CREATION_MODE_NOTDEFINED 0
30 #define CREATION_MODE_SCRATCH 1
31 #define CREATION_MODE_COPY 2
32
33 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName)
34 {
35   SALOMEDS::Locker lock;
36   CheckLocked();
37   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->ChangeCreatorName((char*)theName);
38 }
39
40 char* SALOMEDS_AttributeStudyProperties_i::GetUserName()
41 {
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());
45   return c_s._retn();
46 }
47
48 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
49                                                           CORBA::Long theHour,
50                                                           CORBA::Long theDay,
51                                                           CORBA::Long theMonth,
52                                                           CORBA::Long theYear)
53 {
54   SALOMEDS::Locker lock;
55   CheckLocked();
56   SALOMEDSImpl_AttributeStudyProperties* aProp = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl);
57   int aTmp;
58   if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
59   string S;
60   aProp->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
61 }
62
63 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
64                                                                     CORBA::Long& theHour,
65                                                                     CORBA::Long& theDay,
66                                                                     CORBA::Long& theMonth,
67                                                                     CORBA::Long& theYear)
68 {
69   SALOMEDS::Locker lock;
70   int aMinute;
71   int aHour;
72   int aDay;
73   int aMonth;
74   int aYear;
75   if (dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetCreationDate(aMinute, aHour, aDay, aMonth, aYear)) {
76     theMinute = aMinute;
77     theHour = aHour;
78     theDay = aDay;
79     theMonth = aMonth;
80     theYear = aYear;
81     return true;
82   }
83   return false;
84 }
85
86 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode)
87 {
88   SALOMEDS::Locker lock;
89   CheckLocked();
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);
94 }
95
96 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode()
97 {
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;
103   default: c_s = "";
104   }
105   return c_s._retn();
106 }
107
108 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified)
109 {
110   SALOMEDS::Locker lock;
111   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetModified(theModified);
112 }
113
114 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified()
115 {
116   SALOMEDS::Locker lock;
117   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsModified();
118 }
119
120 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified()
121 {
122   SALOMEDS::Locker lock;
123   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetModified();
124 }
125
126 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked)
127 {
128   SALOMEDS::Locker lock;
129   dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetLocked(theLocked);
130 }
131
132 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
133 {
134   SALOMEDS::Locker lock;
135   return dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->IsLocked();
136 }
137
138 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
139                                                           CORBA::Long theMinute,
140                                                           CORBA::Long theHour,
141                                                           CORBA::Long theDay,
142                                                           CORBA::Long theMonth,
143                                                           CORBA::Long theYear)
144 {
145   SALOMEDS::Locker lock;
146   CheckLocked();
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);
150 }
151
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)
159 {
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];
187   }
188 }