SQLFactoryInterface.hh

00001 //********************************************************************
00002 //*** ResourcePool/SQL/SQLFactoryInterface.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: SQLFactoryInterface.hh,v 1.14 2009-05-11 14:54:36 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_SQLFACTORYINTERFACE_HH
00025 #define RESOURCEPOOL_SQL_SQLFACTORYINTERFACE_HH
00026 
00027 #include "util/Clone.hh"
00028 #include "mm/gc_ptr.hh"
00029 #include "ResourcePool/ResourcePoolEventObserver.hh"
00030 
00031 namespace fatalmind {
00032 namespace SQL {
00033 
00049 class SQLFactoryInterface: public Clone {
00050     public:
00051         SQLFactoryInterface(ResourcePoolEventObserver& e) 
00052         :observer(e.clone<ResourcePoolEventObserver>())
00053         {
00054             Event.PREPARE = observer->registerEvent("PREPARE");
00055             Event.EXECUTE = observer->registerEvent("EXECUTE");
00056             Event.EXECUTE_FAIL = observer->registerEvent("EXECUTE_FAIL");
00057             Event.FETCH   = observer->registerEvent("FETCH");
00058             Event.COMMIT  = observer->registerEvent("COMMIT");
00059             Event.ROLLBACK= observer->registerEvent("ROLLBACK");
00060 
00061             getEventObserver()->setDefaultEventMask();
00062         };
00063 
00064         gc_ptr<ResourcePoolEventObserver> getEventObserver() const {
00065             return observer;
00066         }
00067 
00068         // TODO: would be nice to have it private/protected?
00069         enum databaseType_t { UNDEF, OCI, MYSQL, MYSQLTX };
00070     private:
00071         struct Events {
00072             ResourcePoolEventObserver::event_t PREPARE;
00073             ResourcePoolEventObserver::event_t EXECUTE;
00074             ResourcePoolEventObserver::event_t EXECUTE_FAIL;
00075             ResourcePoolEventObserver::event_t FETCH;
00076             ResourcePoolEventObserver::event_t COMMIT;
00077             ResourcePoolEventObserver::event_t ROLLBACK;
00078         } Event;
00079 
00080         const gc_ptr<ResourcePoolEventObserver> observer;
00081 };
00082 
00083 } // namespace SQL
00084 } // namespace fatalmind
00085 
00086 #endif

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