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(connection_base &C, 00045 const PGSTD::string &IsolationLevel); //[t1] 00046 00047 private: 00048 virtual void do_commit(); //[t1] 00049 }; 00050 00051 00053 00081 template<isolation_level ISOLATIONLEVEL=read_committed> 00082 class transaction : public basic_transaction 00083 { 00084 public: 00085 typedef isolation_traits<ISOLATIONLEVEL> isolation_tag; 00086 00088 00093 explicit transaction(connection_base &C, const PGSTD::string &TName): //[t1] 00094 namedclass(fullname("transaction", isolation_tag::name()), TName), 00095 basic_transaction(C, isolation_tag::name()) 00096 { Begin(); } 00097 00098 explicit transaction(connection_base &C) : //[t1] 00099 namedclass(fullname("transaction", isolation_tag::name())), 00100 basic_transaction(C, isolation_tag::name()) 00101 { Begin(); } 00102 00103 virtual ~transaction() throw () 00104 { 00105 #ifdef PQXX_QUIET_DESTRUCTORS 00106 disable_noticer Quiet(conn()); 00107 #endif 00108 End(); 00109 } 00110 }; 00111 00112 00114 typedef transaction<> work; 00115 00117 00118 } 00119 00120 00121 #include "pqxx/compiler-internal-post.hxx" 00122 00123 #endif 00124