oracleRefType.hh

00001 //********************************************************************
00002 //*** ResourcePool/oracle/oracleRefType.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: oracleRefType.hh,v 1.24 2009-03-14 15:12:25 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_ORACLE_ORACLEREFTYPE_HH
00025 #define RESOURCEPOOL_ORACLE_ORACLEREFTYPE_HH
00026 
00027 #include <memory>
00028 #include <string>
00029 
00030 #ifndef OCI_ORACLE
00031 #include <oci.h>
00032 #endif
00033 
00034 #include "mm/gc_ptr.hh"
00035 
00036 namespace fatalmind {
00037 namespace oracle {
00038 
00039 class oracleRefType: public usg_cnt_t<DefaultThreadedModel> {
00040     public:
00041         oracleRefType();
00042         virtual void* ptr() const = 0;
00043         virtual sb4   capacity() const = 0;
00044         virtual ub2   type() const = 0;
00045         virtual void  start() = 0;
00046         virtual void  done(const ub4 size, void* ptr) = 0;
00047         virtual ~oracleRefType();
00048         dvoid* indptr() const;
00049         
00050         sb2 _ind;
00051 };
00052 
00053 template<typename T>
00054 class oracleRefTypeImpl: public oracleRefType {
00055     public:
00056         oracleRefTypeImpl(T& val, bool& isnull);
00057         virtual ~oracleRefTypeImpl();
00058 
00059         virtual void* ptr() const;
00060         virtual sb4   capacity() const;
00061         virtual ub2   type() const;
00062         virtual void  start();
00063         virtual void  done(const ub4 size, void* ptr);
00064         virtual T&    getValue();
00065         
00066     private:
00067         T& val;
00068         bool& isnull;
00069 };
00070 
00071 template<>
00072 class oracleRefTypeImpl<std::string>: public oracleRefType {
00073     public:
00074         oracleRefTypeImpl(std::string& val, bool& isnull);
00075         virtual ~oracleRefTypeImpl();
00076 
00077         virtual void* ptr() const;
00078         virtual sb4   capacity() const;
00079         virtual ub2   type() const;
00080         virtual void  start();
00081         virtual void  done(const ub4 size, void* ptr);
00082     private:
00083         std::string& val;
00084         bool& isnull;
00085         sb4 _cap;
00086         bool needsreset;
00087 };
00088 
00089 
00090 } // namespace oracle
00091 } // namespace fatalmind
00092 #endif

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