Bayeux  3.4.1
Core Foundation library for SuperNEMO
reflective_command.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2016 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of datatools.
7 //
8 // datatools is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // datatools is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with datatools. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef DATATOOLS_UI_REFLECTIVE_COMMAND_H
22 #define DATATOOLS_UI_REFLECTIVE_COMMAND_H
23 
24 // Third Party:
25 // - Camp:
26 #include <camp/function.hpp>
27 #include <camp/value.hpp>
28 
29 // This project:
30 #include <datatools/ui/utils.h>
34 
35 namespace datatools {
36 
37  namespace ui {
38 
40  template <typename Type>
42  : public target_command<Type>
43  {
44  public:
45 
48 
50  reflective_command(Type & target_,
51  const std::string & func_name_,
52  const std::string & name_ = "",
53  const std::string & description_ = "",
54  const version_id & vid_ = version_id::invalid());
55 
57  virtual ~reflective_command();
58 
60  void set_func_name(const std::string & func_name_);
61 
62  static void repr(std::ostream & out_,
63  const camp::Value & value_,
65 
66  protected:
67 
68  virtual void _init(const datatools::properties & config_);
69 
70  virtual void _run(datatools::command::returned_info & cri_,
71  uint32_t flags_ = 0);
72 
73  virtual void _fini();
74 
75  private:
76 
77  std::string _func_name_;
79  const camp::Function * _func_ = nullptr;
80 
81  };
82 
83  } // namespace ui
84 
85 } // namespace datatools
86 
88 
89 #endif // DATATOOLS_UI_REFLECTIVE_COMMAND_H
90 
91 // Local Variables: --
92 // mode: c++ --
93 // c-file-style: "gnu" --
94 // tab-width: 2 --
95 // End: --
Description of a method.
Definition: method.h:45
Description of a method argument.
Definition: argument.h:46
Description of a method or function.
static void repr(std::ostream &out_, const camp::Value &value_, const datatools::introspection::argument &arg_)
Definition: reflective_command-inl.h:333
virtual void _init(const datatools::properties &config_)
Definition: reflective_command-inl.h:76
static const version_id & invalid()
Return an invalid version identifier.
virtual void _fini()
Definition: reflective_command-inl.h:281
Command returned information.
Definition: command_utils.h:78
virtual void _run(datatools::command::returned_info &cri_, uint32_t flags_=0)
Definition: reflective_command-inl.h:292
Utilities.
virtual ~reflective_command()
Destructor.
Definition: reflective_command-inl.h:60
Base command for target objects.
void set_func_name(const std::string &func_name_)
Set the function name.
Definition: reflective_command-inl.h:69
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Base command for a target object.
Definition: target_command.h:38
reflective_command()
Default constructor.
Definition: reflective_command-inl.h:39
A class representing a version ID :
Definition: version_id.h:67
Reflective command for a target object.
Definition: reflective_command.h:41
A dictionary of arbitrary properties.
Definition: properties.h:125