openModeller
Version 1.4.0
|
00001 00029 #ifndef _OCCURRENCES_FACTORY_HH_ 00030 #define _OCCURRENCES_FACTORY_HH_ 00031 00032 #include <openmodeller/occ_io/OccurrencesReader.hh> 00033 #include <openmodeller/occ_io/DelimitedTextOccurrences.hh> 00034 #include <openmodeller/occ_io/SerializedXmlOccurrences.hh> 00035 00036 #ifdef TERRALIB_FOUND 00037 #include <openmodeller/occ_io/TeOccurrences.hh> 00038 #endif 00039 00040 #ifdef CURL_FOUND 00041 #include <openmodeller/occ_io/TapirOccurrences.hh> 00042 #include <openmodeller/occ_io/GbifOccurrences.hh> 00043 #endif 00044 00045 #include <string> 00046 using std::string; 00047 00048 #include <map> 00049 using std::map; 00050 00051 #include <vector> 00052 using std::vector; 00053 00057 class dllexp OccurrencesFactory 00058 { 00059 00060 private: 00061 00062 // Function pointer to builder function. 00063 typedef OccurrencesReader * (*CreateOccurrencesReaderCallback)( const char * source, const char * coordSystem ); 00064 00065 // Map of OccurrencesReader and identifiers. 00066 typedef map<string, CreateOccurrencesReaderCallback> DriversMap; 00067 00068 public: 00069 00072 static OccurrencesFactory& instance(); 00073 00079 bool registerDriver( const string& driverId, CreateOccurrencesReaderCallback builder ); 00080 00085 bool unregisterDriver( const string& driverId ); 00086 00090 vector<string> getRegisteredDrivers(); 00091 00097 OccurrencesReader * create( const char * source, const char * coordSystem ); 00098 00099 private: 00100 00101 // Indicates if the factory was initiated (i.e., drivers were registered). 00102 static bool _initiated; 00103 00104 // Map of OccurrencesReader and identifiers. 00105 DriversMap _drivers; 00106 00107 // No constructor allowed (singleton pattern). 00108 OccurrencesFactory(){}; 00109 00110 // No copy allowed. 00111 OccurrencesFactory( const OccurrencesFactory& ); 00112 00113 // No copy allowed. 00114 OccurrencesFactory& operator=( const OccurrencesFactory& ); 00115 00116 // No destructor allowed. 00117 ~OccurrencesFactory(){}; 00118 }; 00119 00120 #endif