Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Scheduler / TimerEvent.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 TimerDispatcher inline non-template implementation */
25
26 #include "TimerEvent.ih"
27
28 // Custom includes
29 #include <unistd.h>
30
31 #define prefix_ inline
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
35 // senf::scheduler::TimerEvent
36
37 prefix_ senf::scheduler::TimerEvent::TimerEvent(std::string const & name, Callback const & cb,
38                                                 ClockService::clock_type timeout,
39                                                 bool initiallyEnabled)
40     : detail::FIFORunner::TaskInfo (name), cb_ (cb), timeout_ (timeout)
41 {
42     if (initiallyEnabled)
43         enable();
44 }
45
46 prefix_ senf::scheduler::TimerEvent::TimerEvent(std::string const & name, Callback const & cb)
47     : detail::FIFORunner::TaskInfo (name), cb_ (cb), timeout_ (0)
48 {}
49
50 prefix_ senf::scheduler::TimerEvent::~TimerEvent()
51 {
52     if (senf::scheduler::detail::TimerDispatcher::alive())
53         disable();
54 }
55
56 prefix_ void senf::scheduler::TimerEvent::enable()
57 {
58     if (! detail::TimerSetBase::linked())
59         senf::scheduler::detail::TimerDispatcher::instance().add(*this);
60 }
61
62 prefix_ void senf::scheduler::TimerEvent::disable()
63 {
64     if (detail::TimerSetBase::linked())
65         senf::scheduler::detail::TimerDispatcher::instance().remove(*this);
66 }
67
68 prefix_ void senf::scheduler::TimerEvent::action(Callback const & cb)
69 {
70     cb_ = cb;
71 }
72
73 prefix_ void senf::scheduler::TimerEvent::timeout(ClockService::clock_type timeout,
74                                                   bool initiallyEnabled)
75 {
76     disable();
77     timeout_ = timeout;
78     if (initiallyEnabled)
79         enable();
80 }
81
82 prefix_ senf::ClockService::clock_type senf::scheduler::TimerEvent::timeout()
83     const
84 {
85     return timeout_;
86 }
87
88 //-/////////////////////////////////////////////////////////////////////////////////////////////////
89 // senf::scheduler::detail::TimerDispatcher
90
91 prefix_ void senf::scheduler::detail::TimerDispatcher::enable()
92 {
93     source_->enable();
94 }
95
96 prefix_ void senf::scheduler::detail::TimerDispatcher::disable()
97 {
98     source_->disable();
99 }
100
101 prefix_ bool senf::scheduler::detail::TimerDispatcher::empty()
102     const
103 {
104     return timers_.empty();
105 }
106
107 prefix_ void senf::scheduler::detail::TimerDispatcher::
108 timerSource(std::auto_ptr<TimerSource> timerSource)
109 {
110     source_.reset(timerSource.release());
111 }
112
113 prefix_ senf::scheduler::detail::TimerSource *
114 senf::scheduler::detail::TimerDispatcher::timerSource()
115 {
116     return source_.get();
117 }
118
119 //-/////////////////////////////////////////////////////////////////////////////////////////////////
120 #undef prefix_
121
122 \f
123 // Local Variables:
124 // mode: c++
125 // fill-column: 100
126 // comment-column: 40
127 // c-file-style: "senf"
128 // indent-tabs-mode: nil
129 // ispell-local-dictionary: "american"
130 // compile-command: "scons -u test"
131 // End: