ProjectionHandler.hh
// -*- C++ -*-
#ifndef RIVET_ProjectionHandler_HH
#define RIVET_ProjectionHandler_HH
#include "Rivet/Rivet.hh"
#include "Rivet/RivetBoost.hh"
#include "Rivet/Tools/Logging.fhh"
#include "Rivet/Projection.fhh"
namespace Rivet {
typedef shared_ptr<const Projection> ProjHandle;
// Forward declaration.
class ProjectionApplier;
class ProjectionHandler {
public:
friend class ProjectionApplier;
typedef set<ProjHandle> ProjHandles;
typedef map<const string, ProjHandle> NamedProjs;
enum ProjDepth { SHALLOW, DEEP };
private:
typedef map<const ProjectionApplier*, NamedProjs> NamedProjsMap;
NamedProjsMap _namedprojs;
ProjHandles _projs;
private:
~ProjectionHandler();
ProjectionHandler& operator=(const ProjectionHandler&);
ProjectionHandler(const ProjectionHandler&);
ProjectionHandler() { }
static ProjectionHandler* _instance;
public:
static ProjectionHandler& getInstance(); // {
// static ProjectionHandler _instance;
// return _instance;
// }
public:
const Projection& registerProjection(const ProjectionApplier& parent,
const Projection& proj,
const string& name);
const Projection* registerProjection(const ProjectionApplier& parent,
const Projection* proj,
const string& name);
private:
const Projection* _getEquiv(const Projection& proj) const;
const Projection* _clone(const Projection& proj);
const Projection* _register(const ProjectionApplier& parent,
const Projection& proj,
const string& name);
string _getStatus() const;
bool _checkDuplicate(const ProjectionApplier& parent,
const Projection& proj,
const string& name) const;
public:
const Projection& getProjection(const ProjectionApplier& parent,
const string& name) const;
set<const Projection*> getChildProjections(const ProjectionApplier& parent,
ProjDepth depth=SHALLOW) const;
void clear();
private:
void removeProjectionApplier(ProjectionApplier& parent);
private:
Log& getLog() const;
// /// Get map of named projections belonging to @a parent.
// /// Throws an exception if @a parent has not got any registered projections.
// const NamedProjs& namedProjs(const ProjectionApplier* parent) const {
// NamedProjsMap::const_iterator nps = _namedprojs.find(parent);
// if (nps == _namedprojs.end()) {
// stringstream ss;
// ss << "No NamedProjs registered for parent " << parent;
// throw Error(ss.str());
// }
// return *nps;
// }
};
}
#endif
Rivet
Definition: MC_JetAnalysis.hh:9
Rivet::ProjectionHandler::ProjectionApplier
friend class ProjectionApplier
ProjectionApplier's destructor needs to trigger cleaning up the proj handler repo.
Definition: ProjectionHandler.hh:45
Rivet::ProjectionHandler::registerProjection
const Projection & registerProjection(const ProjectionApplier &parent, const Projection &proj, const string &name)
Attach and retrieve a projection as a reference.
Definition: ProjectionHandler.cc:47
Rivet::ProjectionHandler::ProjDepth
ProjDepth
Enum to specify depth of projection search.
Definition: ProjectionHandler.hh:55
Rivet::ProjectionHandler::NamedProjs
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
Rivet::ProjectionHandler::ProjHandles
set< ProjHandle > ProjHandles
Typedef for a vector of Projection pointers.
Definition: ProjectionHandler.hh:48
Rivet::ProjectionHandler
The projection handler is a central repository for projections to be used in a Rivet analysis run...
Definition: ProjectionHandler.hh:41
Rivet::ProjectionHandler::clear
void clear()
Definition: ProjectionHandler.cc:31
Rivet::ProjectionHandler::getProjection
const Projection & getProjection(const ProjectionApplier &parent, const string &name) const
Definition: ProjectionHandler.cc:258
Rivet::ProjectionApplier
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:18
Rivet::ProjHandle
shared_ptr< const Projection > ProjHandle
Typedef for Projection (smart) pointer.
Definition: ProjectionHandler.hh:14
Rivet::ProjectionHandler::getChildProjections
set< const Projection * > getChildProjections(const ProjectionApplier &parent, ProjDepth depth=SHALLOW) const
Definition: ProjectionHandler.cc:233
Rivet::ProjectionHandler::getInstance
static ProjectionHandler & getInstance()
Singleton creation function.
Definition: ProjectionHandler.cc:14