libpqxx  7.3.0
nontransaction.hxx
1 /* Definition of the pqxx::nontransaction class.
2  *
3  * pqxx::nontransaction provides nontransactional database access
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/nontransaction instead.
6  *
7  * Copyright (c) 2000-2020, Jeroen T. Vermeulen.
8  *
9  * See COPYING for copyright license. If you did not receive a file called
10  * COPYING with this source code, please notify the distributor of this
11  * mistake, or contact the author.
12  */
13 #ifndef PQXX_H_NONTRANSACTION
14 #define PQXX_H_NONTRANSACTION
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
18 
19 #include "pqxx/connection.hxx"
20 #include "pqxx/result.hxx"
21 #include "pqxx/transaction.hxx"
22 
23 namespace pqxx
24 {
26 
52 class PQXX_LIBEXPORT nontransaction final : public transaction_base
53 {
54 public:
56 
61  nontransaction(connection &c, std::string_view tname) :
62  transaction_base{c, tname, std::shared_ptr<std::string>{}}
63  {
64  register_transaction();
65  }
66 
68 
74  {
75  register_transaction();
76  }
77 
78  virtual ~nontransaction() override { close(); }
79 
80 private:
81  virtual void do_commit() override {}
82 };
83 } // namespace pqxx
84 
85 #include "pqxx/internal/compiler-internal-post.hxx"
86 #endif
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:71
Simple "transaction" class offering no transactional integrity.
Definition: nontransaction.hxx:52
virtual ~nontransaction() override
Definition: nontransaction.hxx:78
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
nontransaction(connection &c, std::string_view tname)
Constructor.
Definition: nontransaction.hxx:61
Connection to a database.
Definition: connection.hxx:163
nontransaction(connection &c)
Constructor.
Definition: nontransaction.hxx:73