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"
29 //============================================================================
30 /*! Function : SALOMEDSImpl_ScalarVariable
33 //============================================================================
34 SALOMEDSImpl_ScalarVariable::
35 SALOMEDSImpl_ScalarVariable(SALOMEDSImpl_GenericVariable::VariableTypes type,
36 const string& theName):
37 SALOMEDSImpl_GenericVariable(type,theName)
40 //============================================================================
41 /*! Function : ~SALOMEDSImpl_ScalarVariable()
44 //============================================================================
45 SALOMEDSImpl_ScalarVariable::~SALOMEDSImpl_ScalarVariable(){}
47 //============================================================================
51 //============================================================================
52 bool SALOMEDSImpl_ScalarVariable::setValue(const double theValue)
55 if(myValue == theValue)
62 //============================================================================
63 /*! Function : getValue()
66 //============================================================================
67 double SALOMEDSImpl_ScalarVariable::getValue() const
72 //============================================================================
76 //============================================================================
77 string SALOMEDSImpl_ScalarVariable::Save() const{
81 case SALOMEDSImpl_GenericVariable::REAL_VAR:
83 sprintf(buffer, "%.64e", myValue);
86 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
87 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
89 sprintf(buffer, "%d", (int)myValue);
94 return string(buffer);
97 //============================================================================
98 /*! Function : SaveToScript()
101 //============================================================================
102 string SALOMEDSImpl_ScalarVariable::SaveToScript() const
107 case SALOMEDSImpl_GenericVariable::REAL_VAR:
109 sprintf(buffer, "%g", myValue);
112 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
114 sprintf(buffer, "%d", (int)myValue);
117 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
120 sprintf(buffer, "%s", "True");
122 sprintf(buffer, "%s", "False");
127 return string(buffer);
130 //============================================================================
131 /*! Function : SaveType()
134 //============================================================================
135 string SALOMEDSImpl_ScalarVariable::SaveType() const{
137 sprintf(buffer, "%d", (int)Type());
138 return string(buffer);
141 //============================================================================
142 /*! Function : Load()
145 //============================================================================
146 void SALOMEDSImpl_ScalarVariable::Load(const string& theStrValue)
148 double aValue = atof(theStrValue.c_str());