00001 /****************************************************************************** 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 00008 00009 #ifndef databaseDriverFactory_H_ 00010 #define databaseDriverFactory_H_ 00011 00012 #include "vlDatabase.h" 00013 00014 #include <map> 00015 #include <vlutil/vlMutex.h> 00016 #include <vector> 00017 00018 class DtString; 00019 00020 class DtDatabaseDriver; 00021 00023 class DT_DLL_VLDB DtDatabaseDriverFactory 00024 { 00025 public: 00027 ~DtDatabaseDriverFactory(); 00028 00030 static std::vector<DtString> getInstalledDrivers(); 00031 00034 static const DtDatabaseDriver* getDriver(const DtString& driverName); 00035 00040 static void registerDriver(DtDatabaseDriver* driver); 00041 00045 static void replaceDriver(DtDatabaseDriver* driver); 00046 00048 static std::vector<DtString> getDataSources(const DtString& driver); 00049 00050 private: 00052 DtDatabaseDriverFactory(const DtDatabaseDriverFactory&); 00053 DtDatabaseDriverFactory& operator=(const DtDatabaseDriverFactory&); 00055 00056 00057 protected: 00058 00060 static DtDatabaseDriverFactory* acquire(); 00061 00063 static void release(); 00064 00066 explicit DtDatabaseDriverFactory(); 00067 00069 DtDatabaseDriver* lookupDriverByName(const DtString& driverName); 00070 00073 bool registerDriver(DtDatabaseDriver* driver,bool allowReplace); 00074 00075 static DtMutex theFactoryMutex; 00076 static DtDatabaseDriverFactory theDriverFactory; 00077 00078 typedef std::map<DtString,DtDatabaseDriver*> DriverMap; 00079 DriverMap myDriverMap; 00080 }; 00081 00082 #endif