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