switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Scheduler / ReadHelper.cti
1 // $Id$
2 //
3 // Copyright (C) 2006 Stefan Bund <g0dil@berlios.de>
4 //
5 // The contents of this file are subject to the Fraunhofer FOKUS Public License
6 // Version 1.0 (the "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at 
8 // http://senf.berlios.de/license.html
9 //
10 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
11 // but modifies the Mozilla Public License Version 1.1.
12 // See the full license text for the amendments.
13 //
14 // Software distributed under the License is distributed on an "AS IS" basis, 
15 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
16 // for the specific language governing rights and limitations under the License.
17 //
18 // The Original Code is Fraunhofer FOKUS code.
19 //
20 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
21 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
22 // All Rights Reserved.
23 //
24 // Contributor(s):
25
26 // Copyright (C) 2006
27 /** \file
28     \brief ReadHelper inline template implementation */
29
30 #include "ReadHelper.ih"
31
32 // Custom includes
33 #include <senf/Utils/Exception.hh>
34
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 template <class Handle>
39 prefix_ typename senf::ReadHelper<Handle>::ptr
40 senf::ReadHelper<Handle>::dispatch(Handle handle, std::string::size_type maxSize,
41                                           Callback callback)
42 {
43     return ptr(new ReadHelper(handle, maxSize, 0, callback));
44 }
45
46 template <class Handle>
47 template <class Predicate>
48 prefix_ typename senf::ReadHelper<Handle>::ptr
49 senf::ReadHelper<Handle>::dispatch(Handle handle, std::string::size_type maxSize,
50                                    Predicate const & predicate, Callback callback)
51 {
52     return ptr(new ReadHelper(handle, maxSize,
53                               new typename InternalPredicate::template Dispatcher<Predicate>(predicate),
54                               callback));
55 }
56
57 template <class Handle>
58 prefix_ Handle senf::ReadHelper<Handle>::handle()
59     const
60 {
61     return handle_;
62 }
63
64 template <class Handle>
65 prefix_ std::string::size_type senf::ReadHelper<Handle>::maxSize()
66     const
67 {
68     return maxSize_;
69 }
70
71 template <class Handle>
72 prefix_ std::string const & senf::ReadHelper<Handle>::data()
73     const
74 {
75     return data_;
76 }
77
78 template <class Handle>
79 prefix_ std::string const & senf::ReadHelper<Handle>::tail()
80     const
81 {
82     return tail_;
83 }
84
85 template <class Handle>
86 prefix_ bool senf::ReadHelper<Handle>::complete()
87     const
88 {
89     return complete_;
90 }
91
92 template <class Handle>
93 prefix_ bool senf::ReadHelper<Handle>::error()
94     const
95 {
96     return errno_ != 0;
97 }
98
99 template <class Handle>
100 prefix_ void senf::ReadHelper<Handle>::throw_error()
101     const
102 {
103     if (errno_ != 0) throw SystemException(errno_ SENF_EXC_DEBUGINFO);
104 }
105
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 #undef prefix_
108
109 \f
110 // Local Variables:
111 // mode: c++
112 // fill-column: 100
113 // c-file-style: "senf"
114 // indent-tabs-mode: nil
115 // ispell-local-dictionary: "american"
116 // compile-command: "scons -u test"
117 // comment-column: 40
118 // End: