libpqxx  7.6.1
transaction_focus.hxx
1 
9 #ifndef PQXX_H_TRANSACTION_FOCUS
10 #define PQXX_H_TRANSACTION_FOCUS
11 
12 #include "pqxx/compiler-public.hxx"
13 #include "pqxx/internal/compiler-internal-pre.hxx"
14 
15 #include "pqxx/util.hxx"
16 
17 namespace pqxx
18 {
20 
27 class PQXX_LIBEXPORT transaction_focus
28 {
29 public:
31  transaction_base &t, std::string_view cname, std::string_view oname) :
32  m_trans{t}, m_classname{cname}, m_name{oname}
33  {}
34 
36  transaction_base &t, std::string_view cname, std::string &&oname) :
37  m_trans{t}, m_classname{cname}, m_name{std::move(oname)}
38  {}
39 
40  transaction_focus(transaction_base &t, std::string_view cname) :
41  m_trans{t}, m_classname{cname}
42  {}
43 
44  transaction_focus() = delete;
47 
49  [[nodiscard]] std::string_view classname() const noexcept
50  {
51  return m_classname;
52  }
53 
55  [[nodiscard]] std::string_view name() const noexcept { return m_name; }
56 
57  [[nodiscard]] std::string description() const
58  {
59  return pqxx::internal::describe_object(m_classname, m_name);
60  }
61 
63 
67 
69 
73 
74 protected:
75  void register_me();
76  void unregister_me() noexcept;
77  void reg_pending_error(std::string const &) noexcept;
78  bool registered() const noexcept { return m_registered; }
79 
81 
82 private:
83  bool m_registered = false;
84  std::string_view m_classname;
85  std::string m_name;
86 };
87 } // namespace pqxx
88 
89 #include "pqxx/internal/compiler-internal-post.hxx"
90 #endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
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:70
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:76
Base class for things that monopolise a transaction's attention.
Definition: transaction_focus.hxx:28
std::string description() const
Definition: transaction_focus.hxx:57
transaction_base & m_trans
Definition: transaction_focus.hxx:80
std::string_view classname() const noexcept
Class name, for human consumption.
Definition: transaction_focus.hxx:49
transaction_focus & operator=(transaction_focus &&)=delete
Can't move a transaction_focus.
transaction_focus(transaction_base &t, std::string_view cname)
Definition: transaction_focus.hxx:40
transaction_focus(transaction_base &t, std::string_view cname, std::string &&oname)
Definition: transaction_focus.hxx:35
transaction_focus(transaction_focus const &)=delete
std::string_view name() const noexcept
Name for this object, if the caller passed one; empty string otherwise.
Definition: transaction_focus.hxx:55
transaction_focus(transaction_base &t, std::string_view cname, std::string_view oname)
Definition: transaction_focus.hxx:30
transaction_focus & operator=(transaction_focus const &)=delete
transaction_focus(transaction_focus &&)=delete
Can't move a transaction_focus.