CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CalibFormats/SiPixelObjects/interface/PixelConfig.h

Go to the documentation of this file.
00001 #ifndef PixelConfig_h
00002 #define PixelConfig_h
00003 
00009 namespace pos{
00015   class PixelConfig {
00016     
00017   public:
00018 
00019     void write(std::ofstream& out){
00020       for (unsigned int i=0;i<versions_.size();i++){
00021         out << versions_[i].first<<"   "<<versions_[i].second<<std::endl;
00022       }
00023     }
00024 
00025     void add(std::string dir, unsigned int version){
00026       std::pair<std::string,unsigned int> aPair(dir,version);
00027       versions_.push_back(aPair);    
00028     }
00029     //returns -1 if it can not find the dir.
00030     int find(std::string dir, unsigned int &version){
00031 //      std::cout << "[pos::PixelConfig::find()] versions_.size() = " << versions_.size() << std::endl ;
00032       for(unsigned int i=0;i<versions_.size();i++){
00033 //      std::cout << "Looking :"<<versions_[i].first
00034 //                <<" "<<versions_[i].second<<std::endl;
00035         if (versions_[i].first==dir) {
00036           version=versions_[i].second;
00037           return 0;
00038         }
00039       }
00040       return -1;
00041     }
00042 
00043     //returns -1 if it can not find the dir.
00044     int update(std::string dir, unsigned int &version, unsigned int newversion){
00045       for(unsigned int i=0;i<versions_.size();i++){
00046         //std::cout << "Looking :"<<versions_[i].first
00047         //            <<" "<<versions_[i].second<<std::endl;
00048         if (versions_[i].first==dir) {
00049           version=versions_[i].second;
00050           versions_[i].second=newversion;
00051           return 0;
00052         }
00053       }
00054       return -1;
00055     }
00056 
00057     std::vector<std::pair<std::string,unsigned int> > versions(){
00058       return versions_;
00059     }
00060 
00061   private:
00062    
00063     std::vector<std::pair<std::string,unsigned int> > versions_; 
00064 
00065   };
00066 }
00067 #endif