4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
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
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.
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.
19 // The Original Code is Fraunhofer FOKUS code.
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.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief EventManager public header */
31 #ifndef HH_SENF_Scheduler_EventManager_
32 #define HH_SENF_Scheduler_EventManager_ 1
36 #include <boost/iterator/filter_iterator.hpp>
37 #include <senf/boost_intrusive/ilist.hpp>
38 #include <senf/boost_intrusive/ilist_hook.hpp>
39 #include <senf/Utils/singleton.hh>
41 //#include "EventManager.mpp"
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
50 typedef boost::intrusive::ilist_base_hook<EventListTag> EventListBase;
51 typedef boost::intrusive::ilist<EventListBase::value_traits<Event>, false> EventList;
56 : public EventListBase
59 //-////////////////////////////////////////////////////////////////////////
62 //-////////////////////////////////////////////////////////////////////////
63 ///\name Structors and default members
66 explicit Event(std::string const & name);
70 //-////////////////////////////////////////////////////////////////////////
72 std::string const & name() const; ///< Get event name
73 bool enabled() const; ///< \c true, if event is enabled, \c false otherwise
74 unsigned runCount() const; ///< Number of times, event was fired
75 char const * type() const; ///< Event type code
76 std::string info() const; ///< Additional event information
82 virtual bool v_enabled() const = 0;
83 virtual char const * v_type() const = 0;
84 virtual std::string v_info() const = 0;
93 : public singleton<EventManager>
96 using singleton<EventManager>::instance;
97 using singleton<EventManager>::alive;
99 struct IteratorFilter {
100 bool operator()(Event const & e);
103 typedef boost::filter_iterator<
104 IteratorFilter, EventList::const_iterator> iterator;
106 void add(Event & event);
107 void remove(Event & event);
109 iterator begin() const;
110 iterator end() const;
112 void listEvents(std::ostream & os);
121 friend class singleton<EventManager>;
126 //-/////////////////////////////////////////////////////////////////////////////////////////////////
127 #include "EventManager.cci"
128 //#include "EventManager.ct"
129 //#include "EventManager.cti"
136 // comment-column: 40
137 // c-file-style: "senf"
138 // indent-tabs-mode: nil
139 // ispell-local-dictionary: "american"
140 // compile-command: "scons -u test"