00001 /*------------------------------------------------------------------------- 00002 * 00003 * FILE 00004 * pqxx/notify-listen.hxx 00005 * 00006 * DESCRIPTION 00007 * definition of the pqxx::notify_listener functor interface. 00008 * pqxx::notify_listener describes a notification to wait on, and what it does 00009 * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/notify-listen instead. 00010 * 00011 * Copyright (c) 2001-2008, 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/connection_base" 00026 00027 00028 /* Methods tested in eg. self-test program test001 are marked with "//[t1]" 00029 */ 00030 00031 namespace pqxx 00032 { 00034 00059 class PQXX_LIBEXPORT PQXX_NOVTABLE notify_listener : 00060 public PGSTD::unary_function<int, void> 00061 { 00062 public: 00064 00068 notify_listener(connection_base &C, const PGSTD::string &N) : //[t4] 00069 m_Conn(C), m_Name(N) { m_Conn.add_listener(this); } 00070 00071 virtual ~notify_listener() throw () //[t4] 00072 { 00073 #ifdef PQXX_QUIET_DESTRUCTORS 00074 disable_noticer Quiet(Conn()); 00075 #endif 00076 m_Conn.remove_listener(this); 00077 } 00078 00079 const PGSTD::string &name() const { return m_Name; } //[t4] 00080 00082 00087 virtual void operator()(int be_pid) =0; //[t4] 00088 00089 00090 protected: 00091 connection_base &Conn() const throw () { return m_Conn; } //[t23] 00092 00093 private: 00095 notify_listener(const notify_listener &); 00097 notify_listener &operator=(const notify_listener &); 00098 00099 connection_base &m_Conn; 00100 PGSTD::string m_Name; 00101 }; 00102 00103 } 00104 00105 00106 #include "pqxx/compiler-internal-post.hxx" 00107 00108 #endif 00109