3d6b9165fcd24b92117c1c0558fc515e3f838d93
[senf.git] / senf / Scheduler / ReadHelper.ih
1 // $Id$
2 //
3 // Copyright (C) 2006 Stefan Bund <g0dil@berlios.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the
17 // Free Software Foundation, Inc.,
18 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 // Copyright (C) 2006
20
21 /** \file
22     \brief ReadHelper internal header */
23
24 #ifndef IH_SENF_Scheduler_ReadHelper_
25 #define IH_SENF_Scheduler_ReadHelper_ 1
26
27 // Custom includes
28
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30
31 namespace senf {
32
33
34     /** \brief Abstract predicate interface
35         \internal
36      */
37     template <class Handle>
38     struct ReadHelper<Handle>::InternalPredicate
39     {
40         virtual ~InternalPredicate() {}
41
42         /** \brief template to runtime polymorphic barrier for the predicate interface
43             \internal
44
45             \implementation This class will provide a polymorphic
46                 wrapper around the non-polymorphic ReadHelper
47                 predicate. This is used, so the predicate can be
48                 specified as an arbitrary callable object (even a
49                 boost::function or a Boost.Lambda expression) without
50                 imposing any inheritance relationship on the predicate
51          */
52         template <class Predicate>
53         struct Dispatcher
54             : public ReadHelper<Handle>::InternalPredicate
55         {
56             Dispatcher(Predicate p) : predicate(p) {}
57             virtual std::string::size_type operator()(std::string const & data);
58             Predicate predicate;
59         };
60
61         virtual std::string::size_type operator()(std::string const & data) = 0;
62     };
63
64 }
65
66
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 #endif
69
70 \f
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // c-file-style: "senf"
75 // indent-tabs-mode: nil
76 // ispell-local-dictionary: "american"
77 // compile-command: "scons -u test"
78 // comment-column: 40
79 // End: