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