Salome HOME
Revert "Synchronize adm files"
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeReference.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOMEDSImpl_AttributeReference.cxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDSImpl_AttributeReference.hxx"
28
29 //=======================================================================
30 //function : GetID
31 //purpose  :
32 //=======================================================================
33 const std::string& SALOMEDSImpl_AttributeReference::GetID ()
34 {
35   static std::string refID ("D913E0B3-0A9F-4ea6-9480-18A9B72D9D86");
36   return refID;
37
38
39 SALOMEDSImpl_AttributeReference* SALOMEDSImpl_AttributeReference::Set(const DF_Label& theLabel, 
40                                                                       const DF_Label& theRefLabel)
41 {
42   SALOMEDSImpl_AttributeReference* A = NULL;
43   if (!(A=(SALOMEDSImpl_AttributeReference*)theLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID()))) {
44     A = new  SALOMEDSImpl_AttributeReference(); 
45     theLabel.AddAttribute(A);
46   }
47
48   A->Set(theRefLabel);  
49   return A;  
50 }
51
52 //=======================================================================
53 //function : Set
54 //purpose  :
55 //=======================================================================
56 void SALOMEDSImpl_AttributeReference::Set(const DF_Label& Origin)
57 {
58   CheckLocked();
59
60   if(myLabel == Origin) return;
61
62   Backup();
63   myLabel = Origin;
64
65   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
66 }  
67
68 //=======================================================================
69 //function : ID
70 //purpose  :
71 //=======================================================================
72 const std::string& SALOMEDSImpl_AttributeReference::ID () const { return GetID(); } 
73
74
75 std::string SALOMEDSImpl_AttributeReference::Save() 
76 {
77   return myLabel.Entry();
78 }
79
80 void SALOMEDSImpl_AttributeReference::Load(const std::string& value) 
81 {
82   myLabel = DF_Label::Label(Label(), value, true);
83 }
84
85 //=======================================================================
86 //function : NewEmpty
87 //purpose  : 
88 //=======================================================================
89 DF_Attribute* SALOMEDSImpl_AttributeReference::NewEmpty () const
90 {  
91   return new SALOMEDSImpl_AttributeReference(); 
92 }
93
94 //=======================================================================
95 //function : Restore
96 //purpose  :
97 //=======================================================================
98
99 void SALOMEDSImpl_AttributeReference::Restore(DF_Attribute* With)
100 {
101   myLabel = dynamic_cast<SALOMEDSImpl_AttributeReference*>(With)->Get ();
102 }
103
104 //=======================================================================
105 //function : Paste
106 //purpose  :
107 //=======================================================================
108
109 void SALOMEDSImpl_AttributeReference::Paste (DF_Attribute* Into)
110 {
111   dynamic_cast<SALOMEDSImpl_AttributeReference*>(Into)->Set(myLabel);
112