Salome HOME
Removed includes and libraries of OCC
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributePythonObject.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_AttributePythonObject.cxx
21 //  Author : Michael Ponikarov
22 //  Module : SALOME
23
24 #include "SALOMEDSImpl_AttributePythonObject.hxx"
25
26 using namespace std;
27
28 const std::string& SALOMEDSImpl_AttributePythonObject::GetID() 
29 {
30   static std::string SALOMEDSImpl_AttributePythonObjectID ("128371A3-8F52-11d6-A8A3-0001021E8C7F");
31   return SALOMEDSImpl_AttributePythonObjectID;
32 }
33
34 SALOMEDSImpl_AttributePythonObject* SALOMEDSImpl_AttributePythonObject::Set(const DF_Label& label) 
35 {
36   SALOMEDSImpl_AttributePythonObject* A = NULL;
37   if (!(A = (SALOMEDSImpl_AttributePythonObject*)label.FindAttribute(SALOMEDSImpl_AttributePythonObject::GetID()))) {
38     A = new SALOMEDSImpl_AttributePythonObject();
39     label.AddAttribute(A);
40   }
41   return A;
42 }
43
44 SALOMEDSImpl_AttributePythonObject::SALOMEDSImpl_AttributePythonObject()
45 :SALOMEDSImpl_GenericAttribute("AttributePythonObject")
46 {
47     myIsScript = false;
48 }
49
50 void SALOMEDSImpl_AttributePythonObject::SetObject(const string& theSequence,
51                                                    const bool theScript) 
52 {
53   CheckLocked();
54   Backup();
55   mySequence = theSequence;
56   myIsScript = theScript;
57
58   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
59 }
60
61 string SALOMEDSImpl_AttributePythonObject::GetObject() const
62 {
63   return mySequence;
64 }
65
66 bool SALOMEDSImpl_AttributePythonObject::IsScript() const
67 {
68   return myIsScript;
69 }
70
71 int SALOMEDSImpl_AttributePythonObject::GetLength() const
72 {
73   return mySequence.size();
74 }
75
76 const std::string& SALOMEDSImpl_AttributePythonObject::ID() const
77 {
78   return GetID();
79 }
80
81 void SALOMEDSImpl_AttributePythonObject::Restore(DF_Attribute* with) 
82 {
83   SALOMEDSImpl_AttributePythonObject* anObj = dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(with);
84   SetObject(anObj->GetObject(),anObj->IsScript());
85 }
86
87 DF_Attribute* SALOMEDSImpl_AttributePythonObject::NewEmpty() const
88 {
89   return new SALOMEDSImpl_AttributePythonObject();
90 }
91
92 void SALOMEDSImpl_AttributePythonObject::Paste(DF_Attribute* into)
93 {
94   SALOMEDSImpl_AttributePythonObject* anObj = dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(into);
95   anObj->SetObject(GetObject(),IsScript());
96 }
97
98
99 string SALOMEDSImpl_AttributePythonObject::Save() 
100 {
101   string aString = GetObject();
102   string aResult = IsScript()?"s":"n";
103   aResult += aString;
104   
105   return aResult;
106 }
107           
108 void SALOMEDSImpl_AttributePythonObject::Load(const string& value) 
109 {
110   char* aString = (char*)value.c_str();
111   SetObject(aString + 1, aString[0]=='s');
112 }