5dd66980b26b3921c01d86f45148439739a989ee
[senf.git] / senf / PPI / Events.cti
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
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 <senf/Utils/senfassert.hh>
30 #include "detail/EventBinding.hh"
31
32 #define prefix_ inline
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36 // senf::ppi::EventImplementationHelper<EventType,Self>
37
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // protected members
40
41 template <class EventType, class Self>
42 prefix_ void
43 senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event,
44                                                                ClockService::clock_type time)
45 {
46     binding().callback(event,time);
47 }
48
49 template <class EventType, class Self>
50 prefix_ void senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event)
51 {
52     binding().callback(event);
53 }
54
55 //-/////////////////////////////////////////////////////////////////////////////////////////////////
56 // private members
57
58 template <class EventType, class Self>
59 prefix_ senf::ppi::detail::EventBinding<EventType> &
60 senf::ppi::EventImplementationHelper<EventType,Self>::binding()
61 {
62     SENF_ASSERT( static_cast<Self*>(this)->binding_,
63                  "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
64     return * static_cast<Self*>(this)->binding_;
65 }
66
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 // senf::ppi::EventImplementationHelper<void,Self>
69
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 // protected members
72
73 template <class Self>
74 prefix_ void
75 senf::ppi::EventImplementationHelper<void,Self>::callback(ClockService::clock_type time)
76 {
77     binding().callback(time);
78 }
79
80 template <class Self>
81 prefix_ void senf::ppi::EventImplementationHelper<void,Self>::callback()
82 {
83     binding().callback();
84 }
85
86 //-/////////////////////////////////////////////////////////////////////////////////////////////////
87 // private members
88
89 template <class Self>
90 prefix_ senf::ppi::detail::EventBinding<void> &
91 senf::ppi::EventImplementationHelper<void,Self>::binding()
92 {
93     SENF_ASSERT( static_cast<Self*>(this)->binding_,
94                  "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
95     return * static_cast<Self*>(this)->binding_;
96 }
97
98 //-/////////////////////////////////////////////////////////////////////////////////////////////////
99 // senf::ppi::EventImplementation<EventType>
100
101 template <class EventType>
102 prefix_ senf::ppi::module::Module & senf::ppi::EventImplementation<EventType>::module()
103     const
104 {
105     return binding_->module();
106 }
107
108 template <class EventType>
109 prefix_ senf::ppi::EventManager & senf::ppi::EventImplementation<EventType>::manager()
110     const
111 {
112     return binding_->manager();
113 }
114
115 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 // protected members
117
118 template <class EventType>
119 prefix_ senf::ppi::EventImplementation<EventType>::EventImplementation()
120     : binding_(0)
121 {}
122
123 //-/////////////////////////////////////////////////////////////////////////////////////////////////
124 // private members
125
126 template <class EventType>
127 prefix_ bool senf::ppi::EventImplementation<EventType>::v_isRegistered()
128 {
129     return binding_;
130 }
131
132 template <class EventType>
133 prefix_ void
134 senf::ppi::EventImplementation<EventType>::setBinding(detail::EventBinding<Event> & binding)
135 {
136     binding_ = & binding;
137 }
138
139 //-/////////////////////////////////////////////////////////////////////////////////////////////////
140 #undef prefix_
141
142 \f
143 // Local Variables:
144 // mode: c++
145 // fill-column: 100
146 // comment-column: 40
147 // c-file-style: "senf"
148 // indent-tabs-mode: nil
149 // ispell-local-dictionary: "american"
150 // compile-command: "scons -u test"
151 // End: