Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_PythonObjectAttribute.cxx
1 using namespace std;
2 //  File      : SALOMEDS_PythonObjectAttribute.cxx
3 //  Created   : Tue Oct  8 10:13:30 2002
4 //  Author    : Michael Ponikarov
5 //  Project   : SALOME
6 //  Module    : SALOMEDS
7 //  Copyright : Open CASCADE
8 //  $Header$
9
10 #include "SALOMEDS_PythonObjectAttribute.ixx"
11 #include <string>
12
13 const Standard_GUID& SALOMEDS_PythonObjectAttribute::GetID() 
14 {
15   static Standard_GUID SALOMEDS_PythonObjectAttributeID ("128371A3-8F52-11d6-A8A3-0001021E8C7F");
16   return SALOMEDS_PythonObjectAttributeID;
17 }
18
19 Handle(SALOMEDS_PythonObjectAttribute) SALOMEDS_PythonObjectAttribute::Set(const TDF_Label& label) 
20 {
21   Handle(SALOMEDS_PythonObjectAttribute) anAttr;
22   if (!label.FindAttribute(SALOMEDS_PythonObjectAttribute::GetID(),anAttr)) {
23     anAttr = new SALOMEDS_PythonObjectAttribute();
24     label.AddAttribute(anAttr);
25   }
26   return anAttr;
27 }
28
29 SALOMEDS_PythonObjectAttribute::SALOMEDS_PythonObjectAttribute()
30 {
31 }
32
33 void SALOMEDS_PythonObjectAttribute::SetObject(const Standard_CString theSequence,
34                                                const Standard_Boolean theScript) 
35 {
36   Backup();
37   if(mySequence != NULL) delete mySequence;
38   if (theSequence == NULL) {
39     mySequence = NULL;
40   } else {
41     mySequence = new char[strlen(theSequence)+1];
42     strcpy(mySequence, theSequence);
43   }
44
45   myIsScript = theScript;
46 }
47
48 Standard_CString SALOMEDS_PythonObjectAttribute::GetObject() const
49 {
50   return mySequence;
51 }
52
53 Standard_Boolean SALOMEDS_PythonObjectAttribute::IsScript() const
54 {
55   return myIsScript;
56 }
57
58 Standard_Integer SALOMEDS_PythonObjectAttribute::GetLength() const
59 {
60   if (mySequence == NULL) return 0;
61   return (strlen(mySequence)+1);
62 }
63
64 const Standard_GUID& SALOMEDS_PythonObjectAttribute::ID() const
65 {
66   return GetID();
67 }
68
69 void SALOMEDS_PythonObjectAttribute::Restore(const Handle(TDF_Attribute)& with) 
70 {
71   Handle(SALOMEDS_PythonObjectAttribute) anObj = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(with);
72   SetObject(anObj->GetObject(),anObj->IsScript());
73 }
74
75 Handle(TDF_Attribute) SALOMEDS_PythonObjectAttribute::NewEmpty() const
76 {
77   return new SALOMEDS_PythonObjectAttribute();
78 }
79
80 void SALOMEDS_PythonObjectAttribute::Paste(const Handle(TDF_Attribute)& into,
81                                            const Handle(TDF_RelocationTable)&) const
82 {
83   Handle(SALOMEDS_PythonObjectAttribute) anObj = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(into);
84   anObj->SetObject(GetObject(),IsScript());
85 }
86