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