PPI: Implement PassiveOuput <-> ActiveInput functionality
[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 ///////////////////////////////////////////////////////////////////////////
45 // senf::ppi::module::debug::PassivePacketSource
46
47 prefix_ senf::ppi::module::debug::PassivePacketSource::PassivePacketSource()
48 {
49     noroute(output);
50     output.onRequest(&PassivePacketSource::request);
51 }
52
53 prefix_ void senf::ppi::module::debug::PassivePacketSource::submit(Packet packet)
54 {
55     packets_.push_back(packet);
56 }
57
58 prefix_ bool senf::ppi::module::debug::PassivePacketSource::empty()
59 {
60     return packets_.empty();
61 }
62
63 prefix_ senf::ppi::module::debug::PassivePacketSource::size_type
64 senf::ppi::module::debug::PassivePacketSource::size()
65 {
66     return packets_.size();
67 }
68
69 ////////////////////////////////////////
70 // private members
71
72 prefix_ void senf::ppi::module::debug::PassivePacketSource::request()
73 {
74     output(packets_.front());
75     packets_.pop_front();
76 }
77
78 ///////////////////////////////////////////////////////////////////////////
79 // senf::ppi::module::debug::ActivePacketSink
80
81 prefix_ senf::ppi::module::debug::ActivePacketSink::ActivePacketSink()
82 {
83     noroute(input);
84 }
85
86 prefix_ senf::Packet senf::ppi::module::debug::ActivePacketSink::request()
87 {
88     return input();
89 }
90
91 ///////////////////////////////////////////////////////////////////////////
92 // senf::ppi::module::debug::PassivePacketSink
93
94 prefix_ senf::ppi::module::debug::PassivePacketSink::PassivePacketSink()
95 {
96     noroute(input);
97     input.onRequest(&PassivePacketSink::request);
98 }
99
100 prefix_ bool senf::ppi::module::debug::PassivePacketSink::empty()
101 {
102     return packets_.empty();
103 }
104
105 prefix_ senf::ppi::module::debug::PassivePacketSink::size_type
106 senf::ppi::module::debug::PassivePacketSink::size()
107 {
108     return packets_.size();
109 }
110
111 prefix_ senf::ppi::module::debug::PassivePacketSink::iterator
112 senf::ppi::module::debug::PassivePacketSink::begin()
113 {
114     return packets_.begin();
115 }
116
117 prefix_ senf::ppi::module::debug::PassivePacketSink::iterator
118 senf::ppi::module::debug::PassivePacketSink::end()
119 {
120     return packets_.end();
121 }
122
123 prefix_ senf::Packet senf::ppi::module::debug::PassivePacketSink::back()
124 {
125     if (empty())
126         return Packet();
127     else
128         return packets_.back();
129 }
130
131 prefix_ senf::Packet senf::ppi::module::debug::PassivePacketSink::pop_back()
132 {
133     Packet p (back());
134     if (p) 
135         packets_.pop_back();
136     return p;
137 }
138
139 prefix_ void senf::ppi::module::debug::PassivePacketSink::clear()
140 {
141     packets_.erase(packets_.begin(), packets_.end());
142 }
143
144 ////////////////////////////////////////
145 // private members
146
147 prefix_ void senf::ppi::module::debug::PassivePacketSink::request()
148 {
149     packets_.push_back(input());
150 }
151
152 ///////////////////////////////cci.e///////////////////////////////////////
153 #undef prefix_
154
155 \f
156 // Local Variables:
157 // mode: c++
158 // fill-column: 100
159 // comment-column: 40
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u test"
164 // End: