switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / PPI / Events.cti
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Events inline template implementation */
30
31 #include "Events.ih"
32
33 // Custom includes
34 #include <senf/Utils/senfassert.hh>
35 #include "detail/EventBinding.hh"
36
37 #define prefix_ inline
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 // senf::ppi::EventImplementationHelper<EventType,Self>
42
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 // protected members
45
46 template <class EventType, class Self>
47 prefix_ void
48 senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event,
49                                                                ClockService::clock_type time)
50 {
51     binding().callback(event,time);
52 }
53
54 template <class EventType, class Self>
55 prefix_ void senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event)
56 {
57     binding().callback(event);
58 }
59
60 //-/////////////////////////////////////////////////////////////////////////////////////////////////
61 // private members
62
63 template <class EventType, class Self>
64 prefix_ senf::ppi::detail::EventBinding<EventType> &
65 senf::ppi::EventImplementationHelper<EventType,Self>::binding()
66 {
67     SENF_ASSERT( static_cast<Self*>(this)->binding_,
68                  "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
69     return * static_cast<Self*>(this)->binding_;
70 }
71
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 // senf::ppi::EventImplementationHelper<void,Self>
74
75 //-/////////////////////////////////////////////////////////////////////////////////////////////////
76 // protected members
77
78 template <class Self>
79 prefix_ void
80 senf::ppi::EventImplementationHelper<void,Self>::callback(ClockService::clock_type time)
81 {
82     binding().callback(time);
83 }
84
85 template <class Self>
86 prefix_ void senf::ppi::EventImplementationHelper<void,Self>::callback()
87 {
88     binding().callback();
89 }
90
91 //-/////////////////////////////////////////////////////////////////////////////////////////////////
92 // private members
93
94 template <class Self>
95 prefix_ senf::ppi::detail::EventBinding<void> &
96 senf::ppi::EventImplementationHelper<void,Self>::binding()
97 {
98     SENF_ASSERT( static_cast<Self*>(this)->binding_,
99                  "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
100     return * static_cast<Self*>(this)->binding_;
101 }
102
103 //-/////////////////////////////////////////////////////////////////////////////////////////////////
104 // senf::ppi::EventImplementation<EventType>
105
106 template <class EventType>
107 prefix_ senf::ppi::module::Module & senf::ppi::EventImplementation<EventType>::module()
108     const
109 {
110     return binding_->module();
111 }
112
113 template <class EventType>
114 prefix_ senf::ppi::EventManager & senf::ppi::EventImplementation<EventType>::manager()
115     const
116 {
117     return binding_->manager();
118 }
119
120 //-/////////////////////////////////////////////////////////////////////////////////////////////////
121 // protected members
122
123 template <class EventType>
124 prefix_ senf::ppi::EventImplementation<EventType>::EventImplementation()
125     : binding_(0)
126 {}
127
128 //-/////////////////////////////////////////////////////////////////////////////////////////////////
129 // private members
130
131 template <class EventType>
132 prefix_ bool senf::ppi::EventImplementation<EventType>::v_isRegistered()
133 {
134     return binding_;
135 }
136
137 template <class EventType>
138 prefix_ void
139 senf::ppi::EventImplementation<EventType>::setBinding(detail::EventBinding<Event> & binding)
140 {
141     binding_ = & binding;
142 }
143
144 //-/////////////////////////////////////////////////////////////////////////////////////////////////
145 #undef prefix_
146
147 \f
148 // Local Variables:
149 // mode: c++
150 // fill-column: 100
151 // comment-column: 40
152 // c-file-style: "senf"
153 // indent-tabs-mode: nil
154 // ispell-local-dictionary: "american"
155 // compile-command: "scons -u test"
156 // End: