Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
command-setup.hpp
Go to the documentation of this file.
1 /*
2  COMMAND-INSTANCE-SETUP.hpp - Key abstraction for proc/edit operations and UNDO management
3 
4  Copyright (C) Lumiera.org
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
52 #ifndef CONTROL_COMMAND_SETUP_H
53 #define CONTROL_COMMAND_SETUP_H
54 
55 #include "lib/error.hpp"
56 #include "lib/nocopy.hpp"
57 #include "proc/control/command.hpp"
58 #include "lib/symbol.hpp"
59 
60 #include <functional>
61 #include <string>
62 
63 
64 
65 
66 namespace proc {
67 namespace control {
68 
69  using std::string;
70  using lib::Symbol;
71 
72  class CommandDef;
73 
74  using DefinitionClosure = std::function<void(CommandDef&)>;
75 
76 
77 
98  : util::Cloneable // copy-construction allowed, but no assignment
99  {
101 
102  public:
103  ~CommandSetup();
104  CommandSetup (Symbol cmdID);
105 
106  operator Symbol const&() const
107  {
108  return cmdID_;
109  }
110  operator string() const
111  {
112  return string{cmdID_};
113  }
114 
117 
119  static void invokeDefinitionClosures();
120 
122  static size_t pendingCnt();
123 
124  friend bool
125  operator== (CommandSetup const& left, CommandSetup const& right)
126  {
127  return left.cmdID_ == right.cmdID_;
128  }
129  friend bool
130  operator!= (CommandSetup const& left, CommandSetup const& right)
131  {
132  return left.cmdID_ != right.cmdID_;
133  }
134  };
135 
136 
137 
138 
144  #define COMMAND_DEFINITION(_NAME_) \
145  CommandSetup _NAME_ = CommandSetup{STRINGIFY(_NAME_)} = [&](CommandDef& def)
146 
147 
148 
149 }} // namespace proc::control
150 #endif /*CONTROL_COMMAND_SETUP_H*/
friend bool operator!=(CommandSetup const &left, CommandSetup const &right)
std::function< void(CommandDef &)> DefinitionClosure
static void invokeDefinitionClosures()
Token or Atom with distinct identity.
Definition: symbol.hpp:116
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Proc-Layer command frontend.
CommandSetup & operator=(DefinitionClosure)
core functionality: provide a command definition block.
Types marked with this mix-in may be created by copy-construction (or move construction), but may be not reassigned thereafter.
Definition: nocopy.hpp:91
Lumiera error handling (C++ interface).
static size_t pendingCnt()
diagnostics / test
CommandSetup(Symbol cmdID)
Start a command setup for defining a Proc-Layer command with the given cmdID.
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63
friend bool operator==(CommandSetup const &left, CommandSetup const &right)
Marker and Helper for writing Proc-Layer Command definitions.