sigx++  2.0.1
dispatchable.h
Go to the documentation of this file.
1 #ifndef _SIGX_DISPATCHABLE_HPP_
2 #define _SIGX_DISPATCHABLE_HPP_
3 
4 /*
5  * Copyright 2006 Klaus Triendl
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21 */
22 
23 #include <utility> // std::pair
24 #include <sigc++/trackable.h> // need the trackable_callback_list
25 #include <sigxconfig.h>
26 #include <sigx/fwddecl.h>
27 #include <sigx/noncopyable.h>
28 #include <sigx/glib_lockables.h>
29 
30 
31 namespace sigx
32 {
33 
34  namespace internal
35  {
36 
38 
39 
40  } // namespace internal
41 
42 
43 
51 class SIGX_API dispatchable: noncopyable
52 {
53  // must access members
54  friend class shared_dispatchable;
55 
56 protected:
60  dispatchable();
61  // non-virtual by design
62  ~dispatchable() throw();
63 
64 private:
67  dispatchable(const dispatchable& other) throw();
68 
71  dispatchable& operator =(const dispatchable& other) throw();
72 
75  void release() throw();
76 
77 protected:
82  void invalidate_tunnels();
83 
86  dispatcher_ptr dispatcher() const throw()
87  {
88  return m_disp_ptr->access_nonvolatile();
89  }
90 
91 public:
92  typedef void (*func_dispatcher_change_notify)(void* /*handle to internal::validity_trackable*/);
93 
100  void add_dispatcher_change_notify_callback(void* data, func_dispatcher_change_notify func) const;
101 
106  void remove_dispatcher_change_notify_callback(void* data) const;
107 
108 
109 private:
111  volatile int* m_shared_count;
112 
117  typedef std::list<std::pair<void*, func_dispatcher_change_notify> > callback_list_type;
118  typedef callback_list_type* callback_list_ptr_type;
119  callback_list_ptr_type* m_dispatcher_change_callback_list;
120 
121 protected:
123 };
124 
125 
126 } // namespace sigx
127 
128 
129 #endif // end file guard