Generic hardware access library
/home/cschwick/hal/generic/src/common/UnmaskedWriteFactory.cc
Go to the documentation of this file.
00001 #include "hal/UnmaskedWriteFactory.hh"
00002 
00003 HAL::SequencerCommand* HAL::UnmaskedWriteFactory::create( std::list<std::string>& arguments, 
00004                                                           const         HAL::AddressTableInterface& addressTable,
00005                                                           HAL::CommandSequence& sequence ) 
00006   throw (HAL::SequencerSyntaxError, HAL::NoSuchItemException) {
00007   
00008   if ( arguments.size() < 2 || arguments.size() > 4 ) {
00009     throw ( HAL::SequencerSyntaxError("unmaskedWrite command must have two to four arguments."));
00010   }
00011   std::string item = arguments.front();
00012   arguments.pop_front();
00013   // we check immediately if the item exists. So the program gets an
00014   // exception immediately and not only when the script is run
00015   if ( ! addressTable.exists( item ) ) {
00016     std::string text = "Item \"" + item +
00017       "\" does not exist in HAL::AddressTable" +
00018       "\n    (HAL::UnmaskedWriteFactory::create)";
00019     throw (HAL::NoSuchItemException( text, __FILE__, __LINE__, __FUNCTION__ ));
00020   }
00021   
00022   HAL::UnmaskedWriteCommand* commandPtr = new HAL::UnmaskedWriteCommand( item, sequence );
00023   
00024   std::string dataStr = arguments.front();
00025   arguments.pop_front();
00026   
00027   if (dataStr[0] != '$') {
00028     commandPtr->setData( stringToNumber( dataStr ) );
00029   } else {
00030     commandPtr->setDataPointer( sequence.getVariablePointer( dataStr ));
00031   }
00032 
00033   if ( arguments.size() >= 1 ) {
00034     std::string verifyStr = arguments.front();
00035     arguments.pop_front();
00036     if (verifyStr == "HAL_DO_VERIFY") {
00037       commandPtr->setVerify();
00038     } else if (verifyStr != "HAL_NO_VERIFY") {
00039       std::string text = "If present third argument must be 'HAL_DO_VERIFY' or 'HAL_NO_VERIFY'\n    (HAL::UnmaskedWriteFactory::create)";
00040       throw (HAL::SequencerSyntaxError( text ));
00041       ;
00042     }
00043   }  
00044 
00045   if ( arguments.size() >= 1 ) {
00046     std::string offsetStr = arguments.front();
00047     arguments.pop_front();
00048     if (offsetStr[0] != '$') {
00049       commandPtr->setOffset( stringToNumber( offsetStr ));
00050     } else {
00051       commandPtr->setOffsetPointer( sequence.getVariablePointer( offsetStr ));
00052     }
00053   }
00054 
00055   return commandPtr;
00056 }