49 #ifndef CONTROL_COMMAND_REGISTRY_H 50 #define CONTROL_COMMAND_REGISTRY_H 64 #include <boost/functional/hash.hpp> 65 #include <unordered_map> 77 using std::unordered_map;
97 || ( pC1 && pC2 && (*pC1 < *pC2));
114 typedef unordered_map<Symbol, Command, hash<Symbol>> CmdIndex;
115 typedef map< const Command*, Symbol, order_by_impl> ReverseIndex;
128 if (0 < index_size())
129 TRACE (command,
"Shutting down Command system...");
147 REQUIRE (commandHandle);
148 if (contains (index_,cmdID) || contains(ridx_, &commandHandle))
149 commandHandle.duplicate_detected(cmdID);
151 Command& indexSlot = index_[cmdID];
152 indexSlot = commandHandle;
153 ridx_[&indexSlot] = cmdID;
155 ENSURE (contains(ridx_, &indexSlot));
156 ENSURE (contains(index_, cmdID));
169 bool actually_remove = contains (index_,cmdID);
172 ridx_.erase(& index_[cmdID]);
175 ENSURE (!contains (index_,cmdID));
176 return actually_remove;
192 return getValue_or_default (index_, cmdID,
Command() );
204 return getValue_or_default (ridx_, &cmdInstance, Symbol::BOTTOM );
211 return index_.size();
216 instance_count()
const 227 template<
typename SIG_OPER
233 ,function<SIG_CAPT>& captFunctor
234 ,function<SIG_UNDO>& undoFunctor)
239 typedef typename UndoSignature<SIG_CAPT>::Memento Mem;
244 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.