Variables.ih
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 Variables internal header */
16 
17 #ifndef IH_SENF_Scheduler_Console_Variables_
18 #define IH_SENF_Scheduler_Console_Variables_ 1
19 
20 // Custom includes
21 #include <boost/function.hpp>
22 #include <boost/type_traits/is_const.hpp>
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 namespace console {
28 
29  template <class Variable> class ConstVariableAttributor;
30  template <class Variable> class VariableAttributor;
31 
32 namespace detail {
33 
34 #ifndef DOXYGEN
35 
36  template <class Variable>
37  struct QueryVariable
38  {
39  typedef Variable const & Signature ();
40  typedef boost::function<Signature> Function;
41  typedef detail::ParsedCommandTraits<Signature> Traits;
42  typedef detail::CreateParsedCommandOverload<Traits> CreateOverload;
43  typedef Variable const & result_type;
44 
45  QueryVariable(Variable const & var);
46 
47  static typename Traits::Overload::ptr create(Variable const & var);
48 
49  Variable const & operator()() const;
50 
51  Variable const & var_;
52  };
53 
54  template <class Variable>
55  struct SetVariable
56  {
57  typedef void Signature (Variable &);
58  typedef boost::function<Signature> Function;
59  typedef detail::ParsedCommandTraits<Signature> Traits;
60  typedef detail::CreateParsedCommandOverload<Traits> CreateOverload;
61  typedef boost::function<void (Variable const &)> OnChangeHandler;
62  typedef void result_type;
63 
64  SetVariable(Variable & var, OnChangeHandler handler = OnChangeHandler());
65 
66  static typename Traits::Overload::ptr create(Variable & var);
67 
68  void operator()(Variable const & value) const;
69 
70  Variable & var_;
71  OnChangeHandler handler_;
72  };
73 
74 #endif
75 
76 }}}
77 
78 //-/////////////////////////////////////////////////////////////////////////////////////////////////
79 #endif
80 
81 
82 // Local Variables:
83 // mode: c++
84 // fill-column: 100
85 // comment-column: 40
86 // c-file-style: "senf"
87 // indent-tabs-mode: nil
88 // ispell-local-dictionary: "american"
89 // compile-command: "scons -u test"
90 // End: