Salome HOME
A patch from Paul RASCLE for: kernel documentation with doxygen, modification on...
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeInteger.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_AttributeInteger.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #include "SALOMEDSImpl_AttributeInteger.hxx"
25
26 #ifndef WNT
27 using namespace std;
28 #endif
29
30 #include <stdlib.h>
31
32 //=======================================================================
33 //function : GetID
34 //purpose  :
35 //=======================================================================
36 const std::string& SALOMEDSImpl_AttributeInteger::GetID ()
37 {
38   static std::string IntegerID ("8CC3E213-C9B4-47e4-8496-DD5E62E22018");
39   return IntegerID;
40 }   
41
42 SALOMEDSImpl_AttributeInteger* SALOMEDSImpl_AttributeInteger::Set (const DF_Label& L, int Val) 
43 {
44   SALOMEDSImpl_AttributeInteger* A = NULL;
45   if (!(A = (SALOMEDSImpl_AttributeInteger*)L.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID()))) {
46     A = new  SALOMEDSImpl_AttributeInteger(); 
47     L.AddAttribute(A);
48   }
49
50   A->SetValue(Val); 
51   return A;
52 }
53
54 //=======================================================================
55 //function : Value
56 //purpose  :
57 //=======================================================================
58 int SALOMEDSImpl_AttributeInteger::Value() const
59 {
60     return myValue;
61 }
62
63 //=======================================================================
64 //function : SetValue
65 //purpose  :
66 //=======================================================================
67 void SALOMEDSImpl_AttributeInteger::SetValue(const int v)
68 {
69   if(myValue == v) return;
70
71   Backup();
72   myValue = v;
73
74   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
75 }
76
77 //=======================================================================
78 //function : ID
79 //purpose  :
80 //=======================================================================
81 const std::string& SALOMEDSImpl_AttributeInteger::ID () const { return GetID(); }
82
83
84 //=======================================================================
85 //function : NewEmpty
86 //purpose  :
87 //=======================================================================
88 DF_Attribute* SALOMEDSImpl_AttributeInteger::NewEmpty () const
89 {
90   return new SALOMEDSImpl_AttributeInteger();
91 }
92
93 //=======================================================================
94 //function : Restore
95 //purpose  :
96 //=======================================================================
97 void SALOMEDSImpl_AttributeInteger::Restore(DF_Attribute* With)
98 {
99   myValue = dynamic_cast<SALOMEDSImpl_AttributeInteger*>(With)->Value();
100 }
101
102 //=======================================================================
103 //function : Paste
104 //purpose  :
105 //=======================================================================
106 void SALOMEDSImpl_AttributeInteger::Paste (DF_Attribute* Into)
107 {
108   dynamic_cast<SALOMEDSImpl_AttributeInteger*>(Into)->SetValue(myValue);
109 }             
110
111 //=======================================================================
112 //function : Save
113 //purpose  :
114 //=======================================================================
115 string SALOMEDSImpl_AttributeInteger::Save() 
116
117   char buffer[128]; 
118   sprintf(buffer, "%d", myValue);
119   return string(buffer); 
120 }
121
122 //=======================================================================
123 //function : Load
124 //purpose  :
125 //=======================================================================
126 void SALOMEDSImpl_AttributeInteger::Load(const string& theValue)
127 {
128   myValue = atoi(theValue.c_str());  
129 }