1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_AttributePythonObject.cxx
21 // Author : Michael Ponikarov
24 #include "SALOMEDSImpl_AttributePythonObject.hxx"
25 #include <Standard_GUID.hxx>
30 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute )
31 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute )
33 const Standard_GUID& SALOMEDSImpl_AttributePythonObject::GetID()
35 static Standard_GUID SALOMEDSImpl_AttributePythonObjectID ("128371A3-8F52-11d6-A8A3-0001021E8C7F");
36 return SALOMEDSImpl_AttributePythonObjectID;
39 Handle(SALOMEDSImpl_AttributePythonObject) SALOMEDSImpl_AttributePythonObject::Set(const TDF_Label& label)
41 Handle(SALOMEDSImpl_AttributePythonObject) anAttr;
42 if (!label.FindAttribute(SALOMEDSImpl_AttributePythonObject::GetID(),anAttr)) {
43 anAttr = new SALOMEDSImpl_AttributePythonObject();
44 label.AddAttribute(anAttr);
49 SALOMEDSImpl_AttributePythonObject::SALOMEDSImpl_AttributePythonObject()
50 :SALOMEDSImpl_GenericAttribute("AttributePythonObject")
54 void SALOMEDSImpl_AttributePythonObject::SetObject(const TCollection_AsciiString& theSequence,
59 mySequence = theSequence;
60 myIsScript = theScript;
62 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
65 TCollection_AsciiString SALOMEDSImpl_AttributePythonObject::GetObject() const
70 bool SALOMEDSImpl_AttributePythonObject::IsScript() const
75 int SALOMEDSImpl_AttributePythonObject::GetLength() const
77 return mySequence.Length();
80 const Standard_GUID& SALOMEDSImpl_AttributePythonObject::ID() const
85 void SALOMEDSImpl_AttributePythonObject::Restore(const Handle(TDF_Attribute)& with)
87 Handle(SALOMEDSImpl_AttributePythonObject) anObj = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(with);
88 SetObject(anObj->GetObject(),anObj->IsScript());
91 Handle(TDF_Attribute) SALOMEDSImpl_AttributePythonObject::NewEmpty() const
93 return new SALOMEDSImpl_AttributePythonObject();
96 void SALOMEDSImpl_AttributePythonObject::Paste(const Handle(TDF_Attribute)& into,
97 const Handle(TDF_RelocationTable)&) const
99 Handle(SALOMEDSImpl_AttributePythonObject) anObj = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(into);
100 anObj->SetObject(GetObject(),IsScript());
104 TCollection_AsciiString SALOMEDSImpl_AttributePythonObject::Save()
106 char* aString = (char*)GetObject().ToCString();
107 char* aResult = new char[strlen(aString) + 2];
108 aResult[0] = IsScript()?'s':'n';
109 strcpy(aResult+1, aString);
110 TCollection_AsciiString ret(aResult);
116 void SALOMEDSImpl_AttributePythonObject::Load(const TCollection_AsciiString& value)
118 char* aString = value.ToCString();
119 SetObject(aString + 1, aString[0]=='s');