rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
ProjectionHandler.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ProjectionHandler_HH
3 #define RIVET_ProjectionHandler_HH
4 
5 #include "Rivet/Config/RivetCommon.hh"
6 #include "Rivet/Projection.fhh"
7 
8 namespace Rivet {
9 
10 
12  typedef std::shared_ptr<const Projection> ProjHandle;
13 
14  // Forward declaration.
15  class ProjectionApplier;
16 
40  public:
41 
43  friend class ProjectionApplier;
44 
46  typedef set<ProjHandle> ProjHandles;
47 
50  typedef map<string, ProjHandle> NamedProjs;
51 
53  enum ProjDepth { SHALLOW, DEEP };
54 
55 
56  private:
57 
60  typedef map<const ProjectionApplier*, NamedProjs> NamedProjsMap;
61 
64  NamedProjsMap _namedprojs;
65 
68  ProjHandles _projs;
69 
70 
71  private:
72 
74 
75 
77  ~ProjectionHandler() = default;
78 
80  ProjectionHandler& operator = (const ProjectionHandler&) = delete;
81 
83  ProjectionHandler(const ProjectionHandler&) = delete;
84 
86  ProjectionHandler() = default;
87 
89 
90 
91  public:
92 
95  static ProjectionHandler _instance;
96  return _instance;
97  }
98 
99 
100  public:
101 
103 
104  const Projection& registerProjection(const ProjectionApplier& parent,
106  const Projection& proj,
107  const string& name);
109 
110 
111  private:
112 
114 
115 
118  ProjHandle _getEquiv(const Projection& proj) const;
119 
121  unique_ptr<Projection> _clone(const Projection& proj);
122 
124  const Projection& _register(const ProjectionApplier& parent,
125  ProjHandle proj,
126  const string& name);
127 
129  string _getStatus() const;
130 
132  bool _checkDuplicate(const ProjectionApplier& parent,
133  const Projection& proj,
134  const string& name) const;
135 
137 
138 
139  public:
140 
142 
143 
145  bool hasProjection(const ProjectionApplier& parent, const string& name) const;
146 
151  const Projection& getProjection(const ProjectionApplier& parent,
152  const string& name) const;
153 
159  set<const Projection*> getChildProjections(const ProjectionApplier& parent,
160  ProjDepth depth=SHALLOW) const;
162 
163 
164  private:
165 
167  void removeProjectionApplier(ProjectionApplier& parent);
168 
169 
170  private:
171 
172  // /// Get map of named projections belonging to @a parent.
173  // /// Throws an exception if @a parent has not got any registered projections.
174  // const NamedProjs& namedProjs(const ProjectionApplier* parent) const {
175  // NamedProjsMap::const_iterator nps = _namedprojs.find(parent);
176  // if (nps == _namedprojs.end()) {
177  // stringstream ss;
178  // ss << "No NamedProjs registered for parent " << parent;
179  // throw Error(ss.str());
180  // }
181  // return *nps;
182  // }
183 
184 
185  };
186 
187 
188 }
189 
190 #endif
Definition: ALICE_2010_I880049.cc:13
static ProjectionHandler & getInstance()
Singleton creation function.
Definition: ProjectionHandler.hh:94
std::shared_ptr< const Projection > ProjHandle
Typedef for Projection (smart) pointer.
Definition: ProjectionHandler.hh:12
set< const Projection * > getChildProjections(const ProjectionApplier &parent, ProjDepth depth=SHALLOW) const
Definition: ProjectionHandler.cc:209
const Projection & registerProjection(const ProjectionApplier &parent, const Projection &proj, const string &name)
Attach and retrieve a projection as a reference.
Definition: ProjectionHandler.cc:20
ProjDepth
Enum to specify depth of projection search.
Definition: ProjectionHandler.hh:53
set< ProjHandle > ProjHandles
Typedef for a vector of Projection pointers.
Definition: ProjectionHandler.hh:46
The projection handler is a central repository for projections to be used in a Rivet analysis run...
Definition: ProjectionHandler.hh:39
const Projection & getProjection(const ProjectionApplier &parent, const string &name) const
Definition: ProjectionHandler.cc:241
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:21
map< string, ProjHandle > NamedProjs
Typedef for the structure used to contain named projections for a particular containing Analysis or P...
Definition: ProjectionHandler.hh:50
bool hasProjection(const ProjectionApplier &parent, const string &name) const
Check if there is a name projection registered by parent.
Definition: ProjectionHandler.cc:232
Base class for all Rivet projections.
Definition: Projection.hh:29