Lumiera  0.pre.03
»edit your freedom«
command-setup.hpp
Go to the documentation of this file.
1 /*
2  COMMAND-INSTANCE-SETUP.hpp - Key abstraction for steam/edit operations and UNDO management
3 
4  Copyright (C)
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
43 #ifndef CONTROL_COMMAND_SETUP_H
44 #define CONTROL_COMMAND_SETUP_H
45 
46 #include "lib/error.hpp"
47 #include "lib/nocopy.hpp"
49 #include "lib/symbol.hpp"
50 
51 #include <functional>
52 #include <string>
53 
54 
55 
56 
57 namespace steam {
58 namespace control {
59 
60  using std::string;
61  using lib::Symbol;
62 
63  class CommandDef;
64 
65  using DefinitionClosure = std::function<void(CommandDef&)>;
66 
67 
68 
89  : util::Cloneable // copy-construction allowed, but no assignment
90  {
91  Symbol cmdID_;
92 
93  public:
94  ~CommandSetup();
95  CommandSetup (Symbol cmdID);
96 
97  operator Symbol const&() const
98  {
99  return cmdID_;
100  }
101  operator string() const
102  {
103  return string{cmdID_};
104  }
105 
107  CommandSetup& operator= (DefinitionClosure);
108 
110  static void invokeDefinitionClosures();
111 
113  static size_t pendingCnt();
114 
115  friend bool
116  operator== (CommandSetup const& left, CommandSetup const& right)
117  {
118  return left.cmdID_ == right.cmdID_;
119  }
120  friend bool
121  operator!= (CommandSetup const& left, CommandSetup const& right)
122  {
123  return left.cmdID_ != right.cmdID_;
124  }
125  };
126 
127 
128 
129 
135  #define COMMAND_DEFINITION(_NAME_) \
136  CommandSetup _NAME_ = CommandSetup{STRINGIFY(_NAME_)} = [&](CommandDef& def)
137 
138 
139 
140 }} // namespace steam::control
141 #endif /*CONTROL_COMMAND_SETUP_H*/
Steam-Layer implementation namespace root.
CommandSetup & operator=(DefinitionClosure)
core functionality: provide a command definition block.
Marker and Helper for writing Steam-Layer Command definitions.
static size_t pendingCnt()
diagnostics / test
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Steam-Layer command frontend.
static void invokeDefinitionClosures()
Types marked with this mix-in may be duplicated by copy-construction, yet may not be moved or transfe...
Definition: nocopy.hpp:95
Lumiera error handling (C++ interface).
CommandSetup(Symbol cmdID)
Start a command setup for defining a Steam-Layer command with the given cmdID.