minor fixes for clang++
[senf.git] / senf / PPI / EventManager.hh
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 EventManager public header */
30
31 #ifndef HH_SENF_PPI_EventManager_
32 #define HH_SENF_PPI_EventManager_ 1
33
34 // Custom includes
35 #include <boost/utility.hpp>
36 #include <boost/ptr_container/ptr_vector.hpp>
37 #include <senf/Scheduler/ClockService.hh>
38 #include "predecl.hh"
39 #include "detail/Callback.hh"
40 #include "detail/EventBinding.hh"
41
42 //#include "EventManager.mpp"
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44
45 namespace senf {
46 namespace ppi {
47
48     /** \brief Event registry and control
49
50         The EventManager control event registration and manages global event parameters. The
51         EventManager controls event dispatch but does \e not control event generation. This is the
52         responsibility of an external component (the Scheduler)
53       */
54     class EventManager
55         : boost::noncopyable
56     {
57     public:
58         //-////////////////////////////////////////////////////////////////////////
59         // Types
60
61 #ifndef DOXYGEN
62         // Somehow doxygen barfs on this definition
63         template <class Descriptor>
64         struct Callback
65             : public detail::Callback<typename Descriptor::EventArg>
66         {};
67 #endif
68
69         //-////////////////////////////////////////////////////////////////////////
70         ///\name Structors and default members
71         //\{
72
73         static EventManager & instance();
74         static bool alive();
75
76         // default default constructor
77         // default copy constructor
78         // default copy assignment
79         // default destructor
80
81         // no conversion constructors
82
83         //\}
84         //-////////////////////////////////////////////////////////////////////////
85
86         ClockService::clock_type now(); ///< Current time at last event dispatch
87         ClockService::clock_type time(); ///< Expected time of the last event
88
89     protected:
90
91     private:
92         EventManager();
93         ~EventManager();
94
95         template <class Descriptor>
96         void registerEvent(module::Module & module,
97                            typename Callback<Descriptor>::type callback,
98                            Descriptor & descriptor);
99
100         void destroyModule(module::Module & module);
101         void destroyEvent(EventDescriptor & event);
102
103         typedef boost::ptr_vector<detail::EventBindingBase> EventRegistrations;
104         EventRegistrations registrations_;
105
106         void eventTime(ClockService::clock_type time);
107
108         ClockService::clock_type eventTime_;
109
110         static bool alive_;
111
112         friend class detail::EventBindingBase;
113         friend class module::Module;
114         friend class EventDescriptor;
115     };
116
117 }}
118
119 //-/////////////////////////////////////////////////////////////////////////////////////////////////
120 #include "EventManager.cci"
121 #include "EventManager.ct"
122 //#include "EventManager.cti"
123 #endif
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: