Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

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-2003, 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 #include "pqxx/dbtransaction"
00020 
00021 
00022 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00023  */
00024 
00025 
00026 namespace pqxx
00027 {
00028 
00029 class PQXX_LIBEXPORT basic_robusttransaction : public dbtransaction
00030 {
00031 public:
00033   typedef isolation_traits<read_committed> isolation_tag;
00034 
00035   virtual ~basic_robusttransaction() =0;                                //[t16]
00036 
00037 protected:
00039 
00044   explicit basic_robusttransaction(connection_base &C,
00045                                    const PGSTD::string &IsolationLevel,
00046                                    const PGSTD::string &Name);          //[t16]
00047 
00048 private:
00049   typedef unsigned long IDType;
00050   IDType m_ID;
00051   PGSTD::string m_LogTable;
00052 
00053   virtual void do_begin();                                              //[t18]
00054   virtual result do_exec(const char[]);                                 //[t18]
00055   virtual void do_commit();                                             //[t16]
00056   virtual void do_abort();                                              //[t18]
00057 
00058   void CreateLogTable();
00059   void CreateTransactionRecord();
00060   void DeleteTransactionRecord(IDType ID) throw ();
00061   bool CheckTransactionRecord(IDType ID);
00062 };
00063 
00065 template<> inline PGSTD::string Classname(const basic_robusttransaction *) 
00066 { 
00067   return "basic_robusttransaction"; 
00068 }
00069 
00070 
00071 
00073 
00140 template<isolation_level ISOLATIONLEVEL=read_committed>
00141 class robusttransaction : public basic_robusttransaction
00142 {
00143 public:
00144   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00145 
00146   explicit robusttransaction(connection_base &C,
00147                              const PGSTD::string &TName=PGSTD::string()) :
00148     basic_robusttransaction(C, isolation_tag::name(), TName)
00149         { Begin(); }
00150 
00151   virtual ~robusttransaction() { End(); }
00152 };
00153 
00154 
00156 template<isolation_level ISOLATIONLEVEL> 
00157 inline PGSTD::string Classname(const robusttransaction<ISOLATIONLEVEL> *) 
00158 { 
00159   return "robusttransaction<" + 
00160     isolation_traits<ISOLATIONLEVEL>::name() +
00161     ">";
00162 }
00163 
00164 }
00165 
00166 

Generated on Sun Sep 21 01:09:23 2003 for libpqxx by doxygen 1.3.2