robusttransaction.hxx

Go to the documentation of this file.
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-2009, 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(
00052         connection_base &C,
00053         const PGSTD::string &IsolationLevel,
00054         const PGSTD::string &table_name=PGSTD::string());               //[t16]
00055 
00056 private:
00057   typedef unsigned long IDType;
00058   IDType m_record_id;
00059   PGSTD::string m_xid;
00060   PGSTD::string m_LogTable;
00061   PGSTD::string m_sequence;
00062   int m_backendpid;
00063 
00064   virtual void do_begin();                                              //[t18]
00065   virtual void do_commit();                                             //[t16]
00066   virtual void do_abort();                                              //[t18]
00067 
00068   void PQXX_PRIVATE CreateLogTable();
00069   void PQXX_PRIVATE CreateTransactionRecord();
00070   PGSTD::string PQXX_PRIVATE sql_delete() const;
00071   void PQXX_PRIVATE DeleteTransactionRecord() throw ();
00072   bool PQXX_PRIVATE CheckTransactionRecord();
00073 };
00074 
00075 
00076 
00078 
00144 template<isolation_level ISOLATIONLEVEL=read_committed>
00145 class robusttransaction : public basic_robusttransaction
00146 {
00147 public:
00148   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00149 
00151 
00155   explicit robusttransaction(connection_base &C,
00156       const PGSTD::string &Name=PGSTD::string()) :
00157     namedclass(fullname("robusttransaction",isolation_tag::name()), Name),
00158     basic_robusttransaction(C, isolation_tag::name())
00159         { Begin(); }
00160 
00161   virtual ~robusttransaction() throw ()
00162   {
00163 #ifdef PQXX_QUIET_DESTRUCTORS
00164     disable_noticer Quiet(conn());
00165 #endif
00166     End();
00167   }
00168 };
00169 
00174 } // namespace pqxx
00175 
00176 
00177 #include "pqxx/compiler-internal-post.hxx"
00178 
00179 #endif
00180 

Generated on Mon Feb 15 18:22:41 2010 for libpqxx by  doxygen 1.5.5