libpqxx 4.0
notify-listen.hxx
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/notify-listen.hxx
00005  *
00006  *   DESCRIPTION
00007  *      Definition of the obsolete pqxx::notify_listener functor interface.
00008  *   Predecessor to notification_receiver.  Deprecated.  Do not use.
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/notify-listen instead.
00010  *
00011  * Copyright (c) 2001-2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
00012  *
00013  * See COPYING for copyright license.  If you did not receive a file called
00014  * COPYING with this source code, please notify the distributor of this mistake,
00015  * or contact the author.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #ifndef PQXX_H_NOTIFY_LISTEN
00020 #define PQXX_H_NOTIFY_LISTEN
00021 
00022 #include "pqxx/compiler-public.hxx"
00023 #include "pqxx/compiler-internal-pre.hxx"
00024 
00025 #include "pqxx/notification"
00026 
00027 
00028 namespace pqxx
00029 {
00030 class connection_base;
00031 class notify_listener;
00032 
00033 namespace internal
00034 {
00036 class notify_listener_forwarder: public notification_receiver
00037 {
00038 public:
00039   notify_listener_forwarder(
00040         connection_base &c,
00041         const PGSTD::string &channel_name,
00042         notify_listener *wrappee) :
00043     notification_receiver(c, channel_name),
00044     m_wrappee(wrappee)
00045   {}
00046 
00047   virtual void operator()(const PGSTD::string &, int backend_pid);
00048 
00049 private:
00050   notify_listener *m_wrappee;
00051 };
00052 }
00053 
00054 
00056 
00058 class PQXX_LIBEXPORT PQXX_NOVTABLE notify_listener :
00059   public PGSTD::unary_function<int, void>
00060 {
00061 public:
00062   notify_listener(connection_base &c, const PGSTD::string &n);
00063   virtual ~notify_listener() throw ();
00064   const PGSTD::string &name() const { return m_forwarder.channel(); }
00065   virtual void operator()(int be_pid) =0;
00066 
00067 
00068 protected:
00069   connection_base &Conn() const throw () { return conn(); }
00070   connection_base &conn() const throw () { return m_conn; }
00071 
00072 private:
00073   connection_base &m_conn;
00074   internal::notify_listener_forwarder m_forwarder;
00075 };
00076 }
00077 
00078 
00079 #include "pqxx/compiler-internal-post.hxx" 
00080 
00081 #endif