1 // Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_ScalarVariable.cxx
21 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
24 #include "SALOMEDSImpl_ScalarVariable.hxx"
25 #include "SALOMEDSImpl_GenericVariable.hxx"
31 //============================================================================
32 /*! Function : SALOMEDSImpl_ScalarVariable
35 //============================================================================
36 SALOMEDSImpl_ScalarVariable::
37 SALOMEDSImpl_ScalarVariable(SALOMEDSImpl_GenericVariable::VariableTypes type,
38 const string& theName):
39 SALOMEDSImpl_GenericVariable(type,theName)
42 //============================================================================
43 /*! Function : ~SALOMEDSImpl_ScalarVariable()
46 //============================================================================
47 SALOMEDSImpl_ScalarVariable::~SALOMEDSImpl_ScalarVariable(){}
49 //============================================================================
53 //============================================================================
54 bool SALOMEDSImpl_ScalarVariable::setValue(const double theValue)
57 if(myValue == theValue)
64 //============================================================================
65 /*! Function : getValue()
68 //============================================================================
69 double SALOMEDSImpl_ScalarVariable::getValue() const
74 //============================================================================
78 //============================================================================
79 string SALOMEDSImpl_ScalarVariable::Save() const{
83 case SALOMEDSImpl_GenericVariable::REAL_VAR:
85 sprintf(buffer, "%.64e", myValue);
88 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
89 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
91 sprintf(buffer, "%d", (int)myValue);
96 return string(buffer);
99 //============================================================================
100 /*! Function : SaveToScript()
103 //============================================================================
104 string SALOMEDSImpl_ScalarVariable::SaveToScript() const
109 case SALOMEDSImpl_GenericVariable::REAL_VAR:
111 sprintf(buffer, "%g", myValue);
114 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
116 sprintf(buffer, "%d", (int)myValue);
119 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
122 sprintf(buffer, "%s", "True");
124 sprintf(buffer, "%s", "False");
129 return string(buffer);
132 //============================================================================
133 /*! Function : SaveType()
136 //============================================================================
137 string SALOMEDSImpl_ScalarVariable::SaveType() const{
139 sprintf(buffer, "%d", (int)Type());
140 return string(buffer);
143 //============================================================================
144 /*! Function : Load()
147 //============================================================================
148 void SALOMEDSImpl_ScalarVariable::Load(const string& theStrValue)
150 double aValue = atof(theStrValue.c_str());