CMS 3D CMS Logo

List of all members | Public Types | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Friends
edmplugin::CacheParser Class Reference

#include <CacheParser.h>

Public Types

typedef std::map< std::string, std::vector< PluginInfo > > CategoryToInfos
 
typedef std::map< boost::filesystem::path, NameAndTypesLoadableToPlugins
 
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 &)=delete
 
const CacheParseroperator= (const CacheParser &)=delete
 

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)
 

Friends

class ::TestCacheParser
 

Detailed Description

Definition at line 40 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 )
privatedelete

Member Function Documentation

const CacheParser& edmplugin::CacheParser::operator= ( const CacheParser )
privatedelete
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 120 of file CacheParser.cc.

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

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), main(), and edmplugin::readCacheFile().

122  {
123  unsigned long recordNumber = 0;
124 
125  std::string pluginType;
126 
128 
129  while (iIn) {
130  ++recordNumber;
131  if (not readline(iIn, iDirectory, recordNumber, info, pluginType)) {
132  break;
133  }
134  iOut[pluginType].push_back(info);
135  }
136  //now do a sort which preserves any previous order for files
137  for (CacheParser::CategoryToInfos::iterator it = iOut.begin(), itEnd = iOut.end(); it != itEnd; ++it) {
138  std::stable_sort(it->second.begin(), it->second.end(), CompPluginInfos());
139  }
140  }
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:82
void CacheParser::read ( std::istream &  iIn,
LoadableToPlugins oOut 
)
static

Definition at line 176 of file CacheParser.cc.

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

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

176  {
177  unsigned long recordNumber = 0;
178 
179  std::string pluginType;
180 
184 
185  while (iIn) {
186  ++recordNumber;
187  if (not readline(iIn, empty, recordNumber, info, pat.second)) {
188  break;
189  }
190  pat.first = info.name_;
191  oOut[info.loadable_].push_back(pat);
192  }
193  }
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:82
std::pair< std::string, std::string > NameAndType
Definition: CacheParser.h:43
Definition: HeavyIon.h:7
bool CacheParser::readline ( std::istream &  iIn,
const boost::filesystem::path &  iDirectory,
unsigned long  iRecordNumber,
PluginInfo oInfo,
std::string &  oPluginType 
)
staticprivate

Definition at line 82 of file CacheParser.cc.

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

Referenced by read().

86  {
87  static const std::string kNewLine("start of new line");
89  std::string pluginName;
90  iIn >> fileName;
91  if (iIn.eof()) {
92  return false;
93  }
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(), '\n');
108  while (iIn.peek() == '\n') {
109  iIn.get();
110  }
111  return true;
112  }
static std::string & restoreSpaces(std::string &io)
Definition: CacheParser.cc:203
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 195 of file CacheParser.cc.

Referenced by write().

195  {
197  while (std::string::npos != (index = io.find_first_of(" \t\n", index))) {
198  io[index] = '%';
199  }
200  return io;
201  }
uint16_t size_type
std::string & CacheParser::restoreSpaces ( std::string &  io)
staticprivate

Definition at line 203 of file CacheParser.cc.

Referenced by readline().

203  {
205  while (std::string::npos != (index = io.find_first_of("%", index))) {
206  io[index] = ' ';
207  }
208  return io;
209  }
uint16_t size_type
void CacheParser::write ( const CategoryToInfos iInfos,
std::ostream &  oOut 
)
static

Definition at line 142 of file CacheParser.cc.

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

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

142  {
143  //order the data more to our liking: library then object then type
144  LoadableToPlugins ordered;
145 
146  for (CategoryToInfos::const_iterator it = iInfos.begin(); it != iInfos.end(); ++it) {
147  std::string type(it->first);
148  for (std::vector<PluginInfo>::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
149  //remove any directory specification
150 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 47
151  std::string loadable(it2->loadable_.filename().string());
152 #else
153  std::string loadable(it2->loadable_.filename());
154 #endif
155  std::string name(it2->name_);
156  ordered[loadable].push_back(NameAndType(name, type));
157  }
158  }
159  write(ordered, oOut);
160  }
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:142
void CacheParser::write ( LoadableToPlugins iIn,
std::ostream &  oOut 
)
static

Definition at line 162 of file CacheParser.cc.

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

Referenced by pkg.AbstractPkg::generate().

162  {
163  for (LoadableToPlugins::iterator it = iIn.begin(); it != iIn.end(); ++it) {
164  std::string loadable(it->first.string());
165  replaceSpaces(loadable);
166  edm::sort_all(it->second);
167 
168  for (std::vector<std::pair<std::string, std::string> >::iterator it2 = it->second.begin();
169  it2 != it->second.end();
170  ++it2) {
171  oOut << loadable << " " << replaceSpaces(it2->first) << " " << replaceSpaces(it2->second) << "\n";
172  }
173  }
174  }
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
static std::string & replaceSpaces(std::string &io)
Definition: CacheParser.cc:195

Friends And Related Function Documentation

friend class ::TestCacheParser
friend

Definition at line 64 of file CacheParser.h.