switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / PPI / SocketSink.cti
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
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
10 //
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.
14 //
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.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
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.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief SocketSink inline template implementation */
30
31 //#include "SocketSink.ih"
32
33 // Custom includes
34
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::ppi::TargetDgramWriter<HandleType>
40
41 template <class HandleType>
42 prefix_ senf::ppi::TargetDgramWriter<HandleType>::TargetDgramWriter()
43 {}
44
45 template <class HandleType>
46 prefix_ senf::ppi::TargetDgramWriter<HandleType>::
47 TargetDgramWriter(typename Handle::Address const & target)
48 : target_ (target)
49 {}
50
51 template <class HandleType>
52 prefix_ typename senf::ppi::TargetDgramWriter<HandleType>::Handle::Address
53 senf::ppi::TargetDgramWriter<HandleType>::target()
54     const
55 {
56     return target_;
57 }
58
59 template <class HandleType>
60 prefix_ void
61 senf::ppi::TargetDgramWriter<HandleType>::target(typename Handle::Address const & target)
62 {
63     target_ = target;
64 }
65
66 template <class HandleType>
67 prefix_ bool senf::ppi::TargetDgramWriter<HandleType>::operator()(Handle & handle,
68                                                                   Packet const & packet)
69 {
70     if (target_)
71         return handle.writeto(target_, packet.data()) != packet.data().begin();
72     return false;
73 }
74
75 //-/////////////////////////////////////////////////////////////////////////////////////////////////
76 // senf::ppi::module::ActiveSocketSink<Writer>
77
78 template <class Writer>
79 prefix_ Writer & senf::ppi::module::ActiveSocketSink<Writer>::writer()
80 {
81     return writer_;
82 }
83
84 template <class Writer>
85 prefix_ typename senf::ppi::module::ActiveSocketSink<Writer>::Handle
86 senf::ppi::module::ActiveSocketSink<Writer>::handle()
87 {
88     return handle_;
89 }
90
91 template <class Writer>
92 prefix_ void senf::ppi::module::ActiveSocketSink<Writer>::handle(Handle const & handle)
93 {
94     handle_ = handle;
95     event_.set(handle_, IOEvent::Write);
96 }
97
98 //-/////////////////////////////////////////////////////////////////////////////////////////////////
99 // senf::ppi::module::PassiveSocketSink<Writer>
100
101 template <class Writer>
102 prefix_ Writer & senf::ppi::module::PassiveSocketSink<Writer>::writer()
103 {
104     return writer_;
105 }
106
107 template <class Writer>
108 prefix_ typename Writer::Handle & senf::ppi::module::PassiveSocketSink<Writer>::handle()
109 {
110     return handle_;
111 }
112
113 template <class Writer>
114 prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::handle(Handle const & handle)
115 {
116     handle_ = handle;
117     checkThrottle();
118 }
119
120 #ifndef DOXYGEN
121 template <class Writer>
122 prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::replaceHandle(Handle newHandle)
123 {
124     handle(newHandle);
125 }
126 #endif
127
128 //-/////////////////////////////////////////////////////////////////////////////////////////////////
129 #undef prefix_
130
131 \f
132 // Local Variables:
133 // mode: c++
134 // fill-column: 100
135 // comment-column: 40
136 // c-file-style: "senf"
137 // indent-tabs-mode: nil
138 // ispell-local-dictionary: "american"
139 // compile-command: "scons -u test"
140 // End: