1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDSImpl_AttributePythonObject.cxx
24 // Author : Michael Ponikarov
27 #include "SALOMEDSImpl_AttributePythonObject.hxx"
29 const std::string& SALOMEDSImpl_AttributePythonObject::GetID()
31 static std::string SALOMEDSImpl_AttributePythonObjectID ("128371A3-8F52-11d6-A8A3-0001021E8C7F");
32 return SALOMEDSImpl_AttributePythonObjectID;
35 SALOMEDSImpl_AttributePythonObject* SALOMEDSImpl_AttributePythonObject::Set(const DF_Label& label)
37 SALOMEDSImpl_AttributePythonObject* A = NULL;
38 if (!(A = (SALOMEDSImpl_AttributePythonObject*)label.FindAttribute(SALOMEDSImpl_AttributePythonObject::GetID()))) {
39 A = new SALOMEDSImpl_AttributePythonObject();
40 label.AddAttribute(A);
45 SALOMEDSImpl_AttributePythonObject::SALOMEDSImpl_AttributePythonObject()
46 :SALOMEDSImpl_GenericAttribute("AttributePythonObject")
51 void SALOMEDSImpl_AttributePythonObject::SetObject(const std::string& theSequence,
56 mySequence = theSequence;
57 myIsScript = theScript;
59 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
62 std::string SALOMEDSImpl_AttributePythonObject::GetObject() const
67 bool SALOMEDSImpl_AttributePythonObject::IsScript() const
72 int SALOMEDSImpl_AttributePythonObject::GetLength() const
74 return mySequence.size();
77 const std::string& SALOMEDSImpl_AttributePythonObject::ID() const
82 void SALOMEDSImpl_AttributePythonObject::Restore(DF_Attribute* with)
84 SALOMEDSImpl_AttributePythonObject* anObj = dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(with);
85 SetObject(anObj->GetObject(),anObj->IsScript());
88 DF_Attribute* SALOMEDSImpl_AttributePythonObject::NewEmpty() const
90 return new SALOMEDSImpl_AttributePythonObject();
93 void SALOMEDSImpl_AttributePythonObject::Paste(DF_Attribute* into)
95 SALOMEDSImpl_AttributePythonObject* anObj = dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(into);
96 anObj->SetObject(GetObject(),IsScript());
100 std::string SALOMEDSImpl_AttributePythonObject::Save()
102 std::string aString = GetObject();
103 std::string aResult = IsScript()?"s":"n";
109 void SALOMEDSImpl_AttributePythonObject::Load(const std::string& value)
111 char* aString = (char*)value.c_str();
112 SetObject(aString + 1, aString[0]=='s');