PPI: Clean up time interface
[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 template <class EventType>
99 prefix_ senf::ppi::module::Module & senf::ppi::EventImplementation<EventType>::module()
100     const
101 {
102     return binding_->module();
103 }
104
105 template <class EventType>
106 prefix_ senf::ppi::EventManager & senf::ppi::EventImplementation<EventType>::manager()
107     const
108 {
109     return binding_->manager();
110 }
111
112 ////////////////////////////////////////
113 // protected members
114
115 template <class EventType>
116 prefix_ senf::ppi::EventImplementation<EventType>::EventImplementation()
117     : binding_(0)
118 {}
119
120 ////////////////////////////////////////
121 // private members
122
123 template <class EventType>
124 prefix_ bool senf::ppi::EventImplementation<EventType>::v_isRegistered()
125 {
126     return binding_;
127 }
128
129 template <class EventType>
130 prefix_ void
131 senf::ppi::EventImplementation<EventType>::setBinding(detail::EventBinding<Event> & binding)
132 {
133     binding_ = & binding;
134 }
135
136 ///////////////////////////////cti.e///////////////////////////////////////
137 #undef prefix_
138
139 \f
140 // Local Variables:
141 // mode: c++
142 // fill-column: 100
143 // comment-column: 40
144 // c-file-style: "senf"
145 // indent-tabs-mode: nil
146 // ispell-local-dictionary: "american"
147 // compile-command: "scons -u test"
148 // End: