libpqxx  7.0.7
notification.hxx
1 /* Definition of the pqxx::notification_receiver functor interface.
2  *
3  * pqxx::notification_receiver handles incoming notifications.
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/notification 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_NOTIFICATION
14 #define PQXX_H_NOTIFICATION
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
18 
19 #include <string>
20 
21 #include "pqxx/types.hxx"
22 
23 
24 namespace pqxx
25 {
27 
55 class PQXX_LIBEXPORT PQXX_NOVTABLE notification_receiver
56 {
57 public:
59 
63  notification_receiver(connection &c, std::string_view channel);
65  notification_receiver &operator=(notification_receiver const &) = delete;
66  virtual ~notification_receiver();
67 
69  [[nodiscard]] std::string const &channel() const { return m_channel; }
70 
72 
79  virtual void operator()(std::string const &payload, int backend_pid) = 0;
80 
81 protected:
82  connection &conn() const noexcept { return m_conn; }
83 
84 private:
85  connection &m_conn;
86  std::string m_channel;
87 };
88 } // namespace pqxx
89 
90 #include "pqxx/internal/compiler-internal-post.hxx"
91 #endif
connection & conn() const noexcept
Definition: notification.hxx:82
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
Connection to a database.
Definition: connection.hxx:135
std::string const & channel() const
The channel that this receiver listens on.
Definition: notification.hxx:69
Definition: notification.hxx:55