58 #ifndef CONTROL_COMMAND_REGISTRY_H 59 #define CONTROL_COMMAND_REGISTRY_H 73 #include <boost/functional/hash.hpp> 74 #include <unordered_map> 86 using std::unordered_map;
106 || ( pC1 && pC2 && (*pC1 < *pC2));
123 typedef unordered_map<Symbol, Command, hash<Symbol>> CmdIndex;
124 typedef map< const Command*, Symbol, order_by_impl> ReverseIndex;
137 if (0 < index_size())
138 TRACE (command,
"Shutting down Command system...");
156 REQUIRE (commandHandle);
157 if (contains (index_,cmdID) || contains(ridx_, &commandHandle))
158 commandHandle.duplicate_detected(cmdID);
160 Command& indexSlot = index_[cmdID];
161 indexSlot = commandHandle;
162 ridx_[&indexSlot] = cmdID;
164 ENSURE (contains(ridx_, &indexSlot));
165 ENSURE (contains(index_, cmdID));
178 bool actually_remove = contains (index_,cmdID);
181 ridx_.erase(& index_[cmdID]);
184 ENSURE (!contains (index_,cmdID));
185 return actually_remove;
201 return getValue_or_default (index_, cmdID,
Command() );
213 return getValue_or_default (ridx_, &cmdInstance, Symbol::BOTTOM );
220 return index_.size();
225 instance_count()
const 236 template<
typename SIG_OPER
242 ,function<SIG_CAPT>& captFunctor
243 ,function<SIG_UNDO>& undoFunctor)
248 typedef typename UndoSignature<SIG_CAPT>::Memento Mem;
253 return allocator_.create<
CommandImpl> (pArg, operFunctor,captFunctor,undoFunctor);
Facility for monitor object based locking.
Helper for building a std::map with Command* as keys.
Abstract foundation for building custom allocation managers.
shared_ptr< CommandImpl > newCommandImpl(function< SIG_OPER > &operFunctor, function< SIG_CAPT > &captFunctor, function< SIG_UNDO > &undoFunctor)
set up a new command implementation frame
Any copy and copy construction prohibited.
This header is for including and configuring NoBug.
Registry managing command implementation objects (Singleton).
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Symbol findDefinition(Command const &cmdInstance) const
search the command index for a definition
Object Monitor based synchronisation.
Token or Atom with distinct identity.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Command queryIndex(Symbol cmdID)
query the command index by ID
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Steam-Layer command frontend.
Singleton services and Dependency Injection.
Foundation for a custom allocation manager, tracking the created objects by smart-ptrs.
MAP::mapped_type getValue_or_default(MAP &map, typename MAP::key_type const &key, typename MAP::mapped_type defaultVal)
fetch value from a Map, or return a default if not found
Lumiera error handling (C++ interface).
Handle object representing a single Command instance to be used by client code.
Steam-Layer Command implementation.
void track(Symbol cmdID, Command const &commandHandle)
register a command (Frontend) under the given ID.
Metaprogramming helpers for deriving the precise function signatures necessary to implement a given c...
This is "the" top level CmdClosure implementation.
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
static lib::Depend< CommandRegistry > instance
storage for the singleton factory used to access CommandRegistry
A passive container record holding the actual command arguments & UNDO state.