transaction.hxx

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/transaction.hxx
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::transaction class.
00008  *   pqxx::transaction represents a standard database transaction
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/transaction instead.
00010  *
00011  * Copyright (c) 2001-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_TRANSACTION
00020 #define PQXX_H_TRANSACTION
00021 
00022 #include "pqxx/compiler-public.hxx"
00023 #include "pqxx/compiler-internal-pre.hxx"
00024 
00025 #include "pqxx/dbtransaction"
00026 
00027 
00028 
00029 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00030  */
00031 
00032 
00033 namespace pqxx
00034 {
00035 
00040 
00041 class PQXX_LIBEXPORT basic_transaction : public dbtransaction
00042 {
00043 protected:
00044   basic_transaction(                                                    //[t1]
00045         connection_base &C,
00046         const PGSTD::string &IsolationLevel,
00047         readwrite_policy);
00048 
00049 private:
00050   virtual void do_commit();                                             //[t1]
00051 };
00052 
00053 
00055 
00083 template<
00084         isolation_level ISOLATIONLEVEL=read_committed,
00085         readwrite_policy READWRITE=read_write>
00086 class transaction : public basic_transaction
00087 {
00088 public:
00089   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00090 
00092 
00097   explicit transaction(connection_base &C, const PGSTD::string &TName): //[t1]
00098     namedclass(fullname("transaction", isolation_tag::name()), TName),
00099     basic_transaction(C, isolation_tag::name(), READWRITE)
00100         { Begin(); }
00101 
00102   explicit transaction(connection_base &C) :                            //[t1]
00103     namedclass(fullname("transaction", isolation_tag::name())),
00104     basic_transaction(C, isolation_tag::name(), READWRITE)
00105         { Begin(); }
00106 
00107   virtual ~transaction() throw ()
00108   {
00109 #ifdef PQXX_QUIET_DESTRUCTORS
00110     disable_noticer Quiet(conn());
00111 #endif
00112     End();
00113   }
00114 };
00115 
00116 
00118 typedef transaction<> work;
00119 
00121 typedef transaction<read_committed, read_only> read_transaction;
00122 
00124 
00125 }
00126 
00127 
00128 #include "pqxx/compiler-internal-post.hxx"
00129 
00130 #endif
00131 

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