transaction.hxx
#ifndef PQXX_H_TRANSACTION
#define PQXX_H_TRANSACTION
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include "pqxx/dbtransaction.hxx"
/* Methods tested in eg. self-test program test1 are marked with "//[t01]"
*/
namespace pqxx
{
namespace internal
{
class PQXX_LIBEXPORT basic_transaction : public dbtransaction
{
protected:
basic_transaction( //[t01]
connection_base &C,
const std::string &IsolationLevel,
readwrite_policy);
private:
virtual void do_commit() override; //[t01]
};
} // namespace internal
template<
isolation_level ISOLATIONLEVEL=read_committed,
readwrite_policy READWRITE=read_write>
class transaction : public internal::basic_transaction
{
public:
using isolation_tag = isolation_traits<ISOLATIONLEVEL>;
explicit transaction(connection_base &C, const std::string &TName): //[t01]
namedclass{fullname("transaction", isolation_tag::name()), TName},
internal::basic_transaction(C, isolation_tag::name(), READWRITE)
{ Begin(); }
explicit transaction(connection_base &C) : //[t01]
transaction(C, "") {}
virtual ~transaction() noexcept
{ End(); }
};
using work = transaction<>;
using read_transaction = transaction<read_committed, read_only>;
}
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::transaction_base::Begin
void Begin()
Begin transaction (to be called by implementing class)
Definition: transaction_base.cxx:386
pqxx::read_committed
@ read_committed
Definition: isolation.hxx:59
pqxx::transaction_base::End
void End() noexcept
End transaction. To be called by implementing class' destructor.
Definition: transaction_base.cxx:408
pqxx::internal::namedclass::namedclass
namedclass(const std::string &Classname)
Definition: util.hxx:236
pqxx::internal::basic_transaction::basic_transaction
basic_transaction(connection_base &C, const std::string &IsolationLevel, readwrite_policy)
Definition: transaction.cxx:20
pqxx::transaction::transaction
transaction(connection_base &C, const std::string &TName)
Create a transaction.
Definition: transaction.hxx:93
pqxx::internal::basic_transaction
Helper base class for the transaction class template.
Definition: transaction.hxx:31
pqxx::readwrite_policy
readwrite_policy
Definition: dbtransaction.hxx:24
pqxx::dbtransaction::fullname
static std::string fullname(const std::string &ttype, const std::string &isolation)
Definition: dbtransaction.cxx:95
pqxx::transaction::transaction
transaction(connection_base &C)
Definition: transaction.hxx:98
pqxx::internal::namedclass
Helper base class: object descriptions for error messages and such.
Definition: util.hxx:233
pqxx::isolation_traits::name
static constexpr const char * name() noexcept
pqxx::connection_base
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:139
pqxx::transaction::~transaction
virtual ~transaction() noexcept
Definition: transaction.hxx:101
pqxx::dbtransaction
Abstract base class responsible for bracketing a backend transaction.
Definition: dbtransaction.hxx:62
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
pqxx::transaction
Standard back-end transaction, templatized on isolation level.
Definition: transaction.hxx:82
pqxx::read_write
@ read_write
Definition: dbtransaction.hxx:27
pqxx::isolation_level
isolation_level
Transaction isolation levels.
Definition: isolation.hxx:56
pqxx::isolation_traits
Traits class to describe an isolation level; primarly for libpqxx's own use.
Definition: isolation.hxx:65