Enable move-initialisation on command activation
This commit is contained in:
parent
0b63cdd88e
commit
a9cb417320
5 changed files with 23 additions and 10 deletions
|
|
@ -127,6 +127,13 @@ namespace lib {
|
|||
return *this;
|
||||
}
|
||||
|
||||
Handle&
|
||||
activate(shared_ptr<IMP> && impl)
|
||||
{
|
||||
smPtr_ = move (impl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** deactivate this handle, so it isn't tied any longer
|
||||
* to the associated implementation or service object.
|
||||
* When all handles have either been deactivated or
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace control {
|
|||
namespace stage { ///< helpers for building up a command definition
|
||||
|
||||
using ImplInstance = shared_ptr<CommandImpl>;
|
||||
using Activation = function<Command&(ImplInstance const&)>;
|
||||
using Activation = function<Command&(ImplInstance &&)>;
|
||||
|
||||
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ namespace control {
|
|||
ImplInstance completedDef = registry.newCommandImpl(operFunctor_
|
||||
,captFunctor_
|
||||
,undoFunctor_);
|
||||
return CompletedDefinition<SIG> (activatePrototype_(completedDef));
|
||||
return CompletedDefinition<SIG> {activatePrototype_(move (completedDef))};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -318,9 +318,9 @@ namespace control {
|
|||
/** callback from completed command definition stage:
|
||||
* "arm up" the command handle object and register it
|
||||
* with the CommandRegistry. */
|
||||
Command& activate (PImpl const& completedDef)
|
||||
Command& activate (PImpl && completedDef)
|
||||
{
|
||||
prototype_.activate (completedDef, id_);
|
||||
prototype_.activate (move (completedDef), id_);
|
||||
ENSURE (prototype_);
|
||||
return prototype_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ namespace control {
|
|||
|
||||
REQUIRE (instance and instance.canExec());
|
||||
dispatcher_.enqueue(move (instance));
|
||||
instance.close();
|
||||
ENSURE (not instance);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@
|
|||
#include "proc/control/command-impl-clone-builder.hpp"
|
||||
#include "proc/control/handling-pattern.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
using std::move;
|
||||
using util::cStr;
|
||||
using util::_Fmt;
|
||||
|
||||
|
|
@ -158,14 +160,14 @@ namespace control {
|
|||
* @param cmdID new ID for creating a separate command registration when provided
|
||||
* @throw error::Logic when \c this is already activated. */
|
||||
void
|
||||
Command::activate (shared_ptr<CommandImpl> const& implFrame, Symbol cmdID)
|
||||
Command::activate (shared_ptr<CommandImpl> && implFrame, Symbol cmdID)
|
||||
{
|
||||
REQUIRE (implFrame);
|
||||
|
||||
if (this->isValid())
|
||||
duplicate_detected (cmdID);
|
||||
|
||||
_Handle::activate (implFrame);
|
||||
_Handle::activate (move (implFrame));
|
||||
if (cmdID)
|
||||
CommandRegistry::instance().track (cmdID, *this);
|
||||
|
||||
|
|
@ -185,7 +187,7 @@ namespace control {
|
|||
duplicate_detected (newCmdID);
|
||||
|
||||
Command cloneDefinition;
|
||||
cloneDefinition.activate (registry.createCloneImpl(this->impl()), newCmdID);
|
||||
cloneDefinition.activate (move (registry.createCloneImpl(this->impl())), newCmdID);
|
||||
ENSURE (cloneDefinition);
|
||||
return cloneDefinition;
|
||||
}
|
||||
|
|
@ -200,7 +202,7 @@ namespace control {
|
|||
shared_ptr<CommandImpl> cloneImpl = registry.createCloneImpl(this->impl());
|
||||
|
||||
Command clone;
|
||||
clone.activate (cloneImpl);
|
||||
clone.activate (move (cloneImpl));
|
||||
ENSURE (clone);
|
||||
return clone;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,10 @@ namespace control {
|
|||
~Command();
|
||||
|
||||
// default copy acceptable
|
||||
Command (Command &&) = default;
|
||||
Command (Command const&) = default;
|
||||
Command& operator= (Command &&) = default;
|
||||
Command& operator= (Command const&) = default;
|
||||
|
||||
|
||||
|
||||
|
|
@ -192,7 +196,7 @@ namespace control {
|
|||
|
||||
protected:
|
||||
static Command fetchDef (Symbol cmdID);
|
||||
void activate (shared_ptr<CommandImpl> const&, Symbol cmdID =0);
|
||||
void activate (shared_ptr<CommandImpl> &&, Symbol cmdID =0);
|
||||
|
||||
friend class CommandDef; //...invoking those two functions during definition stage
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue