libpqxx
The C++ client library for PostgreSQL
callgate.hxx
Go to the documentation of this file.
1 #ifndef PQXX_INTERNAL_CALLGATE_HXX
2 #define PQXX_INTERNAL_CALLGATE_HXX
3 
4 /*
5 Here's what a typical gate class definition looks like:
6 
7 ```cxx
8 #include <pqxx/internal/callgate.hxx>
9 
10 namespace pqxx::internal::gate
11 {
12 class PQXX_PRIVATE @gateclass@ final : callgate<@host@>
13 {
14  friend class @client@;
15 
16  explicit constexpr @gateclass@(reference x) noexcept : super(x) {}
17 
18  // Methods here. Use home() to access the host-class object.
19 };
20 } // namespace pqxx::internal::gate
21 ```
22 */
23 
24 namespace pqxx::internal
25 {
27 
54 template<typename HOME> class PQXX_PRIVATE callgate
55 {
56 protected:
60  using reference = HOME &;
61 
62  explicit constexpr callgate(reference x) noexcept : m_home(x) {}
63 
65  [[nodiscard]] constexpr reference home() const noexcept { return m_home; }
66 
67 private:
68  // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
69  reference m_home;
70 };
71 } // namespace pqxx::internal
72 
73 #endif
Base class for call gates.
Definition: callgate.hxx:55
constexpr callgate(reference x) noexcept
Definition: callgate.hxx:62
HOME & reference
A reference to the host class. Helps keep constructors easy.
Definition: callgate.hxx:60
constexpr reference home() const noexcept
The home object. The gate class has full "private" access.
Definition: callgate.hxx:65
#define PQXX_PRIVATE
Definition: header-pre.hxx:207
Private namespace for libpqxx's internal use; do not access.
Definition: connection.cxx:333