4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief SocketSource non-inline template implementation */
31 //#include "SocketSource.ih"
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::ppi::DgramReader<Packet,MaxSize>
41 template <class Packet, unsigned MaxSize>
42 prefix_ Packet senf::ppi::DgramReader<Packet,MaxSize>::operator()(Handle & handle)
44 Packet packet (Packet::create(senf::noinit));
45 handle.read(packet.data(), MaxSize);
49 //-/////////////////////////////////////////////////////////////////////////////////////////////////
50 // senf::ppi::module::ActiveSocketSource<Reader>
52 template <class Reader>
53 prefix_ senf::ppi::module::ActiveSocketSource<Reader>::ActiveSocketSource()
55 registerEvent( event_, &ActiveSocketSource::read );
56 route(event_, output);
59 template <class Reader>
60 prefix_ senf::ppi::module::ActiveSocketSource<Reader>::ActiveSocketSource(Reader reader)
63 registerEvent( event_, &ActiveSocketSource::read );
64 route(event_, output);
67 template <class Reader>
68 prefix_ senf::ppi::module::ActiveSocketSource<Reader>::ActiveSocketSource(Handle const & handle)
69 : handle_(handle), event_(handle_, IOEvent::Read)
71 registerEvent( event_, &ActiveSocketSource::read );
72 route(event_, output);
75 template <class Reader>
76 prefix_ senf::ppi::module::ActiveSocketSource<Reader>::ActiveSocketSource(Handle const & handle,
78 : handle_(handle), event_(handle_, IOEvent::Read), reader_(reader)
80 registerEvent( event_, &ActiveSocketSource::read );
81 route(event_, output);
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 // senf::ppi::module::ActiveBurstSocketSource<Reader>
87 template <class Reader>
88 prefix_ senf::ppi::module::ActiveBurstSocketSource<Reader>::ActiveBurstSocketSource(unsigned max_burst)
89 : maxBurst_(max_burst)
91 registerEvent( event_, &ActiveBurstSocketSource::read );
92 route(event_, output);
95 template <class Reader>
96 prefix_ senf::ppi::module::ActiveBurstSocketSource<Reader>::ActiveBurstSocketSource(Reader reader, unsigned max_burst)
97 : reader_(reader), maxBurst_(maxBurst)
99 registerEvent( event_, &ActiveBurstSocketSource::read );
100 route(event_, output);
103 template <class Reader>
104 prefix_ senf::ppi::module::ActiveBurstSocketSource<Reader>::ActiveBurstSocketSource(Handle const & handle, unsigned max_burst)
105 : handle_(handle), event_(handle_, IOEvent::Read), maxBurst_(max_burst)
107 registerEvent( event_, &ActiveBurstSocketSource::read );
108 route(event_, output);
111 template <class Reader>
112 prefix_ senf::ppi::module::ActiveBurstSocketSource<Reader>::ActiveBurstSocketSource(Handle const & handle,
113 Reader reader, unsigned max_burst)
114 : handle_(handle), event_(handle_, IOEvent::Read), reader_(reader), maxBurst_(max_burst)
116 registerEvent( event_, &ActiveBurstSocketSource::read );
117 route(event_, output);
120 template <class Reader>
121 prefix_ void senf::ppi::module::ActiveBurstSocketSource<Reader>::maxBurst(unsigned max_burst)
123 maxBurst_ = max_burst;
126 template <class Reader>
127 prefix_ unsigned senf::ppi::module::ActiveBurstSocketSource<Reader>::maxBurst()
133 template <class Reader>
134 prefix_ void senf::ppi::module::ActiveBurstSocketSource<Reader>::read()
136 output(reader_(handle_));
137 for (unsigned int i = 0; i < maxBurst_; ++i) {
138 typename Reader::PacketType p (reader_(handle_));
139 if (p.data().size() > 0)
146 template <class Reader>
147 prefix_ void senf::ppi::module::ActiveBurstSocketSource<Reader>::flush()
151 typename Reader::PacketType p(reader_(handle_));
152 if (p.data().size() <= 0)
160 //-/////////////////////////////////////////////////////////////////////////////////////////////////
167 // comment-column: 40
168 // c-file-style: "senf"
169 // indent-tabs-mode: nil
170 // ispell-local-dictionary: "american"
171 // compile-command: "scons -u test"