Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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 void do_commit();                                             //[t16]
00055   virtual void do_abort();                                              //[t18]
00056 
00057   void CreateLogTable();
00058   void CreateTransactionRecord();
00059   void DeleteTransactionRecord(IDType ID) throw ();
00060   bool CheckTransactionRecord(IDType ID);
00061 };
00062 
00064 template<> inline PGSTD::string Classname(const basic_robusttransaction *) 
00065 { 
00066   return "basic_robusttransaction"; 
00067 }
00068 
00069 
00070 
00072 
00139 template<isolation_level ISOLATIONLEVEL=read_committed>
00140 class robusttransaction : public basic_robusttransaction
00141 {
00142 public:
00143   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00144 
00145   explicit robusttransaction(connection_base &C,
00146                              const PGSTD::string &TName=PGSTD::string()) :
00147     basic_robusttransaction(C, isolation_tag::name(), TName)
00148         { Begin(); }
00149 
00150   virtual ~robusttransaction() { End(); }
00151 };
00152 
00153 
00155 template<isolation_level ISOLATIONLEVEL> 
00156 inline PGSTD::string Classname(const robusttransaction<ISOLATIONLEVEL> *) 
00157 { 
00158   return "robusttransaction<" + 
00159     isolation_traits<ISOLATIONLEVEL>::name() +
00160     ">";
00161 }
00162 
00163 }
00164 
00165 

Generated on Thu Dec 25 07:22:37 2003 for libpqxx by doxygen 1.3.4