Rivet
1.8.0
|
00001 // -*- C++ -*- 00002 #ifndef RIVET_ProjectionHandler_HH 00003 #define RIVET_ProjectionHandler_HH 00004 00005 #include "Rivet/Rivet.hh" 00006 #include "Rivet/RivetBoost.hh" 00007 #include "Rivet/Tools/Logging.fhh" 00008 #include "Rivet/Projection.fhh" 00009 00010 namespace Rivet { 00011 00012 00014 typedef shared_ptr<const Projection> ProjHandle; 00015 00016 // Forward declaration. 00017 class ProjectionApplier; 00018 00041 class ProjectionHandler { 00042 public: 00043 00045 friend class ProjectionApplier; 00046 00048 typedef set<ProjHandle> ProjHandles; 00049 00052 typedef map<const string, ProjHandle> NamedProjs; 00053 00055 enum ProjDepth { SHALLOW, DEEP }; 00056 00057 00058 private: 00059 00062 typedef map<const ProjectionApplier*, NamedProjs> NamedProjsMap; 00063 00066 NamedProjsMap _namedprojs; 00067 00070 ProjHandles _projs; 00071 00072 00073 private: 00074 00076 00077 00079 ~ProjectionHandler(); 00080 00082 ProjectionHandler& operator=(const ProjectionHandler&); 00083 00085 ProjectionHandler(const ProjectionHandler&); 00086 00088 ProjectionHandler() { } 00089 00091 static ProjectionHandler* _instance; 00092 00094 00095 00096 public: 00097 00099 static ProjectionHandler& getInstance(); // { 00102 // static ProjectionHandler _instance; 00103 // return _instance; 00104 // } 00105 00106 00107 public: 00108 00110 00111 00112 const Projection& registerProjection(const ProjectionApplier& parent, 00113 const Projection& proj, 00114 const string& name); 00115 00117 const Projection* registerProjection(const ProjectionApplier& parent, 00118 const Projection* proj, 00119 const string& name); 00121 00122 00123 private: 00124 00126 00127 00130 const Projection* _getEquiv(const Projection& proj) const; 00131 00133 const Projection* _clone(const Projection& proj); 00134 00136 const Projection* _register(const ProjectionApplier& parent, 00137 const Projection& proj, 00138 const string& name); 00139 00141 string _getStatus() const; 00142 00144 bool _checkDuplicate(const ProjectionApplier& parent, 00145 const Projection& proj, 00146 const string& name) const; 00147 00149 00150 00151 public: 00152 00154 00155 00160 const Projection& getProjection(const ProjectionApplier& parent, 00161 const string& name) const; 00162 00168 set<const Projection*> getChildProjections(const ProjectionApplier& parent, 00169 ProjDepth depth=SHALLOW) const; 00171 00172 00175 void clear(); 00176 00177 00178 private: 00179 00181 void removeProjectionApplier(ProjectionApplier& parent); 00182 00183 00184 private: 00185 00187 Log& getLog() const; 00188 00189 00190 // /// Get map of named projections belonging to @a parent. 00191 // /// Throws an exception if @a parent has not got any registered projections. 00192 // const NamedProjs& namedProjs(const ProjectionApplier* parent) const { 00193 // NamedProjsMap::const_iterator nps = _namedprojs.find(parent); 00194 // if (nps == _namedprojs.end()) { 00195 // stringstream ss; 00196 // ss << "No NamedProjs registered for parent " << parent; 00197 // throw Error(ss.str()); 00198 // } 00199 // return *nps; 00200 // } 00201 00202 00203 }; 00204 00205 00206 } 00207 00208 #endif