Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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.

Static Public Attributes

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

Public Member Functions

 ~CommandRegistry ()
 
void track (Symbol cmdID, Command const &commandHandle)
 register a command (Frontend) under the given ID.
 
bool remove (Symbol cmdID)
 remove the given command registration.
 
Command queryIndex (Symbol cmdID)
 query the command index by ID
 
Symbol findDefinition (Command const &cmdInstance) const
 search the command index for a definition
 
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
 
shared_ptr< CommandImplcreateCloneImpl (CommandImpl const &refObject)
 create an allocation for holding a clone of the given CommandImpl data.
 

Private Types

using CmdIndex = unordered_map< Symbol, Command, hash< Symbol > >
 
using ReverseIndex = map< const Command *, Symbol, order_by_impl >
 

Private Attributes

TypedAllocationManager allocator_
 
CmdIndex index_
 
ReverseIndex ridx_
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ ~CommandRegistry()

~CommandRegistry ( )
inline

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

References CommandRegistry::index_, CommandRegistry::index_size(), and CommandRegistry::ridx_.

+ Here is the call graph for this function:

Member Typedef Documentation

◆ CmdIndex

using CmdIndex = unordered_map<Symbol, Command, hash<Symbol> >
private

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

◆ ReverseIndex

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

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.

References CommandRegistry::index_, and CommandRegistry::ridx_.

Referenced by CommandRegistry_test::checkRegistration().

+ Here is the caller graph for this function:

◆ 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.

References CommandRegistry::index_, and CommandRegistry::ridx_.

Referenced by CommandRegistry_test::checkRegistration().

+ Here is the caller graph for this function:

◆ 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.

References CommandRegistry::index_.

Referenced by CommandRegistry_test::checkRegistration(), and Command::storeDef().

+ 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.

References Symbol::BOTTOM, and CommandRegistry::ridx_.

Referenced by CommandRegistry_test::checkRegistration().

+ Here is the caller graph for this function:

◆ index_size()

size_t index_size ( ) const
inline

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

References CommandRegistry::index_.

Referenced by CommandRegistry::~CommandRegistry(), CommandRegistry_test::checkRegistration(), and CommandRegistry_test::run().

+ Here is the caller graph for this function:

◆ instance_count()

size_t instance_count ( ) const
inline

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

References CommandRegistry::allocator_, and TypedAllocationManager::numSlots().

Referenced by CommandRegistry_test::checkAllocation(), CommandRegistry_test::checkRegistration(), CommandCloneBuilder_test::run(), CommandRegistry_test::run(), HandlingPatternBasics_test::run(), and HandlingPatternStandardImpl_test::run().

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

◆ 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.

References CommandRegistry::allocator_, and TypedAllocationManager::create().

Referenced by HandlingPatternBasics_test::buildTestCommand(), CommandCloneBuilder_test::buildTestImplFrame(), CommandRegistry_test::checkAllocation(), and UndoDefinition< SIG, MEM >::undoOperation().

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

◆ 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 CommandRegistry::allocator_, and TypedAllocationManager::create().

Referenced by CommandRegistry_test::checkAllocation(), Command::newInstance(), CommandCloneBuilder_test::run(), and Command::storeDef().

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

Member Data Documentation

◆ allocator_

◆ index_

◆ ridx_

◆ instance

+ Inheritance diagram for CommandRegistry:
+ Collaboration diagram for CommandRegistry:

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