notification.hxx
/* Definition of the pqxx::notification_receiver functor interface.
*
* pqxx::notification_receiver handles incoming notifications.
*
* DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/notification instead.
*
* Copyright (c) 2000-2023, Jeroen T. Vermeulen.
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this
* mistake, or contact the author.
*/
#ifndef PQXX_H_NOTIFICATION
#define PQXX_H_NOTIFICATION
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif
#include <string>
#include "pqxx/types.hxx"
namespace pqxx
{
class PQXX_LIBEXPORT PQXX_NOVTABLE notification_receiver
{
public:
notification_receiver(connection &c, std::string_view channel);
notification_receiver(notification_receiver const &) = delete;
notification_receiver &operator=(notification_receiver const &) = delete;
virtual ~notification_receiver();
[[nodiscard]] std::string const &channel() const & { return m_channel; }
// TODO: Change API to take payload as zview instead of string ref.
virtual void operator()(std::string const &payload, int backend_pid) = 0;
protected:
connection &conn() const noexcept { return m_conn; }
private:
connection &m_conn;
std::string m_channel;
};
} // namespace pqxx
#endif
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition array.hxx:33
pqxx::connection
Connection to a database.
Definition connection.hxx:253
pqxx::notification_receiver
Definition notification.hxx:57
pqxx::notification_receiver::notification_receiver
notification_receiver(notification_receiver const &)=delete
Register the receiver with a connection.
pqxx::notification_receiver::channel
std::string const & channel() const &
The channel that this receiver listens on.
Definition notification.hxx:73
pqxx::notification_receiver::operator()
virtual void operator()(std::string const &payload, int backend_pid)=0
Overridable: action to invoke when notification arrives.
pqxx::notification_receiver::conn
connection & conn() const noexcept
Definition notification.hxx:87
pqxx::notification_receiver::operator=
notification_receiver & operator=(notification_receiver const &)=delete
Register the receiver with a connection.