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