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

generalmaker.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 
00015 #ifndef GENERALMAKER_H
00016 #define GENERALMAKER_H
00017 
00018 #include <qstringlist.h>
00019 
00020 #include <map>
00021 #include <iostream>
00022 #include <string>
00023 #include <list>
00024 
00025 class Dbt;
00026 class GeneralData;
00027 
00028 
00029 /** \brief This is a factory class for GeneralData objects
00030   *
00031   */
00032 
00033 class GeneralMaker
00034 {
00035 public:
00036     virtual ~GeneralMaker()
00037     {}
00038     static GeneralData * newData( const std::string& );
00039     static std::list<std::string> listRegistered();
00040 protected:
00041     GeneralMaker( )
00042     {}
00043     virtual GeneralData* makeData() = 0;
00044     typedef std::map< std::string , GeneralMaker * > MakerMap;
00045     static MakerMap & registry();
00046 private:
00047 };
00048 
00049 template <class Data, const char * str_>
00050 class GeneralMakerTP : public GeneralMaker
00051 {
00052 protected:
00053     GeneralMakerTP() : GeneralMaker(  )
00054     {
00055         Data d;
00056         std::string str = d.uniqueName();
00057         GeneralMaker::registry().insert( make_pair( str, this ) );
00058 //         std::cerr<<"Hello?????"<<std::endl;
00059     }
00060     GeneralData* makeData()
00061     {
00062         return new Data();
00063     }
00064     static const GeneralMakerTP<Data, str_> registerThis;
00065 };
00066 
00067 //Generic definition
00068 template <class Data, const char * str_>
00069 const GeneralMakerTP<Data, str_> GeneralMakerTP<Data, str_>::registerThis;
00070 
00071 #endif

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