63 std::deque<CmdDefEntry>&
115 throw error::Invalid (
"unbound function/closure provided for CommandSetup"
116 ,
LERR_(BOTTOM_VALUE));
126 return pendingCmdDefinitions().size();
132 while (
not pendingCmdDefinitions().empty())
134 CmdDefEntry& entry = pendingCmdDefinitions().back();
141 pendingCmdDefinitions().pop_back();
162 : dispatcher_{dispatcher}
163 , table_{2 *
Command::definition_count()}
178 throw new error::Logic (
_Fmt{
"Attempt to create a new Command instance '%s', "
179 "while an instance for this invocationID %s "
180 "is currently open for parametrisation and "
181 "not yet dispatched for execution."}
183 ,
LERR_(DUPLICATE_COMMAND)
187 ENSURE (instance,
"cloning of command prototype failed");
207 auto entry =
table_.find(instanceID);
208 if (entry ==
table_.end())
210 if (
not entry->second)
211 throw error::Logic (
_Fmt{
"Command instance '%s' is not (yet/anymore) active"}
214 return entry->second;
229 auto entry =
table_.find(instanceID);
230 if (entry ==
table_.end())
232 "globally registered command definition, "
233 "nor to an previously opened command instance")
235 ,
LERR_(INVALID_COMMAND));
236 if (
not entry->second.isValid())
237 throw error::Logic (
_Fmt{
"Command instance '%s' is not (yet/anymore) active"}
241 instance = move(entry->second);
245 "without binding all arguments properly beforehand"}
247 ,
LERR_(UNBOUND_ARGUMENTS));
297 instance.bindArg (
argSeq);
298 ENSURE (instance.canExec());
307 and unConst(
this)->table_[instanceID].isValid();
Token or Atom with distinct identity.
define and register a callback for a specific lifecycle event.
Helper class used solely for defining a Command-Object.
Interface of a service to perform Commands on the session.
virtual void enqueue(Command &&)=0
bool contains(Symbol instanceID) const
Command getInstance(Symbol instanceID)
access the currently "opened" instance with the given instanceID
void bindAndDispatch(Symbol instanceID, Rec const &argSeq)
fire and forget anonymous command instance.
CommandInstanceManager(CommandDispatch &)
create a CommandInstanceManager and wire it with the given CommandDispatch implementation.
void handOver(Command &&)
void dispatch(Symbol instanceID)
hand over the designated command instance to the dispatcher installed on construction.
CommandDispatch & dispatcher_
~CommandInstanceManager()
std::unordered_map< Symbol, Command > table_
Command getCloneOrInstance(Symbol, bool)
Symbol newInstance(Symbol prototypeID, string const &invocationID)
Create and thus "open" a new anonymous command instance.
Marker and Helper for writing Steam-Layer Command definitions.
CommandSetup & operator=(DefinitionClosure)
core functionality: provide a command definition block.
static size_t pendingCnt()
diagnostics / test
CommandSetup(Symbol cmdID)
Start a command setup for defining a Steam-Layer command with the given cmdID.
static void invokeDefinitionClosures()
Handle object representing a single Command instance to be used by client code.
static Command maybeGetNewInstance(Symbol cmdID)
try to access an existing command definition and immediately create a new clone copy by calling newIn...
static Command get(Symbol cmdID)
Access existing command for use.
A front-end for using printf-style formatting.
Actually defining a command and binding it to execution parameters.
Service to support forming and invocation of command instances for use by the UI.
Provision for setup of concrete commands for use by the UI.
Steam-Layer command frontend.
Lumiera error handling (C++ interface).
Installing and invoking of application lifecycle event callbacks.
This header is for including and configuring NoBug.
LumieraError< LERR_(STATE)> State
LumieraError< LERR_(LOGIC)> Logic
LumieraError< LERR_(INVALID)> Invalid
CStr ON_GLOBAL_INIT
to be triggered in main()
LifecycleHook schedule_(ON_GLOBAL_INIT, &CommandSetup::invokeDefinitionClosures)
std::tuple< Symbol, DefinitionClosure > CmdDefEntry
std::deque< CmdDefEntry > & pendingCmdDefinitions()
std::function< void(CommandDef &)> DefinitionClosure
Steam-Layer implementation namespace root.
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...