WIP: considerations for a store-as (clone) operation

This commit is contained in:
Fischlurch 2009-08-06 18:00:19 +02:00
parent a677e2edde
commit 09a594d2c5
4 changed files with 37 additions and 3 deletions

View file

@ -111,6 +111,17 @@ namespace control {
~CommandImpl();
/** cloning service for the CommandRegistry:
* effectively this is a placement-copy ctor,
* requiring a sufficient amount of storage for
* holding the clone to be already allocated */
CommandImpl (CommandImpl const& orig, void* paramStorage)
: do_(orig.do_)
, undo_(orig.undo_)
, pClo_(orig.pClo_->createClone(paramStorage)) ///////////////////TODO should pass in a callback/interface for allocations instead
{ }
/** core operation: invoke the command
* @param execPattern describes the individual steps
* necessary to get this command invoked properly

View file

@ -171,6 +171,21 @@ namespace control {
static void killCommandImpl (CommandImpl* entry) { kill(entry); }
/** create an allocation for holding a clone of the given CommandImpl data.
* @todo this is a tricky and problematic operation, as the CommandImpl
* erases the specific type information pertaining the ArgumentHolder.
* But this specific type information is vital for determining the
* exact allocation size for the clone ArgumentHolder.
*/
CommandImpl*
createCloneImpl (CommandImpl const& reference)
{
UNIMPLEMENTED ("allocate clone, solve the re-discovery problem");
}
template<class IMP>
static void
kill (IMP* entry)

View file

@ -143,10 +143,18 @@ namespace control {
}
CommandDef
Command
Command::storeDef (Symbol newCmdID)
{
UNIMPLEMENTED ("create a new definition & prototype based on this command");
static format fmt("Unable to store %s as new command. ID \"%s\" is already in use");
if (registry.queryIndex (newCmdID))
throw error::Logic (str (fmt % *this % newCmdID), LUMIERA_ERROR_DUPLICATE_COMMAND);
Command cloneDefinition;
CommandRegistry& registry = CommandRegistry::instance();
cloneDefinition.activate (registry.createCloneImpl(impl()));
return registry.track (newCmdID, cloneDefinition);
}

View file

@ -86,7 +86,7 @@ namespace control {
static bool remove (Symbol cmdID);
static bool undef (Symbol cmdID);
CommandDef storeDef (Symbol newCmdID);
Command storeDef (Symbol newCmdID);
Command() { } ///< undefined command
~Command();