Lumiera  0.pre.03
»edit your freedom«
command-setup.hpp File Reference

Go to the source code of this file.

Description

Provision for setup of concrete commands for use by the UI.

A Steam-Layer command is a functor, which can be parametrised with actual arguments. It needs to be defined beforehand, which means to establish an unique name and to supply three functions, one for the actual command operation, one to capture state and one to undo the effect of the command invocation. CommandSetup allows to create series of such definitions with minimal effort. Since any access and mutation from the UI into the Session data must be performed by invoking such commands, a huge amount of individual command definitions need to be written eventually.

The macro COMMAND_DEFINITION(NAME) allows to introduce a new definition with a single line, followed by a code block, which actually ends up as the body of a lambda function, and receives the bare CommandDef as single argument with name cmd. The _NAME_ argument of the macro ends up both stringified as the value of the command-ID, and as an variable holding a new CommandSetup instance. It is assumed that a header with corresponding declarations (the header cmd.hpp) is included by all UI elements actually to use, handle and invoke commands towards the session-command-facade.h

See also
command-def.hpp
command.hpp
CommandSetup_test
cmd.hpp
cmd-context.hpp

Definition in file command-setup.hpp.

#include "lib/error.hpp"
#include "lib/nocopy.hpp"
#include "steam/control/command.hpp"
#include "lib/symbol.hpp"
#include <functional>
#include <string>

Classes

class  CommandSetup
 Marker and Helper for writing Steam-Layer Command definitions. More...
 

Typedefs

using DefinitionClosure = std::function< void(CommandDef &)>
 

Macros

#define COMMAND_DEFINITION(_NAME_)   CommandSetup _NAME_ = CommandSetup{STRINGIFY(_NAME_)} = [&](CommandDef& def)
 Macro to write command definitions in a compact form. More...
 

Namespaces

 steam
 Steam-Layer implementation namespace root.
 
 steam::control
 Steam-Layer dispatcher, controller and administrative facilities.
 

Macro Definition Documentation

◆ COMMAND_DEFINITION

#define COMMAND_DEFINITION (   _NAME_)    CommandSetup _NAME_ = CommandSetup{STRINGIFY(_NAME_)} = [&](CommandDef& def)

Macro to write command definitions in a compact form.

On expansion, a variable of type CommandSetup will be defined in the current scope, and immediately be assigned by a lambda, whose body is what follows the macro invocation

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