transaction.hxx

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-2015, 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 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00029  */
00030 
00031 
00032 namespace pqxx
00033 {
00034 
00039 
00040 class PQXX_LIBEXPORT basic_transaction : public dbtransaction
00041 {
00042 protected:
00043   basic_transaction(                                                    //[t1]
00044         connection_base &C,
00045         const std::string &IsolationLevel,
00046         readwrite_policy);
00047 
00048 private:
00049   virtual void do_commit() PQXX_OVERRIDE;                               //[t1]
00050 };
00051 
00052 
00054 
00082 template<
00083         isolation_level ISOLATIONLEVEL=read_committed,
00084         readwrite_policy READWRITE=read_write>
00085 class transaction : public basic_transaction
00086 {
00087 public:
00088   typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
00089 
00091 
00096   explicit transaction(connection_base &C, const std::string &TName):   //[t1]
00097     namedclass(fullname("transaction", isolation_tag::name()), TName),
00098     basic_transaction(C, isolation_tag::name(), READWRITE)
00099         { Begin(); }
00100 
00101   explicit transaction(connection_base &C) :                            //[t1]
00102     namedclass(fullname("transaction", isolation_tag::name())),
00103     basic_transaction(C, isolation_tag::name(), READWRITE)
00104         { Begin(); }
00105 
00106   virtual ~transaction() PQXX_NOEXCEPT                                { End(); }
00107 };
00108 
00109 
00111 typedef transaction<> work;
00112 
00114 typedef transaction<read_committed, read_only> read_transaction;
00115 
00117 
00118 }
00119 
00120 
00121 #include "pqxx/compiler-internal-post.hxx"
00122 
00123 #endif
00124 

Generated on 17 Mar 2017 for libpqxx by  doxygen 1.6.1