CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Static Public Member Functions | Private Member Functions | Static Private Member Functions
edmplugin::CacheParser Class Reference

#include <CacheParser.h>

Public Types

typedef std::map< std::string,
std::vector< PluginInfo > > 
CategoryToInfos
 
typedef std::map
< boost::filesystem::path,
NameAndTypes
LoadableToPlugins
 
typedef std::pair< std::string,
std::string > 
NameAndType
 
typedef std::vector< NameAndTypeNameAndTypes
 

Static Public Member Functions

static void read (std::istream &, const boost::filesystem::path &iDirectory, CategoryToInfos &oOut)
 
static void read (std::istream &, LoadableToPlugins &oOut)
 
static void write (const CategoryToInfos &, std::ostream &)
 
static void write (LoadableToPlugins &iIn, std::ostream &)
 

Private Member Functions

 CacheParser (const CacheParser &)
 
const CacheParseroperator= (const CacheParser &)
 

Static Private Member Functions

static bool readline (std::istream &iIn, const boost::filesystem::path &iDirectory, unsigned long iRecordNumber, PluginInfo &oInfo, std::string &oPluginType)
 
static std::string & replaceSpaces (std::string &io)
 
static std::string & restoreSpaces (std::string &io)
 

Detailed Description

Definition at line 38 of file CacheParser.h.

Member Typedef Documentation

typedef std::map<std::string, std::vector<PluginInfo> > edmplugin::CacheParser::CategoryToInfos

Definition at line 42 of file CacheParser.h.

typedef std::map<boost::filesystem::path, NameAndTypes > edmplugin::CacheParser::LoadableToPlugins

Definition at line 45 of file CacheParser.h.

typedef std::pair< std::string, std::string> edmplugin::CacheParser::NameAndType

Definition at line 43 of file CacheParser.h.

Definition at line 44 of file CacheParser.h.

Constructor & Destructor Documentation

edmplugin::CacheParser::CacheParser ( const CacheParser )
private

Member Function Documentation

const CacheParser& edmplugin::CacheParser::operator= ( const CacheParser )
private
void CacheParser::read ( std::istream &  iIn,
const boost::filesystem::path &  iDirectory,
CacheParser::CategoryToInfos iOut 
)
static

The std::vector<PluginInfo>'s in CategoryToInfos are guaranteed to be ordered by PluginInfo.name_ where identical names are ordered by the order they are passed to read. In this way multiple calls to read for different directories will preserve the ordering

Definition at line 125 of file CacheParser.cc.

References info(), readline(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by main(), and edmplugin::PluginManager::PluginManager().

128 {
129  unsigned long recordNumber=0;
130 
131  std::string pluginType;
132 
134 
135  while(iIn) {
136  ++recordNumber;
137  if( not readline(iIn,iDirectory,recordNumber,info,pluginType) ) {
138  break;
139  }
140  iOut[pluginType].push_back(info);
141  }
142  //now do a sort which preserves any previous order for files
143  for(CacheParser::CategoryToInfos::iterator it = iOut.begin(), itEnd=iOut.end();
144  it != itEnd;
145  ++it) {
146  std::stable_sort(it->second.begin(),it->second.end(), CompPluginInfos());
147  }
148 }
static const TGPicture * info(bool iBackgroundIsBlack)
static bool readline(std::istream &iIn, const boost::filesystem::path &iDirectory, unsigned long iRecordNumber, PluginInfo &oInfo, std::string &oPluginType)
Definition: CacheParser.cc:85
void CacheParser::read ( std::istream &  iIn,
LoadableToPlugins oOut 
)
static

Definition at line 195 of file CacheParser.cc.

References relativeConstraints::empty, info(), edmplugin::PluginInfo::loadable_, edmplugin::PluginInfo::name_, cmsHarvester::path, readline(), and AlCaHLTBitMon_QueryRunRegistry::string.

196 {
197  unsigned long recordNumber=0;
198 
199  std::string pluginType;
200 
202  NameAndType pat;
204 
205  while(iIn) {
206  ++recordNumber;
207  if( not readline(iIn,empty,recordNumber,info,pat.second) ) {
208  break;
209  }
210  pat.first = info.name_;
211  oOut[info.loadable_].push_back(pat);
212  }
213 }
static const TGPicture * info(bool iBackgroundIsBlack)
std::pair< std::string, std::string > NameAndType
Definition: CacheParser.h:43
static bool readline(std::istream &iIn, const boost::filesystem::path &iDirectory, unsigned long iRecordNumber, PluginInfo &oInfo, std::string &oPluginType)
Definition: CacheParser.cc:85
tuple path
else: Piece not in the list, fine.
bool CacheParser::readline ( std::istream &  iIn,
const boost::filesystem::path &  iDirectory,
unsigned long  iRecordNumber,
PluginInfo oInfo,
std::string &  oPluginType 
)
staticprivate

Definition at line 85 of file CacheParser.cc.

References edmplugin::checkForError(), convertXMLtoSQLite_cfg::fileName, edmplugin::PluginInfo::loadable_, max(), edmplugin::PluginInfo::name_, restoreSpaces(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by read().

87 {
88  static const std::string kNewLine("start of new line");
90  std::string pluginName;
91  iIn >> fileName;
92  if(iIn.eof()) { return false;}
93  checkForError(iIn,iRecordNumber,kNewLine);
95  iIn >> pluginName;
96  checkForError(iIn,iRecordNumber,fileName);
97  CacheParser::restoreSpaces(pluginName);
98  iIn >> oPluginType;
99  checkForError(iIn,iRecordNumber,oPluginType);
100  CacheParser::restoreSpaces(oPluginType);
101 
102  oInfo.loadable_ = iDirectory / fileName;
103  oInfo.name_ = pluginName;
104 
105  //ignore everything to the end of line
106  iIn.ignore(std::numeric_limits<int>::max(),
107  '\n');
108  while(iIn.peek() == '\n') {
109  iIn.get();
110  }
111  return true;
112 }
static std::string & restoreSpaces(std::string &io)
Definition: CacheParser.cc:225
const T & max(const T &a, const T &b)
static void checkForError(const std::istream &iIn, unsigned long iRecordNumber, const std::string &iContext)
Definition: CacheParser.cc:71
std::string & CacheParser::replaceSpaces ( std::string &  io)
staticprivate

Definition at line 216 of file CacheParser.cc.

References cmsHarvester::index.

Referenced by write().

217 {
219  while(std::string::npos != (index = io.find_first_of(" \t\n",index))) {
220  io[index]='%';
221  }
222  return io;
223 }
uint16_t size_type
std::string & CacheParser::restoreSpaces ( std::string &  io)
staticprivate

Definition at line 225 of file CacheParser.cc.

References cmsHarvester::index.

Referenced by readline().

226 {
228  while(std::string::npos != (index = io.find_first_of("%",index))) {
229  io[index]=' ';
230  }
231  return io;
232 }
uint16_t size_type
void CacheParser::write ( const CategoryToInfos iInfos,
std::ostream &  oOut 
)
static

Definition at line 151 of file CacheParser.cc.

References mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pkg.AbstractPkg::generate(), and main().

152 {
153  //order the data more to our liking: library then object then type
154  LoadableToPlugins ordered;
155 
156  for(CategoryToInfos::const_iterator it = iInfos.begin();
157  it != iInfos.end();
158  ++it) {
159  std::string type(it->first);
160  for(std::vector<PluginInfo>::const_iterator it2=it->second.begin();
161  it2 != it->second.end();
162  ++it2) {
163  //remove any directory specification
164 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 47
165  std::string loadable(it2->loadable_.filename().string());
166 #else
167  std::string loadable(it2->loadable_.filename());
168 #endif
169  std::string name(it2->name_);
170  ordered[loadable].push_back(NameAndType(name,type));
171  }
172  }
173  write(ordered,oOut);
174 }
type
Definition: HCALResponse.h:21
std::pair< std::string, std::string > NameAndType
Definition: CacheParser.h:43
std::map< boost::filesystem::path, NameAndTypes > LoadableToPlugins
Definition: CacheParser.h:45
static void write(const CategoryToInfos &, std::ostream &)
Definition: CacheParser.cc:151
void CacheParser::write ( LoadableToPlugins iIn,
std::ostream &  oOut 
)
static

Definition at line 177 of file CacheParser.cc.

References replaceSpaces(), edm::sort_all(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pkg.AbstractPkg::generate().

178 {
179  for( LoadableToPlugins::iterator it = iIn.begin();
180  it!=iIn.end();
181  ++it) {
182  std::string loadable(it->first.string());
183  replaceSpaces(loadable);
184  edm::sort_all(it->second);
185 
186  for(std::vector<std::pair<std::string,std::string> >::iterator it2 = it->second.begin();
187  it2 != it->second.end();
188  ++it2) {
189  oOut << loadable <<" "<<replaceSpaces(it2->first)<<" "<<replaceSpaces(it2->second)<<"\n";
190  }
191  }
192 }
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
static std::string & replaceSpaces(std::string &io)
Definition: CacheParser.cc:216