Generic hardware access library
/home/cschwick/hal/generic/src/common/DefineCommand.cc
Go to the documentation of this file.
00001 #include "hal/DefineCommand.hh"
00002 
00003 
00004 HAL::DefineCommand::DefineCommand( std::string variableName, 
00005                                    bool hasInitialization,
00006                                    HAL::CommandSequence& sequence )
00007   : hasInitialization( hasInitialization ),
00008     initValue( initValue ),
00009         sequence(sequence) {
00010 
00011   initValuePtr = &initValue;
00012   if (variableName[0] != '$') {
00013         std::string text = "Unvalid Variable name : " + variableName +
00014           "\n    Variables must start with a \"$\"." +
00015           "\n    (HAL::DefineCommand::DefineCommand)";
00016         throw(HAL::SequencerSyntaxError( text ));
00017   }
00018   this->variableName = variableName;
00019   variablePtr = sequence.addVariable( variableName, initValue );
00020 }
00021 
00022 void HAL::DefineCommand::setInitValuePointer( uint32_t* initValPtr ) {
00023   this->initValuePtr = initValPtr;
00024 }
00025 
00026 void HAL::DefineCommand::setInitValue( uint32_t initValue ) {
00027   this->initValue = initValue;
00028 }
00029 
00030 void HAL::DefineCommand::excecute( const HAL::HardwareDeviceInterface& device ) const
00031   throw() {
00032   if (hasInitialization) {
00033         *variablePtr = *initValuePtr;
00034   }
00035 }
00036