libpqxx
The C++ client library for PostgreSQL
notification.hxx
Go to the documentation of this file.
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-2026, 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_NOTIFICATION_HXX
14 #define PQXX_NOTIFICATION_HXX
15 
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18 #endif
19 
20 #include <string>
21 
22 #include "pqxx/types.hxx"
23 
24 
25 namespace pqxx
26 {
27 // This code is deprecated.
28 // LCOV_EXCL_START
29 
31 
60 {
61 public:
63 
67  [[deprecated("Use pqxx::connection::listen() instead.")]]
69  connection &cx, std::string_view channel, sl loc = sl::current());
70 
73 
75  virtual ~notification_receiver();
76 
79 
81  [[nodiscard]] std::string const &channel() const & { return m_channel; }
82 
84 
91  virtual void operator()(std::string const &payload, int backend_pid) = 0;
92 
93 protected:
94  [[nodiscard]] connection &conn() const noexcept { return m_conn; }
95 
96 private:
97  connection &m_conn;
98  std::string m_channel;
99 };
100 // LCOV_EXCL_STOP
101 } // namespace pqxx
102 #endif
Connection to a database.
Definition: connection.hxx:273
Definition: notification.hxx:60
std::string const & channel() const &
The channel that this receiver listens on.
Definition: notification.hxx:81
notification_receiver & operator=(notification_receiver &&)=delete
notification_receiver(notification_receiver const &)=delete
notification_receiver & operator=(notification_receiver const &)=delete
notification_receiver(notification_receiver &&)=delete
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:94
#define PQXX_LIBEXPORT
Definition: header-pre.hxx:206
#define PQXX_NOVTABLE
Definition: header-pre.hxx:221
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38