libpqxx  4.0.1
notify-listen.hxx
1 /*-------------------------------------------------------------------------
2  *
3  * FILE
4  * pqxx/notify-listen.hxx
5  *
6  * DESCRIPTION
7  * Definition of the obsolete pqxx::notify_listener functor interface.
8  * Predecessor to notification_receiver. Deprecated. Do not use.
9  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/notify-listen instead.
10  *
11  * Copyright (c) 2001-2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
12  *
13  * See COPYING for copyright license. If you did not receive a file called
14  * COPYING with this source code, please notify the distributor of this mistake,
15  * or contact the author.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef PQXX_H_NOTIFY_LISTEN
20 #define PQXX_H_NOTIFY_LISTEN
21 
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24 
25 #include "pqxx/notification"
26 
27 
28 namespace pqxx
29 {
30 class connection_base;
31 class notify_listener;
32 
33 namespace internal
34 {
37 {
38 public:
40  connection_base &c,
41  const PGSTD::string &channel_name,
42  notify_listener *wrappee) :
43  notification_receiver(c, channel_name),
44  m_wrappee(wrappee)
45  {}
46 
47  virtual void operator()(const PGSTD::string &, int backend_pid);
48 
49 private:
50  notify_listener *m_wrappee;
51 };
52 }
53 
54 
56 
58 class PQXX_LIBEXPORT PQXX_NOVTABLE notify_listener :
59  public PGSTD::unary_function<int, void>
60 {
61 public:
62  notify_listener(connection_base &c, const PGSTD::string &n);
63  virtual ~notify_listener() throw ();
64  const PGSTD::string &name() const { return m_forwarder.channel(); }
65  virtual void operator()(int be_pid) =0;
66 
67 
68 protected:
69  connection_base &Conn() const throw () { return conn(); }
70  connection_base &conn() const throw () { return m_conn; }
71 
72 private:
73  connection_base &m_conn;
75 };
76 }
77 
78 
79 #include "pqxx/compiler-internal-post.hxx"
80 
81 #endif