CP3-llbb Framework
HLTService.h
1 #pragma once
2 
3 #include <boost/regex.hpp>
4 #include <map>
5 
6 namespace tinyxml2 {
7  class XMLElement;
8 }
9 
10 template<typename T>
11 class Range {
12  public:
13  Range(T from, T to):
14  m_from(from), m_to(to) {}
15 
16  T from() const {
17  return m_from;
18  }
19 
20  T to() const {
21  return m_to;
22  }
23 
24  bool in(T value) const {
25  return value >= m_from && value <= m_to;
26  }
27 
28  bool operator<(const Range<T>& other) const {
29  return m_from < other.m_from;
30  }
31 
32  template<typename U>
33  friend std::ostream& operator<<(std::ostream& stream, const Range<U>& range);
34 
35  private:
36  T m_from;
37  T m_to;
38 };
39 
40 template<typename T>
41 std::ostream& operator<<(std::ostream& stream, const Range<T>& range)
42 {
43  stream << "[" << range.from() << ", " << range.to() << "]";
44 
45  return stream;
46 }
47 
48 class HLTService {
49  public:
50 
51  using PathName = boost::regex;
52  using PathVector = std::vector<PathName>;
53 
54  HLTService(const std::string& filename):
55  m_cachedRange(nullptr), m_cachedVector(nullptr) {
56  parse(filename);
57  }
58 
59  void print();
60  const PathVector& getPaths(uint64_t run);
61 
62  private:
63  std::map<Range<uint64_t>, PathVector> m_paths;
64 
65  const Range<uint64_t>* m_cachedRange;
66  const PathVector* m_cachedVector;
67 
68  bool parse(const std::string& filename);
69  bool parseRunsElement(const tinyxml2::XMLElement* runs);
70 };
Definition: HLTService.h:48
Definition: HLTService.h:11
Definition: tinyxml2.h:1154