Generic hardware access library
/home/cschwick/hal/generic/src/common/CommandCreator.cc
Go to the documentation of this file.
00001 #include "hal/CommandCreator.hh"
00002 
00003 HAL::CommandCreator::CommandCreator() {
00004   commandFactoryMap["write"] = new HAL::WriteFactory();
00005   commandFactoryMap["unmaskedWrite"] = new HAL::UnmaskedWriteFactory();
00006   commandFactoryMap["setBit"] = new HAL::SetBitFactory();
00007   commandFactoryMap["resetBit"] = new HAL::ResetBitFactory();
00008   commandFactoryMap["define"] = new HAL::DefineFactory();
00009   commandFactoryMap["add"] = new HAL::AddFactory();
00010   commandFactoryMap["read"] = new HAL::ReadFactory();
00011   commandFactoryMap["unmaskedRead"] = new HAL::UnmaskedReadFactory();
00012   commandFactoryMap["label"] = new HAL::LabelFactory();
00013   commandFactoryMap["goto"] = new HAL::GotoFactory();
00014   commandFactoryMap["print"] = new HAL::PrintFactory();
00015   commandFactoryMap["check"] = new HAL::CheckFactory();
00016   commandFactoryMap["pollItem"] = new HAL::PollItemFactory();
00017 }
00018 
00019 HAL::CommandCreator::~CommandCreator() {
00020   std::map<std::string, HAL::AbstractCommandFactory*>::iterator it;
00021   for ( it = commandFactoryMap.begin(); it != commandFactoryMap.end(); it++ ) {
00022     delete((*it).second);
00023   }
00024 }
00025 
00026 HAL::SequencerCommand* HAL::CommandCreator::create( std::list<std::string> commandStringList,
00027                                                     const HAL::AddressTableInterface& addressTable,
00028                                                     HAL::CommandSequence& sequence) 
00029   throw (HAL::SequencerSyntaxError, HAL::NoSuchItemException) {
00030 
00031   std::string commandString = commandStringList.front();
00032   commandStringList.pop_front();
00033   if ( commandFactoryMap.find(commandString) == commandFactoryMap.end() ) {
00034     std::string text;
00035     text = "No such sequencer command : \"" + commandString + "\"";
00036     throw ( HAL::SequencerSyntaxError(text) );
00037   }
00038   return (commandFactoryMap[commandString]->create(commandStringList,
00039                                                    addressTable,
00040                                                    sequence));
00041 }
00042 
00043