Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

AnalysisAlgorithmMap.cpp

00001 #include "AnalysisAlgorithmMap.h"
00002 #include "AnalysisAlgorithm.h"
00003 #include "CalibrationController/IS/TestData.h"
00004 #include <sstream>
00005 
00006 using namespace std;
00007 
00008 namespace SctAnalysis {
00009 
00010 typedef map<string, shared_ptr<AnalysisAlgorithm> > MapType;
00011     
00012 AnalysisAlgorithmMap& AnalysisAlgorithmMap::instance() {
00013     static AnalysisAlgorithmMap* instance = new AnalysisAlgorithmMap();
00014     return *instance;
00015 }
00016     
00017 shared_ptr <AnalysisAlgorithm> AnalysisAlgorithmMap::getAlgorithm(const TestData& testData, const string& moduleName) const throw(Sct::InvalidArgument) {
00018     if (algMap.count(testData.testName) == 0) {
00019     Sct::InvalidArgumentError iae("No map for Test: " + testData.testName, __FILE__, __LINE__);
00020     iae.setSeverity(MRS_DIAGNOSTIC);
00021     throw iae;
00022     }
00023     return (*algMap.find(testData.testName)).second->clone(testData, moduleName);
00024 }
00025     
00026 bool AnalysisAlgorithmMap::setAlgorithm(const string testName, auto_ptr<AnalysisAlgorithm> alg) throw() {
00027     algMap[testName] = shared_ptr<AnalysisAlgorithm>(alg);
00028     return true;    
00029 }
00030 
00031 string AnalysisAlgorithmMap::getStatus(string testName) {
00032     if (algMap.count(testName) == 0) {
00033     return string();
00034     }
00035     return algMap[testName]->getStatus();
00036 }
00037     
00038 string AnalysisAlgorithmMap::getAllStatus() {
00039     ostringstream status;
00040     for (MapType::const_iterator i=algMap.begin(); i!=algMap.end(); ++i) {
00041     status << i->first << " Algorithm " << i->second->getStatus() << "\n";
00042     }
00043     return status.str();
00044 }
00045 
00046     
00047 }

Generated on Thu Jul 15 09:50:42 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5