4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief EventManager public header */
26 #ifndef HH_SENF_Scheduler_EventManager_
27 #define HH_SENF_Scheduler_EventManager_ 1
31 #include <boost/iterator/filter_iterator.hpp>
32 #include <senf/boost_intrusive/ilist.hpp>
33 #include <senf/boost_intrusive/ilist_hook.hpp>
34 #include <senf/Utils/singleton.hh>
35 #include <senf/Utils/Console/LazyDirectory.hh>
37 //#include "EventManager.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
46 typedef boost::intrusive::ilist_base_hook<EventListTag> EventListBase;
47 typedef boost::intrusive::ilist<EventListBase::value_traits<Event>, false> EventList;
52 : public EventListBase
55 ///////////////////////////////////////////////////////////////////////////
58 ///////////////////////////////////////////////////////////////////////////
59 ///\name Structors and default members
62 explicit Event(std::string const & name);
66 ///////////////////////////////////////////////////////////////////////////
68 std::string const & name() const; ///< Get event name
69 bool enabled() const; ///< \c true, if event is enabled, \c false otherwise
70 unsigned runCount() const; ///< Number of times, event was fired
71 char const * type() const; ///< Event type code
72 std::string info() const; ///< Additional event information
78 virtual bool v_enabled() const = 0;
79 virtual char const * v_type() const = 0;
80 virtual std::string v_info() const = 0;
89 : public singleton<EventManager>
92 using singleton<EventManager>::instance;
93 using singleton<EventManager>::alive;
95 struct IteratorFilter {
96 bool operator()(Event const & e);
99 typedef boost::filter_iterator<
100 IteratorFilter, EventList::const_iterator> iterator;
102 void add(Event & event);
103 void remove(Event & event);
105 iterator begin() const;
106 iterator end() const;
108 void listEvents(std::ostream & os);
117 friend class singleton<EventManager>;
119 #ifndef SENF_DISABLE_CONSOLE
120 console::LazyDirectory consoleDir_;
126 ///////////////////////////////hh.e////////////////////////////////////////
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"