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.

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 125 of file CacheParser.cc.

References info, and readline().

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 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 191 of file CacheParser.cc.

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

192 {
193  unsigned long recordNumber=0;
194 
195  std::string pluginType;
196 
198  NameAndType pat;
200 
201  while(iIn) {
202  ++recordNumber;
203  if( not readline(iIn,empty,recordNumber,info,pat.second) ) {
204  break;
205  }
206  pat.first = info.name_;
207  oOut[info.loadable_].push_back(pat);
208  }
209 }
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:85
int path() const
Definition: HLTadd.h:3
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_, and restoreSpaces().

Referenced by read().

87 {
88  static const std::string kNewLine("start of new line");
89  std::string fileName;
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:221
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 212 of file CacheParser.cc.

References getHLTprescales::index.

Referenced by write().

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

Definition at line 221 of file CacheParser.cc.

References getHLTprescales::index.

Referenced by readline().

222 {
224  while(std::string::npos != (index = io.find_first_of("%",index))) {
225  io[index]=' ';
226  }
227  return io;
228 }
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.

Referenced by 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  std::string loadable(it2->loadable_.leaf());
165  std::string name(it2->name_);
166  ordered[loadable].push_back(NameAndType(name,type));
167  }
168  }
169  write(ordered,oOut);
170 }
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:151
void CacheParser::write ( LoadableToPlugins iIn,
std::ostream &  oOut 
)
static

Definition at line 173 of file CacheParser.cc.

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

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