Rivet  1.8.3
ProjectionHandler.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ProjectionHandler_HH
3 #define RIVET_ProjectionHandler_HH
4 
5 #include "Rivet/Rivet.hh"
6 #include "Rivet/RivetBoost.hh"
7 #include "Rivet/Tools/Logging.fhh"
8 #include "Rivet/Projection.fhh"
9 
10 namespace Rivet {
11 
12 
14  typedef shared_ptr<const Projection> ProjHandle;
15 
16  // Forward declaration.
17  class ProjectionApplier;
18 
42  public:
43 
45  friend class ProjectionApplier;
46 
48  typedef set<ProjHandle> ProjHandles;
49 
52  typedef map<const string, ProjHandle> NamedProjs;
53 
55  enum ProjDepth { SHALLOW, DEEP };
56 
57 
58  private:
59 
62  typedef map<const ProjectionApplier*, NamedProjs> NamedProjsMap;
63 
66  NamedProjsMap _namedprojs;
67 
70  ProjHandles _projs;
71 
72 
73  private:
74 
76 
77 
80 
82  ProjectionHandler& operator=(const ProjectionHandler&);
83 
86 
88  ProjectionHandler() { }
89 
91  static ProjectionHandler* _instance;
92 
94 
95 
96  public:
97 
99  static ProjectionHandler& getInstance(); // {
102  // static ProjectionHandler _instance;
103  // return _instance;
104  // }
105 
106 
107  public:
108 
110 
111  const Projection& registerProjection(const ProjectionApplier& parent,
113  const Projection& proj,
114  const string& name);
115 
117  const Projection* registerProjection(const ProjectionApplier& parent,
118  const Projection* proj,
119  const string& name);
121 
122 
123  private:
124 
126 
127 
130  const Projection* _getEquiv(const Projection& proj) const;
131 
133  const Projection* _clone(const Projection& proj);
134 
136  const Projection* _register(const ProjectionApplier& parent,
137  const Projection& proj,
138  const string& name);
139 
141  string _getStatus() const;
142 
144  bool _checkDuplicate(const ProjectionApplier& parent,
145  const Projection& proj,
146  const string& name) const;
147 
149 
150 
151  public:
152 
154 
155 
160  const Projection& getProjection(const ProjectionApplier& parent,
161  const string& name) const;
162 
168  set<const Projection*> getChildProjections(const ProjectionApplier& parent,
169  ProjDepth depth=SHALLOW) const;
171 
172 
175  void clear();
176 
177 
178  private:
179 
181  void removeProjectionApplier(ProjectionApplier& parent);
182 
183 
184  private:
185 
187  Log& getLog() const;
188 
189 
190  // /// Get map of named projections belonging to @a parent.
191  // /// Throws an exception if @a parent has not got any registered projections.
192  // const NamedProjs& namedProjs(const ProjectionApplier* parent) const {
193  // NamedProjsMap::const_iterator nps = _namedprojs.find(parent);
194  // if (nps == _namedprojs.end()) {
195  // stringstream ss;
196  // ss << "No NamedProjs registered for parent " << parent;
197  // throw Error(ss.str());
198  // }
199  // return *nps;
200  // }
201 
202 
203  };
204 
205 
206 }
207 
208 #endif
Definition: MC_JetAnalysis.hh:9
friend class ProjectionApplier
ProjectionApplier's destructor needs to trigger cleaning up the proj handler repo.
Definition: ProjectionHandler.hh:45
const Projection & registerProjection(const ProjectionApplier &parent, const Projection &proj, const string &name)
Attach and retrieve a projection as a reference.
Definition: ProjectionHandler.cc:47
ProjDepth
Enum to specify depth of projection search.
Definition: ProjectionHandler.hh:55
map< const string, ProjHandle > NamedProjs
Typedef for the structure used to contain named projections for a particular containing Analysis or P...
Definition: ProjectionHandler.hh:52
set< ProjHandle > ProjHandles
Typedef for a vector of Projection pointers.
Definition: ProjectionHandler.hh:48
The projection handler is a central repository for projections to be used in a Rivet analysis run...
Definition: ProjectionHandler.hh:41
void clear()
Definition: ProjectionHandler.cc:31
const Projection & getProjection(const ProjectionApplier &parent, const string &name) const
Definition: ProjectionHandler.cc:258
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:18
shared_ptr< const Projection > ProjHandle
Typedef for Projection (smart) pointer.
Definition: ProjectionHandler.hh:14
set< const Projection * > getChildProjections(const ProjectionApplier &parent, ProjDepth depth=SHALLOW) const
Definition: ProjectionHandler.cc:233
static ProjectionHandler & getInstance()
Singleton creation function.
Definition: ProjectionHandler.cc:14