Factory.hh

00001 //********************************************************************
00002 //*** ResourcePool/SQL/Factory.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: Factory.hh,v 1.12 2009-03-02 14:16:44 mws Exp $
00005 //********************************************************************
00006 /*
00007 This file is part of ResourcePool.
00008 
00009 ResourcePool is free software; you can redistribute it
00010 and/or modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2 of
00012 the License, or (at your option) any later version.
00013 
00014 ResourcePool is distributed in the hope that it will be
00015 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00016 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with ResourcePool; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022 02111-1307  USA */
00023 
00024 #ifndef RESOURCEPOOL_SQL_FACTORY_HH
00025 #define RESOURCEPOOL_SQL_FACTORY_HH
00026 
00027 #include "mm/gc_ptr.hh"
00028 #include "Thread/Lock.hh"
00029 
00030 namespace fatalmind {
00031 namespace SQL {
00032 
00033 template<class TM = DefaultThreadedModel>
00034 class SQLFactory;
00035 
00036 }
00037 }
00038 
00039 #include "ResourcePool/SQL/Resource.hh"
00040 #include "ResourcePool/SQL/SQLFactoryInterface.hh"
00041 #include "ResourcePool/ResourcePoolStreamLogger.hh"
00042 
00043 namespace fatalmind {
00044 namespace SQL {
00045 
00046 template<class TM> class SQLFactory_Impl;
00047 
00048 template<class TM> 
00049 class SQLFactory : public SQLFactoryInterface {
00050         typedef SQLFactoryInterface super;
00051     public:
00055         SQLFactory(const std::string& logon, ResourcePoolEventObserver& e = ResourcePoolStreamLogger::defaultLogger);
00056         SQLFactory(const SQLFactory&);
00057         ~SQLFactory() throw();
00058 
00059         DummySQLResource<TM>* create_resource() const;
00060 
00061         virtual databaseType_t getDatabaseType() const;
00062         
00063         // the real observer is not the one in the super class,
00064         // it's the one in the real factory
00065         gc_ptr<ResourcePoolEventObserver> getEventObserver() const {
00066             return _realFactory->getEventObserver();
00067         }
00068 
00069     protected:
00070         virtual Clone* DoClone() const;
00071 
00072     private:
00073         gc_ptr<SQLFactory_Impl<TM> > _realFactory;
00074         databaseType_t resourceTypeCode;
00075 };
00076 
00077 } // namespace SQL
00078 } // namespace fatalmind
00079 
00080 #endif

Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3