CMS 3D CMS Logo

PixelConfig.h
Go to the documentation of this file.
1 #ifndef PixelConfig_h
2 #define PixelConfig_h
3 
9 #include <fstream>
10 #include <string>
11 #include <vector>
12 #include <utility>
13 
14 namespace pos{
20  class PixelConfig {
21 
22  public:
23 
24  void write(std::ofstream& out){
25  for (unsigned int i=0;i<versions_.size();i++){
26  out << versions_[i].first<<" "<<versions_[i].second<<std::endl;
27  }
28  }
29 
30  void add(std::string dir, unsigned int version){
31  std::pair<std::string,unsigned int> aPair(dir,version);
32  versions_.push_back(aPair);
33  }
34  //returns -1 if it can not find the dir.
35  int find(std::string dir, unsigned int &version){
36 // std::cout << "[pos::PixelConfig::find()] versions_.size() = " << versions_.size() << std::endl ;
37  for(unsigned int i=0;i<versions_.size();i++){
38 // std::cout << "Looking :"<<versions_[i].first
39 // <<" "<<versions_[i].second<<std::endl;
40  if (versions_[i].first==dir) {
41  version=versions_[i].second;
42  return 0;
43  }
44  }
45  return -1;
46  }
47 
48  //returns -1 if it can not find the dir.
49  int update(std::string dir, unsigned int &version, unsigned int newversion){
50  for(unsigned int i=0;i<versions_.size();i++){
51  //std::cout << "Looking :"<<versions_[i].first
52  // <<" "<<versions_[i].second<<std::endl;
53  if (versions_[i].first==dir) {
54  version=versions_[i].second;
55  versions_[i].second=newversion;
56  return 0;
57  }
58  }
59  return -1;
60  }
61 
62  std::vector<std::pair<std::string,unsigned int> > versions(){
63  return versions_;
64  }
65 
66  private:
67 
68  std::vector<std::pair<std::string,unsigned int> > versions_;
69 
70  };
71 }
72 #endif
std::vector< std::pair< std::string, unsigned int > > versions()
Definition: PixelConfig.h:62
std::vector< std::pair< std::string, unsigned int > > versions_
Definition: PixelConfig.h:68
void add(std::string dir, unsigned int version)
Definition: PixelConfig.h:30
int find(std::string dir, unsigned int &version)
Definition: PixelConfig.h:35
void write(std::ofstream &out)
Definition: PixelConfig.h:24
int update(std::string dir, unsigned int &version, unsigned int newversion)
Definition: PixelConfig.h:49
dbl *** dir
Definition: mlp_gen.cc:35
This class implements..
Definition: PixelConfig.h:20