00001
00008 #include <utility>
00009
00010 #include "SctApi.h"
00011 #include "SctApiHisto.h"
00012 #include "SctApiRodInfo.h"
00013
00014 using namespace std;
00015
00016 namespace SctApi {
00017
00018 RodScanEx &ScanEx::getOrNewRod(const RodLabel &l, RodScanEx defaultEx) {
00019 RodInfoMap::iterator result = rodInfo.find(l);
00020 if(result == rodInfo.end()) {
00021 rodInfo.insert(std::make_pair(l, defaultEx));
00022 result = rodInfo.find(l);
00023 }
00024 return result->second;
00025 }
00026
00027 const RodScanEx &ScanEx::getRodScanInfo(const RodLabel &l) const {
00028 RodInfoMap::const_iterator result = rodInfo.find(l);
00029 if(result == rodInfo.end()) {
00030 cerr << " getRodScanInfo const: ROD not found\n";
00031 throw SctApiException("Bad ROD");
00032 }
00033 return result->second;
00034 }
00035
00036 RodScanEx &ScanEx::getRodScanInfo(const RodLabel &l) {
00037 RodInfoMap::iterator result = rodInfo.find(l);
00038 if(result == rodInfo.end()) {
00039 cerr << " getRodScanInfo: ROD not found\n";
00040 throw SctApiException("Bad ROD");
00041 }
00042 return result->second;
00043 }
00044
00045 const std::list<RodLabel> SctApi::listRods() const {
00046 return rodList;
00047 }
00048
00049 const std::list<CrateLabel> SctApi::listCrates() const {
00050 std::list<CrateLabel> crateList;
00051
00052 for(map<pair<unsigned int,unsigned int>, Crate*>::const_iterator i=crateMap.begin();
00053 i!=crateMap.end();
00054 i++){
00055 crateList.push_back(CrateLabel(i->first.first, i->first.second));
00056 }
00057
00058 return crateList;
00059 }
00060
00061 void SctApi::addRodToList(RodLabel newRod) {
00062 rodList.push_back(newRod);
00063 RodInfo newInfo;
00064 rodInfoList.insert(make_pair(newRod, newInfo));
00065 }
00066
00067 RodInfo &SctApi::getRodInfo(const RodLabel &l){
00068 std::map<RodLabel, RodInfo>::iterator result = rodInfoList.find(l);
00069 if(result == rodInfoList.end()) {
00070 cerr << " getRodInfo: ROD not found\n";
00071 throw SctApiException("Bad ROD");
00072 }
00073 return result->second;
00074 }
00075 }