Salome HOME
ENV: Windows porting.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeStudyProperties_i.cxx
1 //  File   : SALOMEDS_AttributeStudyProperties_i.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5
6 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
7 #include "SALOMEDS.hxx"
8 #include <TColStd_HSequenceOfExtendedString.hxx>
9 #include <TColStd_HSequenceOfInteger.hxx>
10 #include <TCollection_ExtendedString.hxx>
11
12 using namespace std;
13
14 #define CREATION_MODE_NOTDEFINED 0
15 #define CREATION_MODE_SCRATCH 1
16 #define CREATION_MODE_COPY 2
17
18 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) 
19 {
20   SALOMEDS::Locker lock;
21   CheckLocked();
22   Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetFirstName((char*)theName);
23 }
24
25 char* SALOMEDS_AttributeStudyProperties_i::GetUserName() 
26 {
27   SALOMEDS::Locker lock;
28   TCollection_ExtendedString S = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreatorName();
29   CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
30   return c_s._retn();
31 }
32
33 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
34                                                           CORBA::Long theHour,
35                                                           CORBA::Long theDay,
36                                                           CORBA::Long theMonth,
37                                                           CORBA::Long theYear) 
38 {
39   SALOMEDS::Locker lock;
40   CheckLocked();
41   Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
42   int aTmp;
43   if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
44   aProp->SetModificationDate(theMinute, theHour, theDay, theMonth, theYear);
45 }
46
47 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
48                                                                     CORBA::Long& theHour,
49                                                                     CORBA::Long& theDay,
50                                                                     CORBA::Long& theMonth,
51                                                                     CORBA::Long& theYear) 
52 {
53   SALOMEDS::Locker lock;
54   Standard_Integer aMinute;
55   Standard_Integer aHour;
56   Standard_Integer aDay;
57   Standard_Integer aMonth;
58   Standard_Integer aYear;
59   if (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreationDate(aMinute, aHour, aDay,
60                                                                                       aMonth, aYear)) 
61     {
62       theMinute = aMinute;
63       theHour = aHour;
64       theDay = aDay;
65       theMonth = aMonth;
66       theYear = aYear;
67       return Standard_True;
68     }
69   return Standard_False;
70 }
71
72 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) 
73 {
74   SALOMEDS::Locker lock;
75   CheckLocked();
76   Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
77   if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
78   else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
79   else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
80 }
81
82 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() 
83 {
84   SALOMEDS::Locker lock;
85   CORBA::String_var c_s;
86   switch (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreationMode()) {
87   case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
88   case CREATION_MODE_COPY: c_s = "copy from"; break;
89   default: c_s = "";
90   }
91   return c_s._retn();
92 }
93
94 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) 
95 {
96   SALOMEDS::Locker lock;
97   Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetModified(theModified);
98 }
99
100 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() 
101 {
102   SALOMEDS::Locker lock;
103   return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsModified();
104 }
105
106 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() 
107 {
108   SALOMEDS::Locker lock;
109   return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetModified();
110 }
111
112 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) 
113 {
114   SALOMEDS::Locker lock;
115   Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetLocked(theLocked);
116 }
117
118 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked()
119 {
120   SALOMEDS::Locker lock;
121   return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsLocked();
122 }
123
124 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
125                                                           CORBA::Long theMinute,
126                                                           CORBA::Long theHour,
127                                                           CORBA::Long theDay,
128                                                           CORBA::Long theMonth,
129                                                           CORBA::Long theYear) 
130 {
131   SALOMEDS::Locker lock;
132   CheckLocked();
133   Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
134   aProp->SetUserName((char*)theName);
135   aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
136 }
137 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
138                                                                SALOMEDS::LongSeq_out theMinutes,
139                                                                SALOMEDS::LongSeq_out theHours,
140                                                                SALOMEDS::LongSeq_out theDays,
141                                                                SALOMEDS::LongSeq_out theMonths,
142                                                                SALOMEDS::LongSeq_out theYears,
143                                                                CORBA::Boolean theWithCreator) 
144 {
145   SALOMEDS::Locker lock;
146   Handle(TColStd_HSequenceOfExtendedString) aNames;
147   Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
148   Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl);
149   aNames = aProp->GetUserNames();
150   aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
151   int aLength = aNames->Length()-((theWithCreator)?0:1);
152   theNames = new SALOMEDS::StringSeq;
153   theMinutes = new SALOMEDS::LongSeq;
154   theHours = new SALOMEDS::LongSeq;
155   theDays = new SALOMEDS::LongSeq;
156   theMonths = new SALOMEDS::LongSeq;
157   theYears = new SALOMEDS::LongSeq;
158   theNames->length(aLength);
159   theMinutes->length(aLength);
160   theHours->length(aLength);
161   theDays->length(aLength);
162   theMonths->length(aLength);
163   theYears->length(aLength);
164   int a;
165   for(a = 0; a < aLength; a++) 
166     {
167       (*theNames)[a]=CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString());
168       (*theMinutes)[a] = aMinutes->Value(a + 1 + ((theWithCreator)?0:1));
169       (*theHours)[a] = aHours->Value(a + 1 + ((theWithCreator)?0:1));
170       (*theDays)[a] = aDays->Value(a + 1 + ((theWithCreator)?0:1));
171       (*theMonths)[a] = aMonths->Value(a + 1 + ((theWithCreator)?0:1));
172       (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1));
173     }
174 }
175