AddCutFunctor.hh

Go to the documentation of this file.
00001 
00007 #ifndef ADDCUTFUNCTOR_h
00008 #define ADDCUTFUNCTOR_h
00009 
00010 #include <string>
00011 #include <map>
00012 #include <iostream>
00013 
00014 class BaseModule;
00015 class ProcessingCut;
00016 
00017 //useful macro
00019 #define REGISTER_CUT(cut) AddCutFunctor::CutRegistrar<cut> ___registrar___cut;
00020 
00025 class AddCutFunctor{
00026   BaseModule* _parent;
00027 public:
00028   AddCutFunctor(BaseModule* parent) : _parent(parent) {}
00029   ~AddCutFunctor(){}
00030   
00031   static std::string GetFunctionName(){ return "add_cut"; }
00032   
00034   std::istream& operator()(std::istream& in);
00036   std::ostream& operator()(std::ostream& out);
00037   
00041   class VCut{
00042   public:
00043     VCut(){}
00044     virtual ~VCut(){}
00045     virtual ProcessingCut* GetCut()=0;
00046   };
00047   
00051   typedef std::map<std::string,VCut*> cuts_list;
00052   
00054   static cuts_list* GetListOfCuts(){
00055     static cuts_list _cuts;
00056     return &_cuts;
00057   }
00058   
00060   template<class T> class CutRegistrar : public VCut{
00061   public:
00062     CutRegistrar(){ 
00063       AddCutFunctor::GetListOfCuts()->
00064         insert(std::make_pair(T::GetCutName(), this));
00065     }
00066     ~CutRegistrar(){}
00067     ProcessingCut* GetCut(){ return new T;}
00068   };
00069   
00070   
00071 };
00072 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1