00001 #include "ConfigUpdaterManager.h"
00002 #include "ConfigUpdater.h"
00003 #include "Sct/LogicErrors.h"
00004 #include "SctData/TestResult.h"
00005
00006 using namespace Sct;
00007 using namespace SctData;
00008
00009 namespace SctCalibrationController {
00010
00011 ConfigUpdaterManager::ConfigUpdaterManager() {
00012 }
00013
00014 ConfigUpdaterManager& ConfigUpdaterManager::instance() {
00015 static ConfigUpdaterManager cum;
00016 return cum;
00017 }
00018
00019 void ConfigUpdaterManager::update(const SctData::TestResult& t) const {
00020 getUpdater(t.getClassName()).update(t);
00021 }
00022
00023 ConfigUpdater& ConfigUpdaterManager::getUpdater(const string& className) const {
00024 ConfigUpdaterMap::const_iterator it = updaterMap.find(className);
00025 if ( it == updaterMap.end() ) {
00026 cerr << "Calibration Controller: no updater for " << className << endl;
00027 cerr << "known updaters:" << endl ;
00028 for (ConfigUpdaterMap::const_iterator it = updaterMap.begin(); it != updaterMap.end(); ++it) {
00029 cerr << (*it).first << endl;
00030 }
00031 throw InvalidArgumentError("Calibration Controller: no updater for " + className, __FILE__, __LINE__ );
00032 } else {
00033 return *(*it).second ;
00034 }
00035 }
00036
00037 bool ConfigUpdaterManager::setUpdater(const string& testName, shared_ptr<ConfigUpdater> updater) {
00038 if (updaterMap.find(testName) == updaterMap.end() ) {
00039 updaterMap[testName] = updater;
00040 return true;
00041 }
00042 return false;
00043 }
00044
00045 }
00046