robusttransaction.hxx

00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/robusttransaction.hxx
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::robusttransaction class.
00008  *   pqxx::robusttransaction is a slower but safer transaction class
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/robusttransaction instead.
00010  *
00011  * Copyright (c) 2002-2008, Jeroen T. Vermeulen <jtv@xs4all.nl>
00012  *
00013  * See COPYING for copyright license.  If you did not receive a file called
00014  * COPYING with this source code, please notify the distributor of this mistake,
00015  * or contact the author.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #ifndef PQXX_H_ROBUSTTRANSACTION
00020 #define PQXX_H_ROBUSTTRANSACTION
00021 
00022 #include "pqxx/compiler-public.hxx"
00023 #include "pqxx/compiler-internal-pre.hxx"
00024 
00025 #include "pqxx/dbtransaction"
00026 
00027 
00028 /* Methods tested in eg. self-test program test001 are marked with "//[t1]"
00029  */
00030 
00031 
00032 namespace pqxx
00033 {
00034 
00041 class PQXX_LIBEXPORT PQXX_NOVTABLE basic_robusttransaction :
00042   public dbtransaction
00043 {
00044 public:
00046   typedef isolation_traits<read_committed> isolation_tag;
00047 
00048   virtual ~basic_robusttransaction() =0;                                //[t16]
00049 
00050 protected:
00051   basic_robusttransaction(connection_base &C,
00052         const PGSTD::string &IsolationLevel);                           //[t16]
00053 
00054 private:
00055   typedef unsigned long IDType;
00056   IDType m_ID;
00057   PGSTD::string m_LogTable;
00058   int m_backendpid;
00059 
00060   virtual void do_begin();                                              //[t18]
00061   virtual void do_commit();                                             //[t16]
00062   virtual void do_abort();                                              //[t18]
00063 
00064   void PQXX_PRIVATE CreateLogTable();
00065   void PQXX_PRIVATE CreateTransactionRecord();
00066   void PQXX_PRIVATE DeleteTransactionRecord(IDType ID) throw ();
00067   bool PQXX_PRIVATE CheckTransactionRecord(IDType ID);
00068 };
00069 
00070 
00071 
00073 
00139 template<isolation_level ISOLATIONLEVEL=read_committed>
00140 class robusttransaction : public basic_robusttransaction
00141 {
00142 public:
00143   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00144 
00146 
00150   explicit robusttransaction(connection_base &C,
00151       const PGSTD::string &Name=PGSTD::string()) :
00152     namedclass(fullname("robusttransaction",isolation_tag::name()), Name),
00153     basic_robusttransaction(C, isolation_tag::name())
00154         { Begin(); }
00155 
00156   virtual ~robusttransaction() throw ()
00157   {
00158 #ifdef PQXX_QUIET_DESTRUCTORS
00159     disable_noticer Quiet(conn());
00160 #endif
00161     End();
00162   }
00163 };
00164 
00169 } // namespace pqxx
00170 
00171 
00172 #include "pqxx/compiler-internal-post.hxx"
00173 
00174 #endif
00175 

Generated on Sat Aug 15 00:16:49 2009 for libpqxx by  doxygen 1.5.8