Variable.cpp

Go to the documentation of this file.
00001 // Variable.cpp: implementation of the Variable class.
00002 //
00004 
00005 #ifdef WIN32 
00006 #pragma warning(disable:4786)
00007 #endif
00008 #include "Variable.h"
00009 #include <iostream>
00011 // Construction/Destruction
00013 
00015 //##ModelId=43834ABD027F
00016 Variable::Variable()
00017 {
00018 
00019 }
00020 
00025 //##ModelId=43834ABD0280
00026 Variable::Variable(std::string sName,double dLowerVariableBound,double dUpperVariableBound,double dReferenceValue) : 
00027 _sName(sName),
00028 _dValue(-1.0),
00029 _dSimulatedValue(-1.0),
00030 _dReferenceValue(dReferenceValue)
00031 {
00032         _mBound = new Bound(sName,dLowerVariableBound,dUpperVariableBound);
00033 }
00034 
00036 //##ModelId=43834ABD0285
00037 Variable::~Variable()
00038 {
00039         if (_mBound) 
00040         {
00041                 delete _mBound;
00042                 _mBound = 0;
00043         }
00044 }
00045 
00048 //##ModelId=43834ABD028D
00049 void Variable::setValue(double dNewValue) 
00050 {
00051 
00052         if ( getBound()->isInBound(dNewValue)) 
00053         {
00054                 _dValue = dNewValue;
00055         }
00056         else throw ValueOutOfBoundException(getName(),dNewValue,_mBound->getLowerBound(),_mBound->getUpperBound(),"Variable::setValue(double dNewValue)",__FILE__,__LINE__);    
00057 
00058 }
00059 
00061 void Variable::setUncheckValue(double dNewValue)
00062 {
00063                 _dValue = dNewValue;
00064 }
00065 
00067 //##ModelId=43834ABD0290
00068 double  Variable::getValue() const 
00069 {
00070         return _dValue;
00071 }
00072 
00073 
00074 double Variable::getReferenceValue() const 
00075 {
00076         return _dReferenceValue;
00077 }
00078 
00079 
00080 
00081 
00083 void Variable::setSimulatedValue(double dSimulatedNewValue)
00084 {
00085         _dSimulatedValue = dSimulatedNewValue;
00086 }
00087 
00088 
00090 double  Variable::getSimulatedValue() const 
00091 {
00092         return _dSimulatedValue;
00093 }
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00105 //##ModelId=43834ABD0292
00106 void    Variable::setName(std::string sNewName) 
00107 {
00108         _sName = sNewName;
00109 }
00110 
00112 //##ModelId=43834ABD0295
00113 std::string     Variable::getName() const 
00114 {
00115         return _sName;
00116 }
00117 
00120 //##ModelId=43834ABD0297
00121 Bound* Variable::getBound() 
00122 {
00123         if (_mBound==0) throw NullPointerException("_mBound","Variable::getBound()",__FILE__,__LINE__);
00124         return _mBound;
00125 }
00126 
00127 
00130 //##ModelId=43834ABD029C
00131 void Variable::printInfos() 
00132 {
00133         std::cout << "\n##### VARIABLE " << endl;
00134         std::cout << "\tVariable --> " << getName() << " : " << getValue() << std::endl;
00135         _mBound->printInfos(); 
00136 }
00137 
00139 void Variable::changeBound(Bound* mNewBound)
00140 {
00141         _mBound->setBound(mNewBound);
00142 }
00143 

Generated on Fri Jul 10 10:31:56 2009 for Utils Library by  doxygen 1.4.5