sigx++ 2.0.1
|
00001 #ifndef _SIGX_DISPATCHABLE_HPP_ 00002 #define _SIGX_DISPATCHABLE_HPP_ 00003 00004 /* 00005 * Copyright 2006 Klaus Triendl 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public 00018 * License along with this library; if not, write to the Free 00019 * Software Foundation, 51 Franklin Street, Fifth Floor, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include <utility> // std::pair 00024 #include <sigc++/trackable.h> // need the trackable_callback_list 00025 #include <sigxconfig.h> 00026 #include <sigx/fwddecl.h> 00027 #include <sigx/noncopyable.h> 00028 #include <sigx/glib_lockables.h> 00029 00030 00031 namespace sigx 00032 { 00033 00034 namespace internal 00035 { 00036 00037 typedef rw_lockable<dispatcher_ptr> rwlockable_dispatcher_ptr; 00038 00039 00040 } // namespace internal 00041 00042 00043 00051 class SIGX_API dispatchable: noncopyable 00052 { 00053 // must access members 00054 friend class shared_dispatchable; 00055 00056 protected: 00060 dispatchable(); 00061 // non-virtual by design 00062 ~dispatchable() throw(); 00063 00064 private: 00067 dispatchable(const dispatchable& other) throw(); 00068 00071 dispatchable& operator =(const dispatchable& other) throw(); 00072 00075 void release() throw(); 00076 00077 protected: 00082 void invalidate_tunnels(); 00083 00086 dispatcher_ptr dispatcher() const throw() 00087 { 00088 return m_disp_ptr->access_nonvolatile(); 00089 } 00090 00091 public: 00092 typedef void (*func_dispatcher_change_notify)(void* /*handle to internal::validity_trackable*/); 00093 00100 void add_dispatcher_change_notify_callback(void* data, func_dispatcher_change_notify func) const; 00101 00106 void remove_dispatcher_change_notify_callback(void* data) const; 00107 00108 00109 private: 00111 volatile int* m_shared_count; 00112 00117 typedef std::list<std::pair<void*, func_dispatcher_change_notify> > callback_list_type; 00118 typedef callback_list_type* callback_list_ptr_type; 00119 callback_list_ptr_type* m_dispatcher_change_callback_list; 00120 00121 protected: 00122 internal::rwlockable_dispatcher_ptr* m_disp_ptr; 00123 }; 00124 00125 00126 } // namespace sigx 00127 00128 00129 #endif // end file guard