Lumiera  0.pre.03
»edit your freedom«
command-instance-manager.hpp
Go to the documentation of this file.
1 /*
2  COMMAND-INSTANCE-MANAGER.hpp - Service to manage command instances for actual invocation
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 
57 #ifndef CONTROL_COMMAND_INSTANCE_MANAGER_H
58 #define CONTROL_COMMAND_INSTANCE_MANAGER_H
59 
60 #include "lib/error.hpp"
61 #include "lib/nocopy.hpp"
64 #include "lib/diff/gen-node.hpp"
65 #include "lib/symbol.hpp"
66 
67 #include <unordered_map>
68 #include <string>
69 
70 
71 
72 namespace steam {
73 namespace control {
74 
75  using std::string;
76  using lib::Symbol;
77  using lib::diff::Rec;
78 
79 
101  {
102  CommandDispatch& dispatcher_;
103  std::unordered_map<Symbol,Command> table_;
104 
105  public:
108 
109  Symbol newInstance (Symbol prototypeID, string const& invocationID);
110  Command getInstance(Symbol instanceID);
111  void dispatch (Symbol instanceID);
112  void bindAndDispatch (Symbol instanceID, Rec const& argSeq);
113 
114  bool contains (Symbol instanceID) const;
115 
116  private:
118  void handOver (Command&&);
119  };
120 
121 
122 
123 }} // namespace steam::control
124 #endif /*CONTROL_COMMAND_INSTANCE_MANAGER_H*/
Symbol newInstance(Symbol prototypeID, string const &invocationID)
Create and thus "open" a new anonymous command instance.
Interface to abstract the SteamDispatcher&#39;s ability to handle command messages.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
Maintain a current command instance for parametrisation.
Steam-Layer implementation namespace root.
Command getInstance(Symbol instanceID)
access the currently "opened" instance with the given instanceID
Token or Atom with distinct identity.
Definition: symbol.hpp:126
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
Interface of a service to perform Commands on the session.
Generic building block for tree shaped (meta)data structures.
Steam-Layer command frontend.
Lumiera error handling (C++ interface).
Handle object representing a single Command instance to be used by client code.
Definition: command.hpp:124
void bindAndDispatch(Symbol instanceID, Rec const &argSeq)
fire and forget anonymous command instance.
void dispatch(Symbol instanceID)
hand over the designated command instance to the dispatcher installed on construction.
object-like record of data.
Definition: record.hpp:150
CommandInstanceManager(CommandDispatch &)
create a CommandInstanceManager and wire it with the given CommandDispatch implementation.