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 39 of file CacheParser.h.

Member Typedef Documentation

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

Definition at line 43 of file CacheParser.h.

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

Definition at line 46 of file CacheParser.h.

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

Definition at line 44 of file CacheParser.h.

Definition at line 45 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 126 of file CacheParser.cc.

References info, and readline().

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

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

Definition at line 196 of file CacheParser.cc.

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

197 {
198  unsigned long recordNumber=0;
199 
200  std::string pluginType;
201 
203  NameAndType pat;
205 
206  while(iIn) {
207  ++recordNumber;
208  if( not readline(iIn,empty,recordNumber,info,pat.second) ) {
209  break;
210  }
211  pat.first = info.name_;
212  oOut[info.loadable_].push_back(pat);
213  }
214 }
std::pair< std::string, std::string > NameAndType
Definition: CacheParser.h:44
static bool readline(std::istream &iIn, const boost::filesystem::path &iDirectory, unsigned long iRecordNumber, PluginInfo &oInfo, std::string &oPluginType)
Definition: CacheParser.cc:86
list path
Definition: scaleCards.py:51
bool CacheParser::readline ( std::istream &  iIn,
const boost::filesystem::path &  iDirectory,
unsigned long  iRecordNumber,
PluginInfo oInfo,
std::string &  oPluginType 
)
staticprivate

Definition at line 86 of file CacheParser.cc.

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

Referenced by read().

88 {
89  static const std::string kNewLine("start of new line");
90  std::string fileName;
91  std::string pluginName;
92  iIn >> fileName;
93  if(iIn.eof()) { return false;}
94  checkForError(iIn,iRecordNumber,kNewLine);
96  iIn >> pluginName;
97  checkForError(iIn,iRecordNumber,fileName);
98  CacheParser::restoreSpaces(pluginName);
99  iIn >> oPluginType;
100  checkForError(iIn,iRecordNumber,oPluginType);
101  CacheParser::restoreSpaces(oPluginType);
102 
103  oInfo.loadable_ = iDirectory / fileName;
104  oInfo.name_ = pluginName;
105 
106  //ignore everything to the end of line
107  iIn.ignore(std::numeric_limits<int>::max(),
108  '\n');
109  while(iIn.peek() == '\n') {
110  iIn.get();
111  }
112  return true;
113 }
static std::string & restoreSpaces(std::string &io)
Definition: CacheParser.cc:226
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:72
std::string & CacheParser::replaceSpaces ( std::string &  io)
staticprivate

Definition at line 217 of file CacheParser.cc.

References getHLTprescales::index.

Referenced by write().

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

Definition at line 226 of file CacheParser.cc.

References getHLTprescales::index.

Referenced by readline().

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

Definition at line 152 of file CacheParser.cc.

References mergeVDriftHistosByStation::name.

Referenced by main().

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

Definition at line 178 of file CacheParser.cc.

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

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