Lumiera  0.pre.03
command-registry.hpp File Reference

Go to the source code of this file.


Managing command definitions and the storage of individual command objects.

The CommandRegistry is an singleton object, accessible only at the implementation level of control::Command (note: CommandImpl isn't tied to the registry). For the other parts of the command system, it provides all "get me this command object"-services. Actually, these can be decomposed into two distinct parts:

  • allocation of CommandImpl frames and argument holders, which is delegated to the TypedAllocationManager
  • maintaining an index to find pre-built command definitions (prototypes)

Services during command lifecycle

Each command starts out as command definition, accessed by client code through CommandDef. While collecting the necessary parts of such a definition, there is just an empty (pending) Command (smart-ptr frontend), which is not yet usable, being held within the CommandDef. When the definition is complete, a CommandImpl frame is allocated, configured and used to activate the Command (smart-ptr frontend), at which point it also gets accessible through the CommandRegistry.

Later on, client code is assumed to re-access the command by ID. It may bind arguments, which are stored in the already allocated StorageHolder. (–>Ticket #269). As the Command frontend is a smart-ptr, commands may be copied, stored away and passed on. When finally the ref-count of a given definition goes to zero, de-allocation happens automatically. This can't happen for a registered command definition though, as a Command instance is stored within the index table, keeping the linked data alive. Thus, any registered commands will remain in memory until de-registered explicitly, or until application shutdown.

See also

Definition in file command-registry.hpp.

#include "lib/error.hpp"
#include "lib/depend.hpp"
#include "lib/sync.hpp"
#include "include/logging.h"
#include "lib/nocopy.hpp"
#include "lib/util.hpp"
#include "proc/control/command.hpp"
#include "proc/control/command-signature.hpp"
#include "proc/control/command-storage-holder.hpp"
#include "lib/typed-allocation-manager.hpp"
#include <boost/functional/hash.hpp>
#include <unordered_map>
#include <memory>
#include <string>
#include <map>


class  CommandRegistry
 Registry managing command implementation objects (Singleton). More...
struct  order_by_impl
 Helper for building a std::map with Command* as keys. More...


 Proc-Layer implementation namespace root.
 Proc-Layer dispatcher, controller and administrative facilities.