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-2006, 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/compiler-public.hxx" 00020 #include "pqxx/compiler-internal-pre.hxx" 00021 00022 #include "pqxx/dbtransaction" 00023 00024 00025 00026 /* Methods tested in eg. self-test program test1 are marked with "//[t1]" 00027 */ 00028 00029 00030 namespace pqxx 00031 { 00032 00037 00038 class PQXX_LIBEXPORT basic_transaction : public dbtransaction 00039 { 00040 protected: 00041 basic_transaction(connection_base &C, 00042 const PGSTD::string &IsolationLevel); //[t1] 00043 00044 private: 00045 virtual void do_commit(); //[t1] 00046 }; 00047 00048 00050 00078 template<isolation_level ISOLATIONLEVEL=read_committed> 00079 class transaction : public basic_transaction 00080 { 00081 public: 00082 typedef isolation_traits<ISOLATIONLEVEL> isolation_tag; 00083 00085 00090 explicit transaction(connection_base &C, const PGSTD::string &TName): //[t1] 00091 namedclass(fullname("transaction",isolation_tag::name()), TName), 00092 basic_transaction(C, isolation_tag::name()) 00093 { Begin(); } 00094 00095 explicit transaction(connection_base &C) : //[t1] 00096 namedclass(fullname("transaction",isolation_tag::name())), 00097 basic_transaction(C, isolation_tag::name()) 00098 { Begin(); } 00099 00100 virtual ~transaction() throw () 00101 { 00102 #ifdef PQXX_QUIET_DESTRUCTORS 00103 internal::disable_noticer Quiet(conn()); 00104 #endif 00105 End(); 00106 } 00107 }; 00108 00109 00111 typedef transaction<> work; 00112 00114 00115 } 00116 00117 00118 #include "pqxx/compiler-internal-post.hxx"