switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Scheduler / ReadHelper.ih
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 internal header */
29
30 #ifndef IH_SENF_Scheduler_ReadHelper_
31 #define IH_SENF_Scheduler_ReadHelper_ 1
32
33 // Custom includes
34
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36
37 namespace senf {
38
39
40     /** \brief Abstract predicate interface
41         \internal
42      */
43     template <class Handle>
44     struct ReadHelper<Handle>::InternalPredicate
45     {
46         virtual ~InternalPredicate() {}
47
48         /** \brief template to runtime polymorphic barrier for the predicate interface
49             \internal
50
51             \implementation This class will provide a polymorphic
52                 wrapper around the non-polymorphic ReadHelper
53                 predicate. This is used, so the predicate can be
54                 specified as an arbitrary callable object (even a
55                 boost::function or a Boost.Lambda expression) without
56                 imposing any inheritance relationship on the predicate
57          */
58         template <class Predicate>
59         struct Dispatcher
60             : public ReadHelper<Handle>::InternalPredicate
61         {
62             Dispatcher(Predicate p) : predicate(p) {}
63             virtual std::string::size_type operator()(std::string const & data);
64             Predicate predicate;
65         };
66
67         virtual std::string::size_type operator()(std::string const & data) = 0;
68     };
69
70 }
71
72
73 //-/////////////////////////////////////////////////////////////////////////////////////////////////
74 #endif
75
76 \f
77 // Local Variables:
78 // mode: c++
79 // fill-column: 100
80 // c-file-style: "senf"
81 // indent-tabs-mode: nil
82 // ispell-local-dictionary: "american"
83 // compile-command: "scons -u test"
84 // comment-column: 40
85 // End: