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

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

Description

Registry managing command implementation objects (Singleton).

Relies on TypedAllocationManager for pooled custom allocation (TODO: not implemented as of 9/09) Registered command (definitions) are accessible by command ID; as this mapping is bidirectional, it is also possible to find out the ID for a given command.

Definition at line 109 of file command-registry.hpp.

Public Member Functions

shared_ptr< CommandImplcreateCloneImpl (CommandImpl const &refObject)
 create an allocation for holding a clone of the given CommandImpl data. More...
 
Symbol findDefinition (Command const &cmdInstance) const
 search the command index for a definition More...
 
size_t index_size () const
 
size_t instance_count () const
 
template<typename SIG_OPER , typename SIG_CAPT , typename SIG_UNDO >
shared_ptr< CommandImplnewCommandImpl (function< SIG_OPER > &operFunctor, function< SIG_CAPT > &captFunctor, function< SIG_UNDO > &undoFunctor)
 set up a new command implementation frame More...
 
Command queryIndex (Symbol cmdID)
 query the command index by ID More...
 
bool remove (Symbol cmdID)
 remove the given command registration. More...
 
void track (Symbol cmdID, Command const &commandHandle)
 register a command (Frontend) under the given ID. More...
 

Static Public Attributes

static lib::Depend< CommandRegistryinstance
 storage for the singleton factory used to access CommandRegistry
 

Private Types

typedef unordered_map< Symbol, Command, hash< Symbol > > CmdIndex
 
typedef map< const Command *, Symbol, order_by_implReverseIndex
 

Private Attributes

TypedAllocationManager allocator_
 
CmdIndex index_
 
ReverseIndex ridx_
 

Additional Inherited Members

- Static Public Member Functions inherited from Sync<>
static MonitorgetMonitor (Sync const *forThis)
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Member Function Documentation

◆ track()

void track ( Symbol  cmdID,
Command const &  commandHandle 
)
inline

register a command (Frontend) under the given ID.

Exceptions
error::Logicwhen a registration already exists, either under this ID or for the same concrete implementation record but with a different ID.

Definition at line 143 of file command-registry.hpp.

◆ remove()

bool remove ( Symbol  cmdID)
inline

remove the given command registration.

Returns
true if actually removed an entry
Note
existing command instances remain valid; storage will be freed at zero use-count

Definition at line 165 of file command-registry.hpp.

◆ queryIndex()

Command queryIndex ( Symbol  cmdID)
inline

query the command index by ID

Returns
the registered command, or an "invalid" token
Remarks
this function deliberately returns by-value. Returning a reference into the global CommandRegistry would be dangerous under concurrent access, since the lock is only acquired within this function's body.

Definition at line 189 of file command-registry.hpp.

Referenced by CommandRegistry_test::checkRegistration().

+ Here is the caller graph for this function:

◆ findDefinition()

Symbol findDefinition ( Command const &  cmdInstance) const
inline

search the command index for a definition

Parameters
cmdInstanceusing the definition to look up
Returns
the ID used to register this definition or NULL in case of an "anonymous" command

Definition at line 201 of file command-registry.hpp.

◆ newCommandImpl()

shared_ptr<CommandImpl> newCommandImpl ( function< SIG_OPER > &  operFunctor,
function< SIG_CAPT > &  captFunctor,
function< SIG_UNDO > &  undoFunctor 
)
inline

set up a new command implementation frame

Returns
shared-ptr owning a newly created CommandImpl, allocated through the registry and wired internally to invoke TypedAllocationManager::destroyElement for cleanup.

Definition at line 232 of file command-registry.hpp.

◆ createCloneImpl()

shared_ptr< CommandImpl > createCloneImpl ( CommandImpl const &  refObject)

create an allocation for holding a clone of the given CommandImpl data.

This is a tricky operation, as the CommandImpl after construction erases the specific type information pertaining the StorageHolder. But this specific type information is vital for determining the exact allocation size for the clone StorageHolder. The only solution is to delegate the cloning of the arguments down into the StorageHolder, passing a reference to the memory manager for allocating the clone. Actually, we perform this operation through the help of a visitor, which re-gains the complete type context and prepares the necessary clone objects; in a final step, we allocate a new CommandImpl frame and initialise it with the prepared clone objects.

See also
command.cpp (implementation)
Note
this bit of implementation from CommandRegistry rather heavily relies on implementation details from CommandImpl and the help of CommandImplCloneBuilder and StorageHolder. It's implemented within command.cpp to keep the includes of the handling patterns clean.

Definition at line 219 of file command.cpp.

References CommandImplCloneBuilder::clonedClosuere(), CommandImplCloneBuilder::clonedUndoMutation(), and CommandImpl::prepareClone().

+ Here is the call graph for this function:
+ Inheritance diagram for CommandRegistry:
+ Collaboration diagram for CommandRegistry:

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