Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2007
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
\brief SocketWriter public header */
#ifndef HH_SocketWriter_
#define HH_SocketWriter_ 1
// Custom includes
#include "Packets/Packet.hh"
#include "Module.hh"
#include "Connector.hh"
//#include "SocketWriter.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
namespace ppi {
/** \brief Write helper for module::ActiveSocketWriter / module::PassiveSocketWriter
This write helper will write the packets completely as datagrams to the given socket.
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
*/
class PacketWriter
{
public:
typedef senf::ClientSocketHandle<
senf::MakeSocketPolicy< senf::WriteablePolicy,
senf::DatagramFramingPolicy > > Handle;
///< Handle type supported by this writer
void operator()(Handle handle, Packet::ptr packet);
///< Write \a packet to \a handle
/**< Write the complete \a packet as a datagram to \a
handle.
\param[in] handle Handle to write data to
\param[in] packet Packet to write */
};
}}
namespace senf {
namespace ppi {
namespace module {
/** \brief Output module writing data to arbitrary FileHandle
This output module will write data to a FileHandle object using a given \a Writer. This
output module is active. This requires the file handle to be able to signal its readiness to
accept more data via the Scheduler.
The \a Writer must fulfill the following interface:
\code
class SomeWriter
{
public:
typedef unspecified Handle; // type of handle requested
SomeWriter(); // default constructible
void operator()(Handle handle, Packet::ptr packet); // insertion function
};
\endcode
*/
template <class Writer=PacketWriter>
class ActiveSocketWriter : public Module
{
public:
typedef typename Writer:Handle Handle; ///< Handle type requested by writer
connector::ActiveInput input; ///< Input connector from which data is received
ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Writer.
\param[in] handle Handle to write data to */
};
/** \brief Output module writing data to arbitrary FileHandle
This output module will write data to a FileHandle object using a given \a Writer. This
output module is passive. This implies, that the output handle may not block. This also
implies, that data will probably get lost if written to fast for the underlying transport
mechanism. Either this is desired (like for a UDP socket) or some additional bandwidth
shaping needs to be used.
The \a Writer must fulfill the following interface:
\code
class SomeWriter
{
public:
typedef unspecified Handle; // type of handle requested
SomeWriter(); // default constructible
void operator()(Handle handle, Packet::ptr packet); // insertion function
};
\endcode
*/
template <class Writer=PacketWriter>
class PassiveSocketWriter : public Module
{
public:
typedef typename Writer:Handle Handle; ///< Handle type requested by writer
connector::PassiveInput input; ///< Input connector from which data is received
ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Writer.
\param[in] handle Handle to write data to */
};
}}}
///////////////////////////////hh.e////////////////////////////////////////
//#include "SocketWriter.cci"
//#include "SocketWriter.ct"
//#include "SocketWriter.cti"
#endif
// Local Variables:
// mode: c++
// fill-column: 100
// c-file-style: "senf"
// indent-tabs-mode: nil
// ispell-local-dictionary: "american"
// compile-command: "scons -u test"