Callback.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Callback inline template implementation */
16 
17 //#include "Callback.ih"
18 
19 // Custom includes
20 #include <boost/bind.hpp>
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::ppi::detail::Callback<Arg>
27 
28 template <class Arg>
29 template <class Owner, class FnClass>
30 prefix_ typename senf::ppi::detail::Callback<Arg>::type
31 senf::ppi::detail::Callback<Arg>::make(void (FnClass::* memfn )(), Owner & owner)
32 {
33  return boost::bind(memfn,static_cast<FnClass *>(&owner));
34 }
35 
36 template <class Arg>
37 template <class Owner, class FnClass, class FnArg>
38 prefix_ typename senf::ppi::detail::Callback<Arg>::type
39 senf::ppi::detail::Callback<Arg>::make(void (FnClass::* memfn )(FnArg arg), Owner & owner)
40 {
41  return boost::bind(memfn,static_cast<FnClass *>(&owner),_1);
42 }
43 
44 template <class Arg>
45 template <class Owner>
46 prefix_ typename senf::ppi::detail::Callback<Arg>::type
47 senf::ppi::detail::Callback<Arg>::make(type callable, Owner &)
48 {
49  return callable;
50 }
51 
52 template <class Arg>
53 template <class Owner>
54 prefix_ typename senf::ppi::detail::Callback<Arg>::type
55 senf::ppi::detail::Callback<Arg>::make(boost::function<void()> callable, Owner &)
56 {
57  return boost::bind(callable);
58 }
59 
60 //-/////////////////////////////////////////////////////////////////////////////////////////////////
61 // senf::ppi::detail::Callback<void>
62 
63 template <class Owner, class FnClass>
64 prefix_ typename senf::ppi::detail::Callback<void>::type
65 senf::ppi::detail::Callback<void>::make(void (FnClass::* memfn )(), Owner & owner)
66 {
67  return boost::bind(memfn,static_cast<FnClass *>(&owner));
68 }
69 
70 template <class Owner>
71 prefix_ typename senf::ppi::detail::Callback<void>::type
72 senf::ppi::detail::Callback<void>::make(type callable, Owner &)
73 {
74  return callable;
75 }
76 
77 //-/////////////////////////////////////////////////////////////////////////////////////////////////
78 #undef prefix_
79 
80 
81 // Local Variables:
82 // mode: c++
83 // fill-column: 100
84 // comment-column: 40
85 // c-file-style: "senf"
86 // indent-tabs-mode: nil
87 // ispell-local-dictionary: "american"
88 // compile-command: "scons -u ../test"
89 // End: