libpqxx 7.7.0
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-2022, 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 <string>
17
18#include "pqxx/types.hxx"
19
20
21namespace pqxx
22{
24
52class PQXX_LIBEXPORT PQXX_NOVTABLE notification_receiver
53{
54public:
56
60 notification_receiver(connection &c, std::string_view channel);
66 virtual ~notification_receiver();
67
69 [[nodiscard]] std::string const &channel() const & { return m_channel; }
70
71 // TODO: Change API to take payload as zview instead of string ref.
73
80 virtual void operator()(std::string const &payload, int backend_pid) = 0;
81
82protected:
83 connection &conn() const noexcept { return m_conn; }
84
85private:
86 connection &m_conn;
87 std::string m_channel;
88};
89} // namespace pqxx
90#endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
Connection to a database.
Definition: connection.hxx:181
Definition: notification.hxx:53
notification_receiver(notification_receiver const &)=delete
Register the receiver with a connection.
std::string const & channel() const &
The channel that this receiver listens on.
Definition: notification.hxx:69
virtual void operator()(std::string const &payload, int backend_pid)=0
Overridable: action to invoke when notification arrives.
connection & conn() const noexcept
Definition: notification.hxx:83
notification_receiver & operator=(notification_receiver const &)=delete
Register the receiver with a connection.