Salome HOME
Synchronize adm files
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeReal.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_AttributeReal.cxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDSImpl_AttributeReal.hxx"
28
29 #include <stdlib.h>
30
31
32 //=======================================================================
33 //function : GetID
34 //purpose  :
35 //=======================================================================
36 const std::string& SALOMEDSImpl_AttributeReal::GetID ()
37 {
38   static std::string realID ("1D1992F0-56F4-46b4-8065-CDEA68061CAB");
39   return realID;
40 }   
41
42 SALOMEDSImpl_AttributeReal* SALOMEDSImpl_AttributeReal::Set (const DF_Label& L, const double& Val) 
43 {
44   SALOMEDSImpl_AttributeReal* A = NULL;
45   if (!(A=(SALOMEDSImpl_AttributeReal*)L.FindAttribute(SALOMEDSImpl_AttributeReal::GetID()))) {
46     A = new  SALOMEDSImpl_AttributeReal(); 
47     L.AddAttribute(A);
48   }
49
50   A->SetValue(Val); 
51   return A;
52 }
53
54 //=======================================================================
55 //function : SetValue
56 //purpose  :
57 //=======================================================================
58 void SALOMEDSImpl_AttributeReal::SetValue(const double& v)
59 {
60   CheckLocked();
61
62   if( myValue == v) return;
63
64   Backup();
65   myValue = v;  
66
67   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
68 }
69
70 //=======================================================================
71 //function : ID
72 //purpose  :
73 //=======================================================================
74 const std::string& SALOMEDSImpl_AttributeReal::ID () const 
75
76   return GetID(); 
77
78
79 //=======================================================================
80 //function : NewEmpty
81 //purpose  : 
82 //=======================================================================
83 DF_Attribute* SALOMEDSImpl_AttributeReal::NewEmpty () const
84 {  
85   return new SALOMEDSImpl_AttributeReal(); 
86 }
87
88 //=======================================================================
89 //function : Restore
90 //purpose  : 
91 //=======================================================================
92 void SALOMEDSImpl_AttributeReal::Restore(DF_Attribute* with) 
93 {
94   myValue = dynamic_cast<SALOMEDSImpl_AttributeReal*>(with)->Value ();
95 }
96
97 //=======================================================================
98 //function : Paste
99 //purpose  : 
100 //=======================================================================
101 void SALOMEDSImpl_AttributeReal::Paste (DF_Attribute* into)
102 {
103   dynamic_cast<SALOMEDSImpl_AttributeReal*>(into)->SetValue(myValue);
104 }
105
106 //=======================================================================
107 //function : Save
108 //purpose  :
109 //=======================================================================
110 std::string SALOMEDSImpl_AttributeReal::Save() 
111
112   char buffer[255]; 
113   sprintf(buffer, "%.64e", myValue);
114   return std::string(buffer); 
115 }
116
117 //=======================================================================
118 //function : Load
119 //purpose  :
120 //=======================================================================
121 void SALOMEDSImpl_AttributeReal::Load(const std::string& theValue)
122 {
123   myValue = atof(theValue.c_str());  
124 }