1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SALOMEDS_AttributeStudyProperties_i.cxx
8 // Author : Yves FRICAUD
12 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
13 #include "SALOMEDS_SObject_i.hxx"
14 #include <TColStd_HSequenceOfExtendedString.hxx>
15 #include <TColStd_HSequenceOfInteger.hxx>
18 #define CREATION_MODE_NOTDEFINED 0
19 #define CREATION_MODE_SCRATCH 1
20 #define CREATION_MODE_COPY 2
22 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) {
24 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
25 CORBA::String_var Str = CORBA::string_dup(theName);
26 aProp->SetFirstName(TCollection_ExtendedString(Str));
29 char* SALOMEDS_AttributeStudyProperties_i::GetUserName() {
30 TCollection_ExtendedString S = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreatorName();
31 CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
35 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
39 CORBA::Long theYear) {
41 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
43 if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
44 aProp->SetModificationDate(theMinute, theHour, theDay, theMonth, theYear);
47 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
50 CORBA::Long& theMonth,
51 CORBA::Long& theYear) {
52 Standard_Integer aMinute;
53 Standard_Integer aHour;
54 Standard_Integer aDay;
55 Standard_Integer aMonth;
56 Standard_Integer aYear;
57 if (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationDate(aMinute, aHour, aDay,
66 return Standard_False;
69 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) {
71 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
72 if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
73 else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
74 else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
77 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() {
78 CORBA::String_var c_s;
79 switch (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationMode()) {
80 case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
81 case CREATION_MODE_COPY: c_s = "copy from"; break;
87 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) {
88 Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetModified(theModified);
91 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() {
92 return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsModified();
95 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() {
96 return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetModified();
99 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) {
100 Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetLocked(theLocked);
103 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked() {
104 return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsLocked();
107 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
108 CORBA::Long theMinute,
111 CORBA::Long theMonth,
112 CORBA::Long theYear) {
114 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
115 aProp->SetUserName(CORBA::string_dup(theName));
116 aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
118 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
119 SALOMEDS::LongSeq_out theMinutes,
120 SALOMEDS::LongSeq_out theHours,
121 SALOMEDS::LongSeq_out theDays,
122 SALOMEDS::LongSeq_out theMonths,
123 SALOMEDS::LongSeq_out theYears,
124 CORBA::Boolean theWithCreator) {
125 Handle(TColStd_HSequenceOfExtendedString) aNames;
126 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
127 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
128 aNames = aProp->GetUserNames();
129 aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
130 int aLength = aNames->Length()-((theWithCreator)?0:1);
131 theNames = new SALOMEDS::StringSeq;
132 // SALOMEDS::LongSeq *maminute = new SALOMEDS::LongSeq;
133 // maminute->length(5);
134 theMinutes = new SALOMEDS::LongSeq;
135 theHours = new SALOMEDS::LongSeq;
136 theDays = new SALOMEDS::LongSeq;
137 theMonths = new SALOMEDS::LongSeq;
138 theYears = new SALOMEDS::LongSeq;
139 theNames->length(aLength);
140 theMinutes->length(aLength);
141 theHours->length(aLength);
142 theDays->length(aLength);
143 theMonths->length(aLength);
144 theYears->length(aLength);
146 for(a = 0; a < aLength; a++)
148 (*theNames)[a] = CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString());
149 (*theMinutes)[a] = aMinutes->Value(a + 1 + ((theWithCreator)?0:1));
150 (*theHours)[a] = aHours->Value(a + 1 + ((theWithCreator)?0:1));
151 (*theDays)[a] = aDays->Value(a + 1 + ((theWithCreator)?0:1));
152 (*theMonths)[a] = aMonths->Value(a + 1 + ((theWithCreator)?0:1));
153 (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1));