Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/yacs.git] / src / SALOMEDS / SALOMEDS_AttributePythonObject_i.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SALOMEDS_AttributePythonObject_i.cxx
8 //  Author : Michael Ponikarov
9 //  Module : SALOME
10 //  $Header$
11
12 using namespace std;
13 #include "SALOMEDS_AttributePythonObject_i.hxx"
14 #include <TCollection_ExtendedString.hxx>
15 #include <TColStd_HArray1OfCharacter.hxx>
16 #include "SALOMEDS_SObject_i.hxx"
17
18 void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) {
19   CheckLocked();
20   char *aSeq = CORBA::string_dup(theSequence);
21   Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(aSeq, IsScript);
22 }
23
24 char* SALOMEDS_AttributePythonObject_i::GetObject() {
25   char* aSeq = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->GetObject();
26   CORBA::String_var aStr = CORBA::string_dup(aSeq);
27   return aStr._retn();
28 }
29
30 CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() {
31   return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript();
32 }
33
34 char* SALOMEDS_AttributePythonObject_i::Store() {
35   CORBA::String_var aString = GetObject();
36   char* aResult = new char[strlen(aString) + 2];
37   aResult[0] = IsScript()?'s':'n';
38   strcpy(aResult+1, aString);
39   return aResult;
40 }
41
42 void SALOMEDS_AttributePythonObject_i::Restore(const char* value) {
43   char* aString = strdup(value);
44   SetObject(aString + 1, aString[0]=='s');
45 }