Scheduler: Move timing related code into a ClockService class
[senf.git] / PPI / DebugModules.cci
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
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 DebugModules inline non-template implementation */
25
26 // Custom includes
27
28 #define prefix_ inline
29 ///////////////////////////////cci.p///////////////////////////////////////
30
31 ///////////////////////////////////////////////////////////////////////////
32 // senf::ppi::module::debug::ActivePacketSource
33
34 prefix_ senf::ppi::module::debug::ActivePacketSource::ActivePacketSource()
35 {
36     noroute(output);
37 }
38
39 prefix_ void senf::ppi::module::debug::ActivePacketSource::submit(Packet packet)
40 {
41     output(packet);
42 }
43
44 prefix_ bool senf::ppi::module::debug::ActivePacketSource::boolean_test()
45     const
46 {
47     return output;
48 }
49
50 ///////////////////////////////////////////////////////////////////////////
51 // senf::ppi::module::debug::PassivePacketSource
52
53 prefix_ senf::ppi::module::debug::PassivePacketSource::PassivePacketSource()
54 {
55     noroute(output);
56     output.onRequest(&PassivePacketSource::request);
57 }
58
59 prefix_ void senf::ppi::module::debug::PassivePacketSource::submit(Packet packet)
60 {
61     packets_.push_back(packet);
62     output.unthrottle();
63 }
64
65 prefix_ bool senf::ppi::module::debug::PassivePacketSource::empty()
66 {
67     return packets_.empty();
68 }
69
70 prefix_ senf::ppi::module::debug::PassivePacketSource::size_type
71 senf::ppi::module::debug::PassivePacketSource::size()
72 {
73     return packets_.size();
74 }
75
76 ////////////////////////////////////////
77 // private members
78
79 prefix_ void senf::ppi::module::debug::PassivePacketSource::request()
80 {
81     BOOST_ASSERT( ! packets_.empty() );
82     output(packets_.front());
83     packets_.pop_front();
84     if (packets_.empty())
85         output.throttle();
86 }
87
88 prefix_ void senf::ppi::module::debug::PassivePacketSource::init()
89 {
90     if (empty())
91         output.throttle();
92 }
93
94 ///////////////////////////////////////////////////////////////////////////
95 // senf::ppi::module::debug::ActivePacketSink
96
97 prefix_ senf::ppi::module::debug::ActivePacketSink::ActivePacketSink()
98 {
99     noroute(input);
100 }
101
102 prefix_ senf::Packet senf::ppi::module::debug::ActivePacketSink::request()
103 {
104     return input();
105 }
106
107 prefix_ bool senf::ppi::module::debug::ActivePacketSink::boolean_test()
108     const
109 {
110     return input;
111 }
112
113 ///////////////////////////////////////////////////////////////////////////
114 // senf::ppi::module::debug::PassivePacketSink
115
116 prefix_ senf::ppi::module::debug::PassivePacketSink::PassivePacketSink()
117 {
118     noroute(input);
119     input.onRequest(&PassivePacketSink::request);
120 }
121
122 prefix_ bool senf::ppi::module::debug::PassivePacketSink::empty()
123 {
124     return packets_.empty();
125 }
126
127 prefix_ senf::ppi::module::debug::PassivePacketSink::size_type
128 senf::ppi::module::debug::PassivePacketSink::size()
129 {
130     return packets_.size();
131 }
132
133 prefix_ senf::ppi::module::debug::PassivePacketSink::iterator
134 senf::ppi::module::debug::PassivePacketSink::begin()
135 {
136     return packets_.begin();
137 }
138
139 prefix_ senf::ppi::module::debug::PassivePacketSink::iterator
140 senf::ppi::module::debug::PassivePacketSink::end()
141 {
142     return packets_.end();
143 }
144
145 prefix_ senf::Packet senf::ppi::module::debug::PassivePacketSink::front()
146 {
147     if (empty())
148         return Packet();
149     else
150         return packets_.front();
151 }
152
153 prefix_ senf::Packet senf::ppi::module::debug::PassivePacketSink::pop_front()
154 {
155     Packet p (front());
156     if (p) 
157         packets_.pop_front();
158     return p;
159 }
160
161 prefix_ void senf::ppi::module::debug::PassivePacketSink::clear()
162 {
163     packets_.erase(packets_.begin(), packets_.end());
164 }
165
166 ////////////////////////////////////////
167 // private members
168
169 prefix_ void senf::ppi::module::debug::PassivePacketSink::request()
170 {
171     packets_.push_back(input());
172 }
173
174 ///////////////////////////////cci.e///////////////////////////////////////
175 #undef prefix_
176
177 \f
178 // Local Variables:
179 // mode: c++
180 // fill-column: 100
181 // comment-column: 40
182 // c-file-style: "senf"
183 // indent-tabs-mode: nil
184 // ispell-local-dictionary: "american"
185 // compile-command: "scons -u test"
186 // End: