Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
CommandDef Class Reference

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

Description

Helper class used solely for defining a Command-Object.

This technique is known as "fluent API", see https://en.wikipedia.org/wiki/Fluent_interface The basic idea is for the user to create a disposable instance of this definition helper, only for calling a chain of definition functions, which internally build the actual Command object. Finally, the created Command object will be stored into a registry or handed over to the SteamDispatcher. To give an example:

CommandDefinition ("test.command1")
.operation (command1::operate) // provide the function to be executed as command
.captureUndo (command1::capture) // provide the function capturing Undo state
.undoOperation (command1::undoIt) // provide the function which might undo the command
.bind (obj, randVal) // bind to the actual command parameters
.executeSync(); // convenience call, forwarding the Command to dispatch.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87

Definition at line 265 of file command-def.hpp.

Public Member Functions

 CommandDef (Symbol cmdID)
 
 ~CommandDef ()
 when starting a CommandDef, we immediately place a yet empty Command object into the index, just assuming it will be defined properly and consequently get valid at some point.
 
template<typename FUN >
auto operation (FUN operation_to_define)
 
 operator bool () const
 
bool isValid () const
 is this a valid command definition? especially.
 

Private Types

using PImpl = stage::ImplInstance
 
using Activation = stage::Activation
 

Private Member Functions

Commandactivate (PImpl &&completedDef)
 callback from completed command definition stage: "arm up" the command handle object and register it with the CommandRegistry.
 
- Private Member Functions inherited from NonCopyable
 ~NonCopyable ()=default
 
 NonCopyable ()=default
 
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

Symbol id_
 
Command prototype_
 

Constructor & Destructor Documentation

◆ CommandDef()

CommandDef ( Symbol  cmdID)
inline

Definition at line 275 of file command-def.hpp.

References Literal::c().

+ Here is the call graph for this function:

◆ ~CommandDef()

~CommandDef ( )

when starting a CommandDef, we immediately place a yet empty Command object into the index, just assuming it will be defined properly and consequently get valid at some point.

But in case this doesn't happen (e.g. because the definition is aborted), we need to clean up this empty pre-registration...

Definition at line 326 of file command.cpp.

References CommandDef::id_, CommandRegistry::instance, CommandDef::prototype_, and Command::remove().

+ Here is the call graph for this function:

Member Typedef Documentation

◆ PImpl

Definition at line 271 of file command-def.hpp.

◆ Activation

Definition at line 272 of file command-def.hpp.

Member Function Documentation

◆ operation()

template<typename FUN >
auto operation ( FUN  operation_to_define)
inline

Definition at line 288 of file command-def.hpp.

References CommandDef::activate().

Referenced by CommandQueue_test::CommandQueue_test(), SessionCommandFunction_test::SessionCommandFunction_test(), CommandUse1_test::allInOneStep(), CommandUse1_test::definePrototype(), AbstractTangible_test::invokeCommand(), CommandBasic_test::run(), CommandEquality_test::run(), CommandMessageBinding_test::run(), CommandRegistry_test::run(), CommandUse2_test::run(), CommandUse3_test::run(), CommandUse1_test::standardUse(), CommandUse1_test::stringRepresentation(), and CommandBinding_test::zeroArgumentCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator bool()

operator bool ( ) const
inlineexplicit

Definition at line 299 of file command-def.hpp.

References CommandDef::isValid().

+ Here is the call graph for this function:

◆ isValid()

bool isValid ( ) const

is this a valid command definition? especially.

  • the prototype command is initialised properly
  • there is a command definition registered for our command ID
  • and the registered command uses the same underlying command impl record than our prototype

Definition at line 340 of file command.cpp.

References CommandDef::id_, and CommandDef::prototype_.

Referenced by CommandDef::operator bool().

+ Here is the caller graph for this function:

◆ activate()

Command & activate ( PImpl &&  completedDef)
inlineprivate

callback from completed command definition stage: "arm up" the command handle object and register it with the CommandRegistry.


Definition at line 308 of file command-def.hpp.

References Command::activate(), CommandDef::id_, and CommandDef::prototype_.

Referenced by CommandDef::operation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ id_

Symbol id_
private

◆ prototype_

Command prototype_
private
+ Inheritance diagram for CommandDef:
+ Collaboration diagram for CommandDef:

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