ab879b051c0c2097cb7c4556487e00884fefd367
[senf.git] / senf / Scheduler / EventManager.cci
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
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 EventManager inline non-template implementation */
25
26 //#include "EventManager.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 //-/////////////////////////////////////////////////////////////////////////////////////////////////
32
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34 // senf::scheduler::detail::Event
35
36 prefix_ senf::scheduler::detail::Event::Event(std::string const & name)
37     : name_ (name), runCount_ (0u)
38 {
39     EventManager::instance().add(*this);
40 }
41
42 prefix_ senf::scheduler::detail::Event::~Event()
43 {
44     EventManager::instance().remove(*this);
45 }
46
47 prefix_ void senf::scheduler::detail::EventManager::add(Event & event)
48 {
49     events_.push_back(event);
50 }
51
52 prefix_ void senf::scheduler::detail::EventManager::remove(Event & event)
53 {
54     events_.erase(EventList::current(event));
55 }
56
57 prefix_ std::string const & senf::scheduler::detail::Event::name()
58     const
59 {
60     return name_;
61 }
62
63 prefix_ bool senf::scheduler::detail::Event::enabled()
64     const
65 {
66     return v_enabled();
67 }
68
69 prefix_ unsigned senf::scheduler::detail::Event::runCount()
70     const
71 {
72     return runCount_;
73 }
74
75 prefix_ char const * senf::scheduler::detail::Event::type()
76     const
77 {
78     return v_type();
79 }
80
81 prefix_ std::string senf::scheduler::detail::Event::info()
82     const
83 {
84     return v_info();
85 }
86
87 prefix_ void senf::scheduler::detail::Event::countRun()
88 {
89     ++ runCount_;
90 }
91
92 //-/////////////////////////////////////////////////////////////////////////////////////////////////
93 // senf::scheduler::detail::EventManager
94
95 prefix_ bool senf::scheduler::detail::EventManager::IteratorFilter::operator()(Event const & e)
96 {
97     return e.type() != 0;
98 }
99
100 prefix_ senf::scheduler::detail::EventManager::iterator
101 senf::scheduler::detail::EventManager::begin()
102     const
103 {
104     // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added
105     // by the FIFORunner is such an element and must be skipped.
106     return boost::make_filter_iterator(
107         IteratorFilter(), events_.begin(), events_.end());
108 }
109
110 prefix_ senf::scheduler::detail::EventManager::iterator
111 senf::scheduler::detail::EventManager::end()
112     const
113 {
114     return boost::make_filter_iterator(
115         IteratorFilter(), events_.end(), events_.end());
116 }
117
118 //-/////////////////////////////////////////////////////////////////////////////////////////////////
119 #undef prefix_
120
121 \f
122 // Local Variables:
123 // mode: c++
124 // fill-column: 100
125 // comment-column: 40
126 // c-file-style: "senf"
127 // indent-tabs-mode: nil
128 // ispell-local-dictionary: "american"
129 // compile-command: "scons -u test"
130 // End: