Back to index

salome-kernel  6.5.0
SALOMEDSImpl_AttributeReference.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDSImpl_AttributeReference.cxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #include "SALOMEDSImpl_AttributeReference.hxx"
00028 
00029 //=======================================================================
00030 //function : GetID
00031 //purpose  :
00032 //=======================================================================
00033 const std::string& SALOMEDSImpl_AttributeReference::GetID ()
00034 {
00035   static std::string refID ("D913E0B3-0A9F-4ea6-9480-18A9B72D9D86");
00036   return refID;
00037 } 
00038 
00039 SALOMEDSImpl_AttributeReference* SALOMEDSImpl_AttributeReference::Set(const DF_Label& theLabel, 
00040                                                                       const DF_Label& theRefLabel)
00041 {
00042   SALOMEDSImpl_AttributeReference* A = NULL;
00043   if (!(A=(SALOMEDSImpl_AttributeReference*)theLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID()))) {
00044     A = new  SALOMEDSImpl_AttributeReference(); 
00045     theLabel.AddAttribute(A);
00046   }
00047 
00048   A->Set(theRefLabel);  
00049   return A;  
00050 }
00051 
00052 //=======================================================================
00053 //function : Set
00054 //purpose  :
00055 //=======================================================================
00056 void SALOMEDSImpl_AttributeReference::Set(const DF_Label& Origin)
00057 {
00058   CheckLocked();
00059 
00060   if(myLabel == Origin) return;
00061 
00062   Backup();
00063   myLabel = Origin;
00064 
00065   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
00066 }  
00067 
00068 //=======================================================================
00069 //function : ID
00070 //purpose  :
00071 //=======================================================================
00072 const std::string& SALOMEDSImpl_AttributeReference::ID () const { return GetID(); } 
00073 
00074 
00075 std::string SALOMEDSImpl_AttributeReference::Save() 
00076 {
00077   return myLabel.Entry();
00078 }
00079 
00080 void SALOMEDSImpl_AttributeReference::Load(const std::string& value) 
00081 {
00082   myLabel = DF_Label::Label(Label(), value, true);
00083 }
00084 
00085 //=======================================================================
00086 //function : NewEmpty
00087 //purpose  : 
00088 //=======================================================================
00089 DF_Attribute* SALOMEDSImpl_AttributeReference::NewEmpty () const
00090 {  
00091   return new SALOMEDSImpl_AttributeReference(); 
00092 }
00093 
00094 //=======================================================================
00095 //function : Restore
00096 //purpose  :
00097 //=======================================================================
00098 
00099 void SALOMEDSImpl_AttributeReference::Restore(DF_Attribute* With)
00100 {
00101   myLabel = dynamic_cast<SALOMEDSImpl_AttributeReference*>(With)->Get ();
00102 }
00103 
00104 //=======================================================================
00105 //function : Paste
00106 //purpose  :
00107 //=======================================================================
00108 
00109 void SALOMEDSImpl_AttributeReference::Paste (DF_Attribute* Into)
00110 {
00111   dynamic_cast<SALOMEDSImpl_AttributeReference*>(Into)->Set(myLabel);
00112 }