SctApiMulti.cxx

00001 
00008 #include <utility>
00009 
00010 #include "SctApi.h"
00011 #include "SctApiHisto.h"
00012 #include "SctApiRodInfo.h"
00013 #include "SctApiException.h"
00014 
00015 using namespace std;
00016 
00017 namespace SctApi {
00018 
00019 RodScanEx &ScanEx::getOrNewRod(const RodLabel &l, RodScanEx defaultEx) {
00020   RodInfoMap::iterator result = rodInfo.find(l);
00021   if(result == rodInfo.end()) {
00022     rodInfo.insert(std::make_pair(l, defaultEx));
00023     result = rodInfo.find(l);
00024   }
00025   return result->second;
00026 }
00027 
00028 const RodScanEx &ScanEx::getRodScanInfo(const RodLabel &l) const {
00029   RodInfoMap::const_iterator result = rodInfo.find(l);
00030   if(result == rodInfo.end()) {
00031     cerr << " getRodScanInfo const: ROD not found\n";
00032     throw SctApiException("Bad ROD");
00033   }
00034   return result->second;
00035 }
00036 
00037 RodScanEx &ScanEx::getRodScanInfo(const RodLabel &l) {
00038   RodInfoMap::iterator result = rodInfo.find(l);
00039   if(result == rodInfo.end()) {
00040     cerr << " getRodScanInfo: ROD not found\n";
00041     throw SctApiException("Bad ROD");
00042   }
00043   return result->second;
00044 }
00045 
00046 const std::list<RodLabel> SctApi::listRods() const {
00047   return rodList;
00048 }
00049 
00050   /*
00051     const std::list<CrateLabel> SctApi::listCrates() const {
00052     std::list<CrateLabel> crateList;
00053     
00054     crateList.push_back(CrateLabel(prt(), crt()));
00055     
00056     return crateList;
00057     }
00058   */
00059 
00060 void SctApi::addRodToList(RodLabel newRod) {
00061   rodList.push_back(newRod);
00062   {
00063     boost::recursive_mutex::scoped_lock lock(rodInfoListAccess);
00064     if (rodInfoList.find(newRod)==rodInfoList.end()){
00065       RodInfo newInfo;
00066       rodInfoList.insert(make_pair(newRod, newInfo));
00067     }
00068   }
00069 }
00070 
00071 RodInfo &SctApi::getRodInfo(const RodLabel &l){
00072   boost::recursive_mutex::scoped_lock lock(rodInfoListAccess);
00073   std::map<RodLabel, RodInfo>::iterator result = rodInfoList.find(l);
00074   if(result == rodInfoList.end()) {
00075     cout << " SctApi::getRodInfo(" << Sct::URID(l.partition, l.crate, l.rod) << ") must now throw an exception as the said ROD is not in our rodInfoList" << std::endl;
00076     throw SctApiException("Bad ROD");
00077   }
00078   return result->second;
00079 }
00080 }

Generated on Mon Feb 6 14:01:29 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6