00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RESOURCEPOOL_SQL_RESOURCEPOOL_HH
00025 #define RESOURCEPOOL_SQL_RESOURCEPOOL_HH
00026
00027 #include "ResourcePool/ResourcePoolType.hh"
00028 #include "ResourcePool/IgnoreExceptionCommand.hh"
00029 #include "ResourcePool/SQL/Factory.hh"
00030 #include "ResourcePool/SQL/Resource.hh"
00031
00032 #include "ResourcePool/SQL/RTSQLExecute.hh"
00033 #include "ResourcePool/SQL/RTSQLSelect.hh"
00034 #include "ResourcePool/SQL/RTSQLTransaction.hh"
00035 #include "ResourcePool/SQL/RTSQLBatch.hh"
00036
00037 namespace fatalmind {
00043 namespace SQL {
00044
00045 template<class TM>
00046 struct Commands;
00047
00051 template<class TM>
00052 class ResourceType
00053 : public fatalmind::PoolType<SQLFactory<TM>
00054 , DummySQLResource<TM>
00055 , SQLResource<TM>
00056 , Commands<TM>
00057 , TM>
00058 {
00059 };
00060
00061 template<class TM>
00062 struct Commands {
00063 Commands(const SQLFactory<TM>& f)
00064 : type_(f.getDatabaseType())
00065 {
00066 };
00067
00068 CommandParameters<TM> SQL(const std::string& sql) {
00069 CommandParameters<TM> cp(type_, sql);
00070 return cp;
00071 }
00072
00073 typedef Command<ResourceType<TM> > Base;
00074 typedef RTSQLExecute<TM> SQLExecute;
00075 typedef RTSQLSelect<TM> SQLSelect;
00076 typedef RTSQLSelectRow<TM> SQLSelectRow;
00077 typedef RTSQLBatch<TM> SQLBatch;
00078 typedef RTSQLTransaction<TM> Transaction;
00079 typedef fatalmind::IgnoreExceptionCommand<RTSQLExecute<TM> > IgnoreException;
00080 private:
00081 const typename SQLFactory<TM>::databaseType_t type_;
00082 };
00083
00084 }
00085
00086 namespace ResourceType {
00087
00088 typedef SQL::ResourceType<DefaultThreadedModel > SQL;
00089 typedef SQL::ResourceType<SingleThreadedModel<> > SQLST;
00090 typedef SQL::ResourceType<MultiThreadedModel<> > SQLMT;
00091
00092 }
00093 }
00094
00095 #endif