libpqxx 7.7.0
transaction_focus.hxx
1
9#ifndef PQXX_H_TRANSACTION_FOCUS
10#define PQXX_H_TRANSACTION_FOCUS
11
12#include "pqxx/util.hxx"
13
14namespace pqxx
15{
17
24class PQXX_LIBEXPORT transaction_focus
25{
26public:
28 transaction_base &t, std::string_view cname, std::string_view oname) :
29 m_trans{t}, m_classname{cname}, m_name{oname}
30 {}
31
33 transaction_base &t, std::string_view cname, std::string &&oname) :
34 m_trans{t}, m_classname{cname}, m_name{std::move(oname)}
35 {}
36
37 transaction_focus(transaction_base &t, std::string_view cname) :
38 m_trans{t}, m_classname{cname}
39 {}
40
44
46 [[nodiscard]] std::string_view classname() const noexcept
47 {
48 return m_classname;
49 }
50
52 [[nodiscard]] std::string_view name() const &noexcept { return m_name; }
53
54 [[nodiscard]] std::string description() const
55 {
56 return pqxx::internal::describe_object(m_classname, m_name);
57 }
58
60
64
66
70
71protected:
72 void register_me();
73 void unregister_me() noexcept;
74 void reg_pending_error(std::string const &) noexcept;
75 bool registered() const noexcept { return m_registered; }
76
78
79private:
80 bool m_registered = false;
81 std::string_view m_classname;
82 std::string m_name;
83};
84} // namespace pqxx
85#endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
std::string describe_object(std::string_view class_name, std::string_view name)
Describe an object for humans, based on class name and optional name.
Definition: util.cxx:72
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:73
Base class for things that monopolise a transaction's attention.
Definition: transaction_focus.hxx:25
std::string description() const
Definition: transaction_focus.hxx:54
transaction_base & m_trans
Definition: transaction_focus.hxx:77
std::string_view classname() const noexcept
Class name, for human consumption.
Definition: transaction_focus.hxx:46
transaction_focus(transaction_base &t, std::string_view cname)
Definition: transaction_focus.hxx:37
std::string_view name() const &noexcept
Name for this object, if the caller passed one; empty string otherwise.
Definition: transaction_focus.hxx:52
transaction_focus(transaction_base &t, std::string_view cname, std::string &&oname)
Definition: transaction_focus.hxx:32
transaction_focus(transaction_focus const &)=delete
transaction_focus & operator=(transaction_focus &&)=delete
Can't move a transaction_focus.
transaction_focus(transaction_base &t, std::string_view cname, std::string_view oname)
Definition: transaction_focus.hxx:27
transaction_focus & operator=(transaction_focus const &)=delete
transaction_focus(transaction_focus &&)=delete
Can't move a transaction_focus.