CMS 3D CMS Logo

Public Member Functions | Private Attributes

pos::PixelConfigList Class Reference

This class implements.. More...

#include <interface/PixelConfigList.h>

List of all members.

Public Member Functions

unsigned int add (PixelConfig &aConfig)
unsigned int clone (unsigned int oldkey, std::string path, unsigned int version)
unsigned int numberOfConfigs ()
PixelConfigoperator[] (unsigned int i)
void readfile (std::string filename)
void reload (std::string filename)
unsigned int size ()
void writefile ()

Private Attributes

std::vector< PixelConfigconfigs

Detailed Description

This class implements..

A longer explanation will be placed here later

Definition at line 15 of file PixelConfigList.h.


Member Function Documentation

unsigned int pos::PixelConfigList::add ( PixelConfig aConfig) [inline]

Definition at line 116 of file PixelConfigList.h.

References configs.

Referenced by pos::PixelConfigFile::makeKey().

                                          {

      configs.push_back(aConfig);
    
      return configs.size()-1;

    }
unsigned int pos::PixelConfigList::clone ( unsigned int  oldkey,
std::string  path,
unsigned int  version 
) [inline]

Definition at line 98 of file PixelConfigList.h.

References configs, gather_cfg::cout, and pos::PixelConfig::update().

Referenced by pos::PixelAliasList::updateConfigAlias().

                                                                                 {
      PixelConfig aConfig=configs[oldkey];
    
      unsigned int oldversion;
    
      if (-1==aConfig.update(path,oldversion,version)){
        std::cout << "Old version not found for path="<<path<<" in config "<<oldkey<<std::endl;
        assert(0);
      }

      configs.push_back(aConfig);
    
      return configs.size()-1;

    }
unsigned int pos::PixelConfigList::numberOfConfigs ( ) [inline]

Definition at line 134 of file PixelConfigList.h.

References configs.

{ return configs.size(); }
PixelConfig& pos::PixelConfigList::operator[] ( unsigned int  i) [inline]

Definition at line 126 of file PixelConfigList.h.

References configs, and i.

{return configs[i];}
void pos::PixelConfigList::readfile ( std::string  filename) [inline]

Definition at line 42 of file PixelConfigList.h.

References pos::PixelConfig::add(), configs, gather_cfg::cout, recoMuon::in, GlobalPosition_Frontier_DevDB_cff::tag, tmp, and BeamSplash_cfg::version.

Referenced by pos::PixelConfigFile::getConfig(), and reload().

                                     {

      std::ifstream in(filename.c_str());

      std::string tag;
            
      in >> tag;
      while(tag.substr(0,1) == "#") {
        in.ignore(4096, '\n'); //skips to endl;
        in >> tag;
      }

      unsigned int version=0;

      while(!in.eof()){
        if (tag!="key"){
          std::cout << "PixelConfigDB: tag="<<tag<<std::endl;
          assert(0);
        }
        unsigned int tmp_version;
        in >> tmp_version;
        if (version!=tmp_version){
          std::cout << "PixelConfigDB: read version: "<<tmp_version<<" while expected "
                    << version << std::endl;
          assert(0);
        }

        in >> tag;
        while(tag.substr(0,1) == "#") {
          in.ignore(4096, '\n'); //skips to endl;
          in >> tag;
        }

        PixelConfig aConfig;
        while (tag!="key"&&in.good()){
          unsigned int tmp;
          in >>tmp;
          //std::cout << "adding: "<<tag<<" "<<tmp<<std::endl;
          aConfig.add(tag,tmp);
          in >> tag;
          while(tag.substr(0,1) == "#") {
            in.ignore(4096, '\n'); //skips to endl;
            in >> tag;
          }
        }
      
        configs.push_back(aConfig);
        version++;
      
      };
                
      in.close();

    }
void pos::PixelConfigList::reload ( std::string  filename) [inline]

Definition at line 128 of file PixelConfigList.h.

References configs, and readfile().

Referenced by pos::PixelConfigFile::getConfig().

    {
      configs.clear() ;
      readfile(filename) ;
    }
unsigned int pos::PixelConfigList::size ( void  ) [inline]

Definition at line 124 of file PixelConfigList.h.

References configs.

{ return configs.size(); }
void pos::PixelConfigList::writefile ( ) [inline]

Definition at line 19 of file PixelConfigList.h.

References configs, createBeamHaloJobs::directory, lut2db_cfg::filename, i, and dbtoconf::out.

Referenced by pos::PixelConfigFile::addVersionAlias(), and pos::PixelConfigFile::makeKey().

                    {

      std::string directory=getenv("PIXELCONFIGURATIONBASE");
/*       directory+="/PixelConfigDataExamples/"; */
      directory+="/";
    
      std::string filename=directory+"/configurations.txt";

      std::ofstream out(filename.c_str());
      assert(out.good());

      for (unsigned int i=0;i<configs.size();i++){
        //std::cout << "key "<<i<<std::endl; 
        out << "key "<<i<<std::endl;
        configs[i].write(out);
        out <<std::endl;
        //std::cout <<std::endl; 
      }


    }

Member Data Documentation

Definition at line 138 of file PixelConfigList.h.

Referenced by add(), clone(), numberOfConfigs(), operator[](), readfile(), reload(), size(), and writefile().