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

robusttransaction.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/robusttransaction.h
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::robusttransaction class.
00008  *   pqxx::robusttransaction is a slower but safer transaction class
00009  *
00010  * Copyright (c) 2002-2003, Jeroen T. Vermeulen <jtv@xs4all.nl>
00011  *
00012  * See COPYING for copyright license.  If you did not receive a file called
00013  * COPYING with this source code, please notify the distributor of this mistake,
00014  * or contact the author.
00015  *
00016  *-------------------------------------------------------------------------
00017  */
00018 #ifndef PQXX_ROBUSTTRANSACTION_H
00019 #define PQXX_ROBUSTTRANSACTION_H
00020 
00021 
00022 #include "pqxx/dbtransaction.h"
00023 
00024 
00025 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00026  */
00027 
00028 
00029 namespace pqxx
00030 {
00031 
00032 class PQXX_LIBEXPORT basic_robusttransaction : public dbtransaction
00033 {
00034 public:
00036   typedef isolation_traits<read_committed> isolation_tag;
00037 
00038   virtual ~basic_robusttransaction() =0;                                //[t16]
00039 
00040 protected:
00042 
00047   explicit basic_robusttransaction(connection_base &C,
00048                                    const PGSTD::string &IsolationLevel,
00049                                    const PGSTD::string &Name);          //[t16]
00050 
00051 private:
00052   typedef unsigned long IDType;
00053   IDType m_ID;
00054   PGSTD::string m_LogTable;
00055 
00056   virtual void DoBegin();                                               //[t18]
00057   virtual result DoExec(const char[]);                                  //[t18]
00058   virtual void DoCommit();                                              //[t16]
00059   virtual void DoAbort();                                               //[t18]
00060 
00061   void CreateLogTable();
00062   void CreateTransactionRecord();
00063   void DeleteTransactionRecord(IDType ID) throw ();
00064   bool CheckTransactionRecord(IDType ID);
00065 };
00066 
00068 template<> inline PGSTD::string Classname(const basic_robusttransaction *) 
00069 { 
00070   return "basic_robusttransaction"; 
00071 }
00072 
00073 
00074 
00076 
00143 template<isolation_level ISOLATIONLEVEL=read_committed>
00144 class PQXX_LIBEXPORT robusttransaction : public basic_robusttransaction
00145 {
00146 public:
00147   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00148 
00149   explicit robusttransaction(connection_base &C,
00150                              const PGSTD::string &TName=PGSTD::string()) :
00151     basic_robusttransaction(C, isolation_tag::name(), TName)
00152         { Begin(); }
00153 
00154   virtual ~robusttransaction() { End(); }
00155 };
00156 
00157 
00159 template<isolation_level ISOLATIONLEVEL> 
00160 inline PGSTD::string Classname(const robusttransaction<ISOLATIONLEVEL> *) 
00161 { 
00162   return "robusttransaction<" + 
00163     isolation_traits<ISOLATIONLEVEL>::name() +
00164     ">";
00165 }
00166 
00167 
00169 typedef robusttransaction<read_committed> RobustTransaction;
00170 
00171 }
00172 
00173 
00174 #endif
00175 

Generated on Sat Jun 7 00:49:34 2003 for libpqxx by doxygen1.3-rc3