\param withCreator \c true if creation record should be also added to the resulting list or \c false otherwise
*/
void GetModificationsList(out StringSeq authors, out LongSeq minutes, out LongSeq hours, out LongSeq days, out LongSeq months, out LongSeq years, in boolean withCreator);
+
+ /*!
+ \brief Sets the comment of the study.
+ \param comment comment of the study.
+ */
+ void SetComment(in string comment);
+
+ /*!
+ \brief Returns comment of the study.
+ \return comment
+ */
+ string GetComment();
+
+ /*!
+ \brief Sets the units of the study.
+ \param units units of the study.
+ */
+ void SetUnits(in string units);
+
+ /*!
+ \brief Returns units of the study.
+ \return units
+ */
+ string GetUnits();
};
//==========================================================================
}
}
}
+
+
+void SALOMEDS_AttributeStudyProperties::SetComment(const std::string& theComment)
+{
+ if (_isLocal) {
+ CheckLocked();
+ SALOMEDS::Locker lock;
+ SALOMEDSImpl_AttributeStudyProperties* anImpl =
+ dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
+ anImpl->SetComment(theComment);
+ } else
+ ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetComment(theComment.c_str());
+}
+
+std::string SALOMEDS_AttributeStudyProperties::GetComment()
+{
+ std::string aComment;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ aComment = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetComment();
+ }
+ else
+ aComment = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComment();
+ return aComment;
+}
+
+
+void SALOMEDS_AttributeStudyProperties::SetUnits(const std::string& theUnits)
+{
+ if (_isLocal) {
+ CheckLocked();
+ SALOMEDS::Locker lock;
+ SALOMEDSImpl_AttributeStudyProperties* anImpl =
+ dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
+ anImpl->SetUnits(theUnits);
+ } else
+ ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->SetUnits(theUnits.c_str());
+}
+
+std::string SALOMEDS_AttributeStudyProperties::GetUnits()
+{
+ std::string anUnits;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ anUnits = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetUnits();
+ }
+ else
+ anUnits = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUnits();
+ return anUnits;
+}
std::vector<int>& theYears,
bool theWithCreator);
+ virtual void SetUnits(const std::string& theUnits);
+ virtual std::string GetUnits();
+
+ virtual void SetComment(const std::string& theComment);
+ virtual std::string GetComment();
+
+
};
(*theYears)[a] = aYears[ind-1];
}
}
+
+void SALOMEDS_AttributeStudyProperties_i::SetComment(const char* theComment)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetComment(std::string(theComment));
+}
+
+char* SALOMEDS_AttributeStudyProperties_i::GetComment()
+{
+ SALOMEDS::Locker lock;
+ std::string C = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetComment();
+ CORBA::String_var c_s = CORBA::string_dup(C.c_str());
+ return c_s._retn();
+}
+
+void SALOMEDS_AttributeStudyProperties_i::SetUnits(const char* theUnits)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->SetUnits(std::string(theUnits));
+}
+
+char* SALOMEDS_AttributeStudyProperties_i::GetUnits()
+{
+ SALOMEDS::Locker lock;
+ std::string U = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_impl)->GetUnits();
+ CORBA::String_var c_s = CORBA::string_dup(U.c_str());
+ return c_s._retn();
+}
+
SALOMEDS::LongSeq_out theYears,
CORBA::Boolean theWithCreator);
+ virtual void SetComment(const char* theComment);
+ virtual char* GetComment();
+
+ virtual void SetUnits(const char* theUnits);
+ virtual char* GetUnits();
};
std::vector<int>& theMonths,
std::vector<int>& theYears,
bool theWithCreator) = 0;
+
+ virtual void SetUnits(const std::string& theUnits) = 0;
+ virtual std::string GetUnits() = 0;
+
+ virtual void SetComment(const std::string& theComment) = 0;
+ virtual std::string GetComment() = 0;
+
};
std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
- int aLength, anIndex;
+ int aLength, anIndex, unitsSize = 0, commentSize = 0;;
for (aLength = 0, anIndex = aNames.size()-1; anIndex >= 0; anIndex--)
aLength += aNames[anIndex].size() + 1;
- char* aProperty = new char[3 + aLength + 12 * aNames.size()];
+ std::string units = GetUnits();
+ std::string comment = GetComment();
+
+ unitsSize = units.size();
+ commentSize = comment.size();
+
+ char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize];
char crMode = (char)GetCreationMode();
a = strlen(aProperty);
aProperty[a++] = 1;
}
+
+ //Write delimeter of the section to define end of the modifications section
+ aProperty[a++] = 30;
+
+ //Write units if need
+ if(units.size() > 0) {
+ sprintf(&(aProperty[a]),"%s",units.c_str());
+ a = strlen(aProperty);
+ }
+
+ aProperty[a++] = 1; //delimeter of the units and comments
+
+ //Write comments if need
+ if(comment.size() > 0) {
+ sprintf(&(aProperty[a]),"%s",comment.c_str());
+ a = strlen(aProperty);
+ a++;
+ }
+
aProperty[a] = 0;
std::string prop(aProperty);
delete aProperty;
return prop;
}
+void SALOMEDSImpl_AttributeStudyProperties::SetUnits(const std::string& theUnits) {
+ if(myUnits == theUnits)
+ return;
+ myUnits = theUnits;
+}
+
+std::string SALOMEDSImpl_AttributeStudyProperties::GetUnits() {
+ return myUnits;
+}
+
+void SALOMEDSImpl_AttributeStudyProperties::SetComment(const std::string& theComment) {
+ if(myComment == theComment)
+ return;
+ myComment = theComment;
+}
+
+std::string SALOMEDSImpl_AttributeStudyProperties::GetComment() {
+ return myComment;
+}
+
+
void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value)
{
char* aCopy = (char*)value.c_str();
SetModification(aName,aMinute,aHour,aDay,aMonth,aYear);
delete [] (aName);
anIndex += aNameSize + 1;
+
+ //Check end of the modifications section
+ if(anIndex < value.size() && aCopy[anIndex] == 30)
+ break;
+ }
+
+ //Case then study contains units and comment properties
+ if( anIndex < value.size() ) {
+ anIndex++; //skip the delimeter of the sections: char(30)
+ int unitsSize;
+ for(unitsSize = 0; aCopy[anIndex+unitsSize] != 1; unitsSize++);
+
+ if(unitsSize > 0) {
+ char *anUnits = new char[unitsSize+1];
+ strncpy(anUnits, &(aCopy[anIndex]), unitsSize);
+ anUnits[unitsSize] = 0;
+ SetUnits(anUnits);
+ delete [] (anUnits);
+ }
+ anIndex += unitsSize + 1;
+
+ int commentSize;
+ for(commentSize = 0; aCopy[anIndex+commentSize] != 0; commentSize++);
+
+ if(commentSize > 0) {
+ char *aComment = new char[commentSize+1];
+ strncpy(aComment, &(aCopy[anIndex]), commentSize);
+ aComment[commentSize] = 0;
+ SetComment(aComment);
+ delete [] (aComment);
+ }
+ anIndex += commentSize;
}
+
if (aCopy[1] == 'l') {
SetLocked(true);
}
- SetModified(0);
+ SetModified(0);
}
void ChangeCreatorName(const std::string& theUserName);
+ void SetUnits(const std::string& theUnits);
+ std::string GetUnits();
+
+ void SetComment(const std::string& theComment);
+ std::string GetComment();
+
void SetCreationMode(const int theMode);
int GetCreationMode() const;
std::vector<int> myDay;
std::vector<int> myMonth;
std::vector<int> myYear;
+ std::string myUnits;
+ std::string myComment;
int myMode;
int myModified;
bool myLocked;
aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
- int aLength = 0, anIndex, i;
+ std::string units = aProp->GetUnits();
+ std::string comment = aProp->GetComment();
+
+ int aLength = 0, anIndex, i, unitsSize = 0, commentSize = 0;
for(i=1; i<=aNames.size(); i++)
aLength += aNames[i-1].size() + 1;
-
- //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte
- char* aProperty = new char[3 + aLength + 12 * aNames.size()];
+
+ unitsSize = units.size();
+ commentSize = comment.size();
+
+ //string format:
+ //locked flag, modified flag,
+ //minutes, hours, day, months, year, user name, char(1),
+ //minutes, hours, day, months, year, user name, char(1),
+ //.....................................................,
+ //.....................................................,
+ //.....................................................,
+ //minutes, hours, day, months, year, user name, char(1), char(30) <- !!!! used to define end of section with modifications !!!!
+ //units, char(1), comment, char(0)
+
+ //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimeter)
+ // unit length + 1, comment length, "zero" byte
+
+ char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize ];
sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u');
a = strlen(aProperty);
aProperty[a++] = 1;
}
- aProperty[a] = 0;
+ //Write delimeter of the section to define end of the modifications section
+ aProperty[a++] = 30;
+
+ //Write units if need
+ if(units.size() > 0) {
+ sprintf(&(aProperty[a]),"%s",units.c_str());
+ a = strlen(aProperty);
+ }
+
+ aProperty[a++] = 1;
+
+ //Write comments if need
+ if(comment.size() > 0) {
+ sprintf(&(aProperty[a]),"%s",comment.c_str());
+ a = strlen(aProperty);
+ a++;
+ }
+
+ aProperty[a] = 0;
+
name_len = (hdf_int32) a;
size[0] = name_len + 1 ;
hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
hdf_dataset->CloseOnDisk();
hdf_dataset=0; //will be deleted by hdf_sco_group destructor
delete [] aProperty;
-
+
aProp->SetModified(0);
return true;
}