CMS 3D CMS Logo

ParameterCollector.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 //
4 
5 // class ParameterCollector provides a tool to parse blocks of PSets
6 // like "PythiaParameters" where one can list blocks of vstrings to be
7 // parsed inside another vstring named "parameterSets". It is also
8 // extended to allow nesting of blocks using "+block" statements
9 // (something which is heavily used for Herwig++).
10 // arbitrary vstring blocks can also be explicitly retrieved by name.
11 
12 #ifndef gen_ParameterCollector_h
13 #define gen_ParameterCollector_h
14 
15 #include <ostream>
16 #include <vector>
17 #include <string>
18 #include <map>
19 
20 #include <boost/iterator/iterator_facade.hpp>
21 
23 
24 namespace gen {
25 
27  public:
31 
32  // this iterator makes begin()/end() look like it was
33  // looping over a simple vector<string>
34 
36  : public boost::iterator_facade<const_iterator, const std::string, boost::forward_traversal_tag> {
37  public:
38  const_iterator() : collector_(nullptr), dump_(nullptr) {}
39 
40  protected:
41  friend class ParameterCollector;
42 
43  inline const_iterator(const ParameterCollector *collector,
44  std::vector<std::string>::const_iterator begin,
45  std::vector<std::string>::const_iterator end,
46  bool special = false,
47  std::ostream *dump = nullptr);
48 
49  private:
51 
52  void increment();
53  const std::string &dereference() const { return cache_; }
54  bool equal(const const_iterator &other) const { return iter_ == other.iter_; }
55 
56  void next();
57 
58  typedef std::pair<std::vector<std::string>::const_iterator, std::vector<std::string>::const_iterator> IterPair;
59 
61  std::ostream *dump_;
62  bool special_;
63  std::vector<IterPair> iter_;
65  };
66 
67  // start iterating over blocks listed in "parameterSets"
68  const_iterator begin() const;
69  const_iterator begin(std::ostream &dump) const;
70 
71  // start iterating over contents of this particular vstring block
72  const_iterator begin(const std::string &block) const;
73  const_iterator begin(const std::string &block, std::ostream &dump) const;
74 
75  // the iterator to mark the end of a loop
76  const_iterator end() const { return const_iterator(); }
77 
78  // this replaces ${...} with environment variables
79  // needed for ThePEG because you need full path to repository
80  static std::string resolve(const std::string &line);
81 
82  private:
83  friend class const_iterator;
84 
85  std::map<std::string, std::vector<std::string> > contents_;
86  };
87 
88 } // namespace gen
89 
90 #endif // gen_ParameterCollector_h
gen::ParameterCollector::const_iterator::collector_
const ParameterCollector * collector_
Definition: ParameterCollector.h:60
gen::ParameterCollector::const_iterator::const_iterator
const_iterator()
Definition: ParameterCollector.h:38
gen::ParameterCollector::const_iterator
Definition: ParameterCollector.h:35
gen::ParameterCollector::const_iterator::increment
void increment()
Definition: ParameterCollector.cc:37
gen::ParameterCollector::const_iterator::dereference
const std::string & dereference() const
Definition: ParameterCollector.h:53
gen::ParameterCollector
Definition: ParameterCollector.h:26
gen::ParameterCollector::const_iterator::iter_
std::vector< IterPair > iter_
Definition: ParameterCollector.h:63
gen::ParameterCollector::ParameterCollector
ParameterCollector()
Definition: ParameterCollector.cc:14
gen::ParameterCollector::end
const_iterator end() const
Definition: ParameterCollector.h:76
gen::ParameterCollector::contents_
std::map< std::string, std::vector< std::string > > contents_
Definition: ParameterCollector.h:85
trackingPlots.other
other
Definition: trackingPlots.py:1460
gen
Definition: PythiaDecays.h:13
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
gen::ParameterCollector::begin
const_iterator begin() const
Definition: ParameterCollector.cc:83
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
gen::ParameterCollector::~ParameterCollector
~ParameterCollector()
Definition: ParameterCollector.cc:23
gen::ParameterCollector::const_iterator::equal
bool equal(const const_iterator &other) const
Definition: ParameterCollector.h:54
gen::ParameterCollector::const_iterator::next
void next()
Definition: ParameterCollector.cc:44
gen::ParameterCollector::const_iterator::special_
bool special_
Definition: ParameterCollector.h:62
gen::ParameterCollector::const_iterator::IterPair
std::pair< std::vector< std::string >::const_iterator, std::vector< std::string >::const_iterator > IterPair
Definition: ParameterCollector.h:58
ParameterSet.h
mps_splice.line
line
Definition: mps_splice.py:76
gen::ParameterCollector::const_iterator::iterator_core_access
friend class boost::iterator_core_access
Definition: ParameterCollector.h:50
gen::ParameterCollector::resolve
static std::string resolve(const std::string &line)
Definition: ParameterCollector.cc:117
gen::ParameterCollector::const_iterator::dump_
std::ostream * dump_
Definition: ParameterCollector.h:61
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
gen::ParameterCollector::const_iterator::cache_
std::string cache_
Definition: ParameterCollector.h:64
gen::ParameterCollector::const_iterator
friend class const_iterator
Definition: ParameterCollector.h:83