1 // File : SALOMEDSImpl_AttributePythonObject.cxx
2 // Author : Michael Ponikarov
5 #include "SALOMEDSImpl_AttributePythonObject.hxx"
6 #include <Standard_GUID.hxx>
11 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute )
12 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute )
14 const Standard_GUID& SALOMEDSImpl_AttributePythonObject::GetID()
16 static Standard_GUID SALOMEDSImpl_AttributePythonObjectID ("128371A3-8F52-11d6-A8A3-0001021E8C7F");
17 return SALOMEDSImpl_AttributePythonObjectID;
20 Handle(SALOMEDSImpl_AttributePythonObject) SALOMEDSImpl_AttributePythonObject::Set(const TDF_Label& label)
22 Handle(SALOMEDSImpl_AttributePythonObject) anAttr;
23 if (!label.FindAttribute(SALOMEDSImpl_AttributePythonObject::GetID(),anAttr)) {
24 anAttr = new SALOMEDSImpl_AttributePythonObject();
25 label.AddAttribute(anAttr);
30 SALOMEDSImpl_AttributePythonObject::SALOMEDSImpl_AttributePythonObject()
31 :SALOMEDSImpl_GenericAttribute("AttributePythonObject")
35 void SALOMEDSImpl_AttributePythonObject::SetObject(const TCollection_AsciiString& theSequence,
40 mySequence = theSequence;
41 myIsScript = theScript;
43 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
46 TCollection_AsciiString SALOMEDSImpl_AttributePythonObject::GetObject() const
51 bool SALOMEDSImpl_AttributePythonObject::IsScript() const
56 int SALOMEDSImpl_AttributePythonObject::GetLength() const
58 return mySequence.Length();
61 const Standard_GUID& SALOMEDSImpl_AttributePythonObject::ID() const
66 void SALOMEDSImpl_AttributePythonObject::Restore(const Handle(TDF_Attribute)& with)
68 Handle(SALOMEDSImpl_AttributePythonObject) anObj = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(with);
69 SetObject(anObj->GetObject(),anObj->IsScript());
72 Handle(TDF_Attribute) SALOMEDSImpl_AttributePythonObject::NewEmpty() const
74 return new SALOMEDSImpl_AttributePythonObject();
77 void SALOMEDSImpl_AttributePythonObject::Paste(const Handle(TDF_Attribute)& into,
78 const Handle(TDF_RelocationTable)&) const
80 Handle(SALOMEDSImpl_AttributePythonObject) anObj = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(into);
81 anObj->SetObject(GetObject(),IsScript());
85 TCollection_AsciiString SALOMEDSImpl_AttributePythonObject::Save()
87 char* aString = (char*)GetObject().ToCString();
88 char* aResult = new char[strlen(aString) + 2];
89 aResult[0] = IsScript()?'s':'n';
90 strcpy(aResult+1, aString);
91 TCollection_AsciiString ret(aResult);
97 void SALOMEDSImpl_AttributePythonObject::Load(const TCollection_AsciiString& value)
99 char* aString = value.ToCString();
100 SetObject(aString + 1, aString[0]=='s');