X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSALOMEDSImpl%2FSALOMEDSImpl_AttributeInteger.cxx;h=4b1a06fb2f830d72335c4ea17beda3a653c31993;hb=63414a08d9492c25c206579c1953ec6f390679fd;hp=c95a4d3cb19eea857ac94dcfca3b2a464ae179f5;hpb=e6bfea36374791cd31c274a2f97df90dc60ddaf3;p=modules%2Fkernel.git diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx index c95a4d3cb..4b1a06fb2 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx @@ -1,50 +1,47 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : SALOMEDSImpl_AttributeInteger.cxx // Author : Sergey RUIN // Module : SALOME - +// #include "SALOMEDSImpl_AttributeInteger.hxx" -#ifndef WNT -using namespace std; -#endif - -IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeInteger, SALOMEDSImpl_GenericAttribute) -IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeInteger, SALOMEDSImpl_GenericAttribute ) - +#include //======================================================================= //function : GetID //purpose : //======================================================================= -const Standard_GUID& SALOMEDSImpl_AttributeInteger::GetID () +const std::string& SALOMEDSImpl_AttributeInteger::GetID () { - static Standard_GUID IntegerID ("8CC3E213-C9B4-47e4-8496-DD5E62E22018"); + static std::string IntegerID ("8CC3E213-C9B4-47e4-8496-DD5E62E22018"); return IntegerID; } -Handle(SALOMEDSImpl_AttributeInteger) SALOMEDSImpl_AttributeInteger::Set (const TDF_Label& L, Standard_Integer Val) +SALOMEDSImpl_AttributeInteger* SALOMEDSImpl_AttributeInteger::Set (const DF_Label& L, int Val) { - Handle(SALOMEDSImpl_AttributeInteger) A; - if (!L.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), A)) { + SALOMEDSImpl_AttributeInteger* A = NULL; + if (!(A = (SALOMEDSImpl_AttributeInteger*)L.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID()))) { A = new SALOMEDSImpl_AttributeInteger(); L.AddAttribute(A); } @@ -53,11 +50,20 @@ Handle(SALOMEDSImpl_AttributeInteger) SALOMEDSImpl_AttributeInteger::Set (const return A; } +//======================================================================= +//function : Value +//purpose : +//======================================================================= +int SALOMEDSImpl_AttributeInteger::Value() const +{ + return myValue; +} + //======================================================================= //function : SetValue //purpose : //======================================================================= -void SALOMEDSImpl_AttributeInteger::SetValue(const Standard_Integer v) +void SALOMEDSImpl_AttributeInteger::SetValue(const int v) { if(myValue == v) return; @@ -71,14 +77,14 @@ void SALOMEDSImpl_AttributeInteger::SetValue(const Standard_Integer v) //function : ID //purpose : //======================================================================= -const Standard_GUID& SALOMEDSImpl_AttributeInteger::ID () const { return GetID(); } +const std::string& SALOMEDSImpl_AttributeInteger::ID () const { return GetID(); } //======================================================================= //function : NewEmpty //purpose : //======================================================================= -Handle(TDF_Attribute) SALOMEDSImpl_AttributeInteger::NewEmpty () const +DF_Attribute* SALOMEDSImpl_AttributeInteger::NewEmpty () const { return new SALOMEDSImpl_AttributeInteger(); } @@ -87,17 +93,36 @@ Handle(TDF_Attribute) SALOMEDSImpl_AttributeInteger::NewEmpty () const //function : Restore //purpose : //======================================================================= -void SALOMEDSImpl_AttributeInteger::Restore(const Handle(TDF_Attribute)& With) +void SALOMEDSImpl_AttributeInteger::Restore(DF_Attribute* With) { - myValue = Handle(SALOMEDSImpl_AttributeInteger)::DownCast (With)->Value(); + myValue = dynamic_cast(With)->Value(); } //======================================================================= //function : Paste //purpose : //======================================================================= -void SALOMEDSImpl_AttributeInteger::Paste (const Handle(TDF_Attribute)& Into, - const Handle(TDF_RelocationTable)& RT) const +void SALOMEDSImpl_AttributeInteger::Paste (DF_Attribute* Into) { - Handle(SALOMEDSImpl_AttributeInteger)::DownCast(Into)->SetValue(myValue); + dynamic_cast(Into)->SetValue(myValue); } + +//======================================================================= +//function : Save +//purpose : +//======================================================================= +std::string SALOMEDSImpl_AttributeInteger::Save() +{ + char buffer[128]; + sprintf(buffer, "%d", myValue); + return std::string(buffer); +} + +//======================================================================= +//function : Load +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeInteger::Load(const std::string& theValue) +{ + myValue = atoi(theValue.c_str()); +}