Lumiera  0.pre.03
»edit your freedom«
CommandSetup Class Reference

#include "steam/control/command-setup.hpp"

Description

Marker and Helper for writing Steam-Layer Command definitions.

Together with the Macro COMMAND_DEFINITION, such definitions may be written statically, in DSL-style:

  • statically define a variable of type CommandSetup, with external linkage
  • the ctor argument is what will be used as command-ID
  • assign a functor, function or lambda to this variable, with the signature void(CommandDef&)
  • the argument passed to this functor will be the CommandDef about to be configured and registered. Thus, the body of the functor should use the member functions of CommandDef to setup the command's operation, state capturing and undo functions.
  • behind the scenes, a lumiera::LifecycleHook is scheduled to run ON_GLOBAL_INIT. When this hook is activated, all the lambdas assigned to all CommandSetup instances thus far will be invoked one by one. Which causes all those commands actually to be defined and configured for use with the session subsystem.

Definition at line 97 of file command-setup.hpp.

Public Member Functions

 CommandSetup (Symbol cmdID)
 Start a command setup for defining a Steam-Layer command with the given cmdID. More...
 
 operator string () const
 
 operator Symbol const & () const
 
CommandSetupoperator= (DefinitionClosure)
 core functionality: provide a command definition block. More...
 

Static Public Member Functions

static void invokeDefinitionClosures ()
 
static size_t pendingCnt ()
 diagnostics / test
 

Friends

bool operator!= (CommandSetup const &left, CommandSetup const &right)
 
bool operator== (CommandSetup const &left, CommandSetup const &right)
 

Private Attributes

Symbol cmdID_
 

Additional Inherited Members

- Private Member Functions inherited from Cloneable
 Cloneable (Cloneable &&)=default
 
 Cloneable (Cloneable const &)=default
 
Cloneableoperator= (Cloneable &&)=delete
 
Cloneableoperator= (Cloneable const &)=delete
 

Constructor & Destructor Documentation

◆ CommandSetup()

CommandSetup ( Symbol  cmdID)

Start a command setup for defining a Steam-Layer command with the given cmdID.

Parameters
cmdIDthe ID under with the new command will be registered
Note
after defining a static variable of type CommandSetup, a functor or lambda should be assigned, which then provides the actual setup of the CommandDef

Definition at line 94 of file command-setup.cpp.

Member Function Documentation

◆ operator=()

CommandSetup & operator= ( DefinitionClosure  definitionBlock)

core functionality: provide a command definition block.

Parameters
definitionBlockanything assignable to function<void(CommandDef&)>
Remarks
this operation is intended for a very specific usage pattern, as established by the macro COMMAND_DEFINITION. The purpose is to feed a given code block into the hidden queue for command definitions, from where it will be issued at the lifecycle event ON_BASIC_INIT (typically at start of application main()). On invocation, the code block is provided with an still unbound CommandDef object, which has been registered under the Command-ID as stored in this CommandSetup object. The assumption is that this definition closure will care to define the command, state capturing and undo operations for the command definition in question. Thus, the result of invoking this closure will be to store a complete command prototype into the steam::control::CommandRegistry.
Note
this operation works by side-effect; the given argument is fed into a hidden static queue, but not stored within the object instance.
Warning
invoking this assignment several times on the same CommandSetup object will likely lead to an invalid state, causing the Lumiera application to fail on start-up. The reason for this is the fact that CommandDef rejects duplicate command definitions. Moreover, please note that invoking this operation at any point after the lifecycle event ON_BASIC_INIT will likely have no effect at all, since the given closure will then just sit in the static queue and never be invoked.

Definition at line 121 of file command-setup.cpp.

◆ invokeDefinitionClosures()

void invokeDefinitionClosures ( )
static

empty the definition queue and invoke definitions

Definition at line 139 of file command-setup.cpp.

+ Inheritance diagram for CommandSetup:
+ Collaboration diagram for CommandSetup:

The documentation for this class was generated from the following files: