PPI: Remove 'Packet' from debug module names
[senf.git] / PPI / DebugModules.hh
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 public header */
25
26 #ifndef HH_DebugModules_
27 #define HH_DebugModules_ 1
28
29 // Custom includes
30 #include <deque>
31 #include "Utils/SafeBool.hh"
32 #include "Packets/Packets.hh"
33 #include "Module.hh"
34 #include "ActiveFeeder.hh"
35
36 //#include "DebugModules.mpp"
37 ///////////////////////////////hh.p////////////////////////////////////////
38
39 /** \namespace senf::ppi::module::debug
40     \brief Debug modules
41
42     This namespace collects several modules helpful for PPI debugging. The modules allow to manually
43     pass packets into a network and read back the output packets.
44
45     
46  */
47
48 namespace senf {
49 namespace ppi {
50 namespace module {
51 namespace debug {
52     
53     /** \brief
54      */
55     class ActiveSource
56         : public Module, 
57           public SafeBool<ActiveSource>
58     {
59         SENF_PPI_MODULE(ActiveSource);
60
61     public:
62         connector::ActiveOutput output;
63
64         ActiveSource();
65
66         void submit(Packet packet);
67
68         bool boolean_test() const;
69     };
70
71     class PassiveSource
72         : public Module
73     {
74         SENF_PPI_MODULE(PassiveSource);
75
76         typedef std::deque<Packet> Queue;
77
78     public:
79         typedef Queue::size_type size_type;
80         
81         PassiveSource();
82         
83         connector::PassiveOutput output;
84         
85         void submit(Packet packet);
86
87         bool empty();
88         size_type size();
89
90     private:
91         void request();
92         void init();
93         
94         Queue packets_;
95     };
96
97     class ActiveSink
98         : public Module,
99           public SafeBool<ActiveSink>
100     {
101         SENF_PPI_MODULE(ActiveSink);
102
103     public:
104         connector::ActiveInput input;
105
106         ActiveSink();
107
108         Packet request();
109
110         bool boolean_test() const;
111     };
112
113     class PassiveSink
114         : public Module
115     {
116         SENF_PPI_MODULE(PassiveSink);
117
118         typedef std::deque<Packet> Queue;
119
120     public:
121         typedef Queue::size_type size_type;
122         typedef Queue::const_iterator iterator;
123
124         connector::PassiveInput input;
125         
126         PassiveSink();
127
128         bool empty();
129         size_type size();
130         iterator begin();
131         iterator end();
132
133         Packet front();
134         Packet pop_front();
135
136         void clear();
137
138     private:
139         void request();
140         
141         Queue packets_;
142     };
143
144     class ActiveFeederSource
145     {
146     private:
147         PassiveSource source;
148         ActiveFeeder feeder;
149
150     public:
151         typedef PassiveSource::size_type size_type;
152         
153         connector::ActiveOutput & output;
154
155         ActiveFeederSource();
156
157         void submit(Packet packet);
158         bool empty();
159         size_type size();
160     };
161
162     class ActiveFeederSink
163     {
164     private:
165         PassiveSink sink;
166         ActiveFeeder feeder;
167
168     public:
169         typedef PassiveSink::size_type size_type;
170         typedef PassiveSink::iterator iterator;
171
172         connector::ActiveInput & input;
173         
174         ActiveFeederSink();
175
176         bool empty();
177         size_type size();
178         iterator begin();
179         iterator end();
180
181         Packet front();
182         Packet pop_front();
183
184         void clear();
185     };
186
187 }}}}
188
189 ///////////////////////////////hh.e////////////////////////////////////////
190 #include "DebugModules.cci"
191 //#include "DebugModules.ct"
192 //#include "DebugModules.cti"
193 #endif
194
195 \f
196 // Local Variables:
197 // mode: c++
198 // fill-column: 100
199 // comment-column: 40
200 // c-file-style: "senf"
201 // indent-tabs-mode: nil
202 // ispell-local-dictionary: "american"
203 // compile-command: "scons -u test"
204 // End: