Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

algomaker.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *                                                                             *
00003  *   Copyright (C) 2003  Erik Sjolund,  (<html>Erik Sj&ouml;lund</html>)       *
00004  *                       Center for Genomics and Bioinformatics,               *
00005  *                       Karolinska Institutet,                                *
00006  *                       Stockholm,                                            *
00007  *                       Sweden                                                *
00008  *                                                                             *
00009  *  Author: Erik Sjolund                                                       *
00010  *  Email: erik.sjolund@adivo.se                                               *
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>//T = Algo type, str_ = Algo name
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 //Generic definition
00069 template <class AlgoType, const char * algoName, bool algoShouldPopup>//T = Algo type, str_ = Algo name
00070 const AlgoMakerTP< AlgoType , algoName, algoShouldPopup > AlgoMakerTP< AlgoType , algoName, algoShouldPopup >::registerThis;
00071 
00072 #endif

Generated on Fri Mar 17 17:44:24 2006 for trapper by  doxygen 1.4.4