00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ALGOMAKER_H
00015 #define ALGOMAKER_H
00016
00017 #include <map>
00018 #include <string>
00019 #include <list>
00020 #include <db_cxx.h>
00021 #include <set>
00022 class Algo;
00023 class TrapperDoc;
00024 class AlgoParam;
00025
00026 class AlgoMaker
00027 {
00028 public:
00029 virtual ~AlgoMaker()
00030 {}
00031 static Algo * newAlgo( const std::string& AlgoType, TrapperDoc * doc, std::set< db_recno_t >& recnoList, AlgoParam* param = 0);
00032 static std::list<std::string> algosRegistered();
00033 protected:
00034 AlgoMaker( )
00035 {}
00036 virtual Algo* makeAlgo( TrapperDoc * doc, std::set< db_recno_t >& recnoList, AlgoParam* param ) = 0;
00037 virtual bool algoIsPopup() = 0;
00038 typedef std::map< std::string , AlgoMaker * > MakerMap;
00039 static MakerMap & registry();
00040 private:
00041
00042
00043 };
00044
00045 template <class AlgoType, const char * algoName, bool algoShouldPopup>
00046 class AlgoMakerTP : public AlgoMaker
00047 {
00048 protected:
00049 AlgoMakerTP( ) : AlgoMaker( )
00050 {
00051 AlgoMaker::registry().insert( std::make_pair( algoName, this ) );
00052 }
00053 ~AlgoMakerTP()
00054 {}
00055 Algo* makeAlgo( TrapperDoc * doc, std::set< db_recno_t >& recnoList, AlgoParam* param )
00056 {
00057 return new AlgoType( doc, recnoList, param );
00058 }
00059 bool algoIsPopup()
00060 {
00061 return algoShouldPopup;
00062 }
00063
00064 static const AlgoMakerTP< AlgoType , algoName, algoShouldPopup > registerThis;
00065 };
00066
00067
00068
00069 template <class AlgoType, const char * algoName, bool algoShouldPopup>
00070 const AlgoMakerTP< AlgoType , algoName, algoShouldPopup > AlgoMakerTP< AlgoType , algoName, algoShouldPopup >::registerThis;
00071
00072 #endif