14fbb02902aa9d340aadb67061f17d8f5d686699
[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
35 //#include "DebugModules.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39 namespace ppi {
40 namespace module {
41 namespace debug {
42     
43     class ActivePacketSource
44         : public Module, 
45           public SafeBool<ActivePacketSource>
46     {
47         SENF_PPI_MODULE(ActivePacketSource);
48
49     public:
50         connector::ActiveOutput output;
51
52         ActivePacketSource();
53
54         void submit(Packet packet);
55
56         bool boolean_test() const;
57     };
58
59     class PassivePacketSource
60         : public Module
61     {
62         SENF_PPI_MODULE(PassivePacketSource);
63
64         typedef std::deque<Packet> Queue;
65
66     public:
67         typedef Queue::size_type size_type;
68         
69         PassivePacketSource();
70         
71         connector::PassiveOutput output;
72         
73         void submit(Packet packet);
74
75         bool empty();
76         size_type size();
77
78     private:
79         void request();
80         void init();
81         
82         Queue packets_;
83     };
84
85     class ActivePacketSink
86         : public Module,
87           public SafeBool<ActivePacketSink>
88     {
89         SENF_PPI_MODULE(ActivePacketSink);
90
91     public:
92         connector::ActiveInput input;
93
94         ActivePacketSink();
95
96         Packet request();
97
98         bool boolean_test() const;
99     };
100
101     class PassivePacketSink
102         : public Module
103     {
104         SENF_PPI_MODULE(PassivePacketSink);
105
106         typedef std::deque<Packet> Queue;
107
108     public:
109         typedef Queue::size_type size_type;
110         typedef Queue::const_iterator iterator;
111
112         connector::PassiveInput input;
113         
114         PassivePacketSink();
115
116         bool empty();
117         size_type size();
118         iterator begin();
119         iterator end();
120
121         Packet front();
122         Packet pop_front();
123
124         void clear();
125
126     private:
127         void request();
128         
129         Queue packets_;
130     };
131
132 }}}}
133
134 ///////////////////////////////hh.e////////////////////////////////////////
135 #include "DebugModules.cci"
136 //#include "DebugModules.ct"
137 //#include "DebugModules.cti"
138 #endif
139
140 \f
141 // Local Variables:
142 // mode: c++
143 // fill-column: 100
144 // comment-column: 40
145 // c-file-style: "senf"
146 // indent-tabs-mode: nil
147 // ispell-local-dictionary: "american"
148 // compile-command: "scons -u test"
149 // End: