4a128b46ba0299bfcb253ffc8295c833004d1b85
[senf.git] / PPI / Events.cti
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Events inline template implementation */
25
26 #include "Events.ih"
27
28 // Custom includes
29 #include "detail/EventBinding.hh"
30
31 #define prefix_ inline
32 ///////////////////////////////cti.p///////////////////////////////////////
33
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::ppi::EventImplementationHelper<EventType,Self>
36
37 ////////////////////////////////////////
38 // protected members
39
40 template <class EventType, class Self>
41 prefix_ void
42 senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event,
43                                                                ClockService::clock_type time)
44 {
45     binding().callback(event,time);
46 }
47
48 template <class EventType, class Self>
49 prefix_ void senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event)
50 {
51     binding().callback(event);
52 }
53
54 ////////////////////////////////////////
55 // private members
56
57 template <class EventType, class Self>
58 prefix_ senf::ppi::detail::EventBinding<EventType> &
59 senf::ppi::EventImplementationHelper<EventType,Self>::binding()
60 {
61     BOOST_ASSERT( static_cast<Self*>(this)->binding_ );
62     return * static_cast<Self*>(this)->binding_;
63 }
64
65 ///////////////////////////////////////////////////////////////////////////
66 // senf::ppi::EventImplementationHelper<void,Self>
67
68 ////////////////////////////////////////
69 // protected members
70
71 template <class Self>
72 prefix_ void
73 senf::ppi::EventImplementationHelper<void,Self>::callback(ClockService::clock_type time)
74 {
75     binding().callback(time);
76 }
77
78 template <class Self>
79 prefix_ void senf::ppi::EventImplementationHelper<void,Self>::callback()
80 {
81     binding().callback();
82 }
83
84 ////////////////////////////////////////
85 // private members
86
87 template <class Self>
88 prefix_ senf::ppi::detail::EventBinding<void> &
89 senf::ppi::EventImplementationHelper<void,Self>::binding()
90 {
91     BOOST_ASSERT( static_cast<Self*>(this)->binding_ );
92     return * static_cast<Self*>(this)->binding_;
93 }
94
95 ///////////////////////////////////////////////////////////////////////////
96 // senf::ppi::EventImplementation<EventType>
97
98 ////////////////////////////////////////
99 // protected members
100
101 template <class EventType>
102 prefix_ senf::ppi::EventImplementation<EventType>::EventImplementation()
103     : binding_(0)
104 {}
105
106 ////////////////////////////////////////
107 // private members
108
109 template <class EventType>
110 prefix_ bool senf::ppi::EventImplementation<EventType>::v_isRegistered()
111 {
112     return binding_;
113 }
114
115 template <class EventType>
116 prefix_ void
117 senf::ppi::EventImplementation<EventType>::setBinding(detail::EventBinding<Event> & binding)
118 {
119     binding_ = & binding;
120 }
121
122 ///////////////////////////////cti.e///////////////////////////////////////
123 #undef prefix_
124
125 \f
126 // Local Variables:
127 // mode: c++
128 // fill-column: 100
129 // comment-column: 40
130 // c-file-style: "senf"
131 // indent-tabs-mode: nil
132 // ispell-local-dictionary: "american"
133 // compile-command: "scons -u test"
134 // End: