CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public 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< std::filesystem::path, NameAndTypesLoadableToPlugins
 
typedef std::pair< std::string, std::string > NameAndType
 
typedef std::vector< NameAndTypeNameAndTypes
 

Public Member Functions

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

Static Public Member Functions

static void read (std::istream &, const std::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 &)
 

Static Private Member Functions

static bool readline (std::istream &iIn, const std::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 39 of file CacheParser.h.

Member Typedef Documentation

◆ CategoryToInfos

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

Definition at line 41 of file CacheParser.h.

◆ LoadableToPlugins

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

Definition at line 44 of file CacheParser.h.

◆ NameAndType

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

Definition at line 42 of file CacheParser.h.

◆ NameAndTypes

Definition at line 43 of file CacheParser.h.

Constructor & Destructor Documentation

◆ CacheParser()

edmplugin::CacheParser::CacheParser ( const CacheParser )
delete

Member Function Documentation

◆ operator=()

const CacheParser& edmplugin::CacheParser::operator= ( const CacheParser )
delete

◆ read() [1/2]

void CacheParser::read ( std::istream &  iIn,
const std::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.

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  }

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

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

◆ read() [2/2]

void CacheParser::read ( std::istream &  iIn,
LoadableToPlugins oOut 
)
static

Definition at line 176 of file CacheParser.cc.

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  }

References relativeConstraints::empty, info(), castor_dqm_sourceclient_file_cfg::path, readline(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

◆ readline()

bool CacheParser::readline ( std::istream &  iIn,
const std::filesystem::path &  iDirectory,
unsigned long  iRecordNumber,
PluginInfo oInfo,
std::string &  oPluginType 
)
staticprivate

Definition at line 82 of file CacheParser.cc.

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  }

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

Referenced by read().

◆ replaceSpaces()

std::string & CacheParser::replaceSpaces ( std::string &  io)
staticprivate

Definition at line 195 of file CacheParser.cc.

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

Referenced by write().

◆ restoreSpaces()

std::string & CacheParser::restoreSpaces ( std::string &  io)
staticprivate

Definition at line 203 of file CacheParser.cc.

203  {
205  while (std::string::npos != (index = io.find_first_of('%', index))) {
206  io[index] = ' ';
207  }
208  return io;
209  }

Referenced by readline().

◆ write() [1/2]

void CacheParser::write ( const CategoryToInfos iInfos,
std::ostream &  oOut 
)
static

Definition at line 142 of file CacheParser.cc.

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  }

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

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

◆ write() [2/2]

void CacheParser::write ( LoadableToPlugins iIn,
std::ostream &  oOut 
)
static

Definition at line 162 of file CacheParser.cc.

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  }

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

Referenced by pkg.AbstractPkg::generate().

Friends And Related Function Documentation

◆ ::TestCacheParser

friend class ::TestCacheParser
friend

Definition at line 66 of file CacheParser.h.

edm::sort_all
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
edmplugin::CacheParser::NameAndType
std::pair< std::string, std::string > NameAndType
Definition: CacheParser.h:42
edmplugin::CacheParser::restoreSpaces
static std::string & restoreSpaces(std::string &io)
Definition: CacheParser.cc:203
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edmplugin::CacheParser::LoadableToPlugins
std::map< std::filesystem::path, NameAndTypes > LoadableToPlugins
Definition: CacheParser.h:44
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
edmplugin::CacheParser::replaceSpaces
static std::string & replaceSpaces(std::string &io)
Definition: CacheParser.cc:195
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
pat
Definition: HeavyIon.h:7
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edmplugin::CacheParser::write
static void write(const CategoryToInfos &, std::ostream &)
Definition: CacheParser.cc:142
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
PluginInfo
edmplugin::checkForError
static void checkForError(const std::istream &iIn, unsigned long iRecordNumber, const std::string &iContext)
Definition: CacheParser.cc:71
edmplugin::CacheParser::readline
static bool readline(std::istream &iIn, const std::filesystem::path &iDirectory, unsigned long iRecordNumber, PluginInfo &oInfo, std::string &oPluginType)
Definition: CacheParser.cc:82