Salome HOME
Merge from branch CCRT_Port_V220.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributePythonObject_i.cxx
index 86f7a1ca49edff7386a51a68a8ffcaebc0256bc1..4c552be88733da35ed6b9e0a6bbc17d459f79aaf 100644 (file)
@@ -9,24 +9,47 @@
 //  Module : SALOME
 //  $Header$
 
-using namespace std;
 #include "SALOMEDS_AttributePythonObject_i.hxx"
+#include "SALOMEDS.hxx"
+
 #include <TCollection_ExtendedString.hxx>
 #include <TColStd_HArray1OfCharacter.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+
+using namespace std;
 
 void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) {
+  SALOMEDS::Locker lock;
+
   CheckLocked();
-  char *aSeq = CORBA::string_dup(theSequence);
-  Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(aSeq, IsScript);
+  Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(const_cast<char*>(theSequence), IsScript);
 }
 
 char* SALOMEDS_AttributePythonObject_i::GetObject() {
+  SALOMEDS::Locker lock;
+
   char* aSeq = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->GetObject();
   CORBA::String_var aStr = CORBA::string_dup(aSeq);
   return aStr._retn();
 }
 
 CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() {
+  SALOMEDS::Locker lock;
+
   return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript();
 }
+
+char* SALOMEDS_AttributePythonObject_i::Store() {
+  SALOMEDS::Locker lock;
+
+  CORBA::String_var aString = GetObject();
+  char* aResult = new char[strlen(aString) + 2];
+  aResult[0] = IsScript()?'s':'n';
+  strcpy(aResult+1, aString);
+  return aResult;
+}
+
+void SALOMEDS_AttributePythonObject_i::Restore(const char* theValue) {
+  SALOMEDS::Locker lock;
+
+  SetObject(&theValue[1], theValue[0]=='s');
+}