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-2005, 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/libcompiler.h" 00020 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 00033 class PQXX_LIBEXPORT basic_transaction : public dbtransaction 00034 { 00035 protected: 00036 explicit basic_transaction(connection_base &C, 00037 const PGSTD::string &IsolationLevel, 00038 const PGSTD::string &TName); //[t1] 00039 00040 private: 00041 virtual void do_begin(); //[t1] 00042 virtual void do_commit(); //[t1] 00043 virtual void do_abort(); //[t13] 00044 }; 00045 00046 00048 00076 template<isolation_level ISOLATIONLEVEL=read_committed> 00077 class transaction : public basic_transaction 00078 { 00079 public: 00080 typedef isolation_traits<ISOLATIONLEVEL> isolation_tag; 00081 00083 00088 explicit transaction(connection_base &C, const PGSTD::string &TName): //[t1] 00089 basic_transaction(C, isolation_tag::name(), TName) 00090 { Begin(); } 00091 00092 explicit transaction(connection_base &C) : //[t1] 00093 basic_transaction(C, isolation_tag::name(), PGSTD::string()) 00094 { Begin(); } 00095 00096 virtual ~transaction() throw () 00097 { 00098 #ifdef PQXX_QUIET_DESTRUCTORS 00099 internal::disable_noticer Quiet(conn()); 00100 #endif 00101 End(); 00102 } 00103 00104 protected: 00105 virtual const char *classname() const throw () { return "transaction"; } 00106 }; 00107 00108 00110 typedef transaction<> work; 00111 00112 } 00113 00114