WIP and more stubbing...
This commit is contained in:
parent
c85eb20cee
commit
3ebb8d0285
7 changed files with 72 additions and 23 deletions
|
|
@ -53,6 +53,7 @@
|
|||
#include "proc/control/command-signature.hpp"
|
||||
#include "proc/control/command-mutation.hpp"
|
||||
#include "proc/control/command-closure.hpp"
|
||||
#include "proc/control/argument-tuple-accept.hpp"
|
||||
#include "lib/meta/function.hpp"
|
||||
#include "lib/meta/typelist.hpp"
|
||||
#include "lib/meta/typelist-util.hpp"
|
||||
|
|
@ -74,7 +75,7 @@ namespace control {
|
|||
using lumiera::typelist::FunctionSignature;
|
||||
using lumiera::typelist::FunctionTypedef;
|
||||
using lumiera::typelist::Types;
|
||||
//using lumiera::typelist::NullType;
|
||||
using lumiera::typelist::NullType;
|
||||
using lumiera::typelist::Tuple;
|
||||
|
||||
|
||||
|
|
@ -84,11 +85,17 @@ namespace control {
|
|||
|
||||
template<typename SIG, typename MEM>
|
||||
struct UndoDefinition
|
||||
: AcceptArgumentTupleRet< Command&, SIG // Return type and Argument Signature of the \c bind(..) function
|
||||
, UndoDefinition<SIG,MEM> // target type (this class) providing the implementation \c bindArg(Tuple<..>)
|
||||
>
|
||||
{
|
||||
typedef typename FunctionSignature< function<SIG> >::Args BasicArgs;
|
||||
typedef typename FunctionTypedef<MEM,BasicArgs>::Sig UndoCaptureSig;
|
||||
|
||||
UndoDefinition (function<UndoCaptureSig>& undoCapOperation)
|
||||
Command& prototype_;
|
||||
|
||||
UndoDefinition (Command& underConstruction, function<UndoCaptureSig>& undoCapOperation)
|
||||
: prototype_(underConstruction)
|
||||
{
|
||||
cout << showSizeof(undoCapOperation) << endl;
|
||||
UNIMPLEMENTED ("re-fetch command definition and augment it with Functor for capturing Undo information");
|
||||
|
|
@ -106,22 +113,15 @@ namespace control {
|
|||
return *this;
|
||||
}
|
||||
|
||||
template
|
||||
< typename T1
|
||||
, typename T2
|
||||
>
|
||||
UndoDefinition& ///////TODO return here the completed Command
|
||||
bind ( T1& p1
|
||||
, T2& p2
|
||||
)
|
||||
|
||||
Command&
|
||||
bindArg (Tuple<BasicArgs> const& params)
|
||||
{
|
||||
typedef Types<T1,T2> ArgTypes;
|
||||
Tuple<ArgTypes> params(p1,p2);
|
||||
Closure<SIG> clo (params);
|
||||
|
||||
cout << showSizeof(clo) << endl;
|
||||
UNIMPLEMENTED ("complete Command definition by closing all functions");
|
||||
return *this;
|
||||
return prototype_;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -145,7 +145,10 @@ namespace control {
|
|||
template<typename SIG>
|
||||
struct BasicDefinition
|
||||
{
|
||||
BasicDefinition(function<SIG>& operation)
|
||||
Command& prototype_;
|
||||
|
||||
BasicDefinition(Command& underConstruction, function<SIG>& operation)
|
||||
: prototype_(underConstruction)
|
||||
{
|
||||
cout << showSizeof(operation) << endl;
|
||||
UNIMPLEMENTED ("create new command object and store the operation functor");
|
||||
|
|
@ -160,7 +163,7 @@ namespace control {
|
|||
typedef typename BuildUndoDefType<UndoSignature<SIG2> >::Type SpecificUndoDefinition;
|
||||
|
||||
function<UndoCapSig> opera2 (how_to_capture_UndoState);
|
||||
return SpecificUndoDefinition (opera2);
|
||||
return SpecificUndoDefinition (prototype_, opera2);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -188,11 +191,12 @@ namespace control {
|
|||
: public lib::BoolCheckable<CommandDef>
|
||||
{
|
||||
Symbol id_;
|
||||
|
||||
Command& prototype_;
|
||||
|
||||
public:
|
||||
CommandDef (Symbol cmdID)
|
||||
: id_(cmdID)
|
||||
, prototype_(Command::fetchDef(cmdID))
|
||||
{ }
|
||||
|
||||
template<typename SIG>
|
||||
|
|
@ -200,7 +204,7 @@ namespace control {
|
|||
operation (SIG& operation_to_define)
|
||||
{
|
||||
function<SIG> opera1 (operation_to_define);
|
||||
return stage::BasicDefinition<SIG>(opera1);
|
||||
return stage::BasicDefinition<SIG>(prototype_, opera1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,20 @@ namespace control {
|
|||
}
|
||||
|
||||
|
||||
Command&
|
||||
Command::fetchDef (Symbol cmdID)
|
||||
{
|
||||
UNIMPLEMENTED ("fetch an command prototype from the registry, create if necessary");
|
||||
}
|
||||
|
||||
|
||||
CommandDef
|
||||
Command::storeDef (Symbol newCmdID)
|
||||
{
|
||||
UNIMPLEMENTED ("create a new definition & prototype based on this command");
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Command::remove (Symbol cmdID)
|
||||
{
|
||||
|
|
@ -139,6 +153,13 @@ namespace control {
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
Command::execSync ()
|
||||
{
|
||||
exec (HandlingPattern::get(HandlingPattern::SYNC_THROW));
|
||||
}
|
||||
|
||||
|
||||
HandlingPattern const&
|
||||
Command::getDefaultHandlingPattern() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ namespace control {
|
|||
|
||||
|
||||
|
||||
class CommandDef;
|
||||
class HandlingPattern;
|
||||
|
||||
|
||||
|
|
@ -73,8 +74,9 @@ namespace control {
|
|||
/* === command registry === */
|
||||
static Command& get (Symbol cmdID);
|
||||
static bool remove (Symbol cmdID);
|
||||
static bool undef (Symbol cmdID);
|
||||
static bool undef (Symbol cmdID);
|
||||
|
||||
CommandDef storeDef (Symbol newCmdID);
|
||||
|
||||
|
||||
~Command();
|
||||
|
|
@ -89,6 +91,8 @@ namespace control {
|
|||
*/
|
||||
void exec (HandlingPattern const& execPattern);
|
||||
|
||||
void execSync ();
|
||||
|
||||
HandlingPattern const& getDefaultHandlingPattern() const;
|
||||
|
||||
|
||||
|
|
@ -104,6 +108,12 @@ namespace control {
|
|||
bool isValid() const;
|
||||
bool canExec() const;
|
||||
bool canUndo() const;
|
||||
|
||||
protected:
|
||||
static Command& fetchDef (Symbol cmdID);
|
||||
|
||||
friend class CommandDef;
|
||||
|
||||
};
|
||||
////////////////TODO currently just fleshing out the API....
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@
|
|||
namespace control {
|
||||
|
||||
/** */
|
||||
HandlingPattern const&
|
||||
HandlingPattern::get (ID id)
|
||||
{
|
||||
UNIMPLEMENTED ("Factory for handling patterns");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////TODO: is this implementation file actually required??
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#define CONTROL_HANDLING_PATTERN_H
|
||||
|
||||
//#include "pre.hpp"
|
||||
#include "lib/error.hpp"
|
||||
//#include "include/symbol.hpp"
|
||||
|
||||
//#include <tr1/memory>
|
||||
|
|
@ -58,6 +59,15 @@ namespace control {
|
|||
|
||||
public:
|
||||
|
||||
enum ID
|
||||
{ SYNC
|
||||
, SYNC_THROW
|
||||
, ASYNC
|
||||
};
|
||||
|
||||
static HandlingPattern const& get (ID id);
|
||||
|
||||
|
||||
virtual ~HandlingPattern() {}
|
||||
|
||||
virtual void invoke (Command& command) const =0;
|
||||
|
|
|
|||
|
|
@ -267,8 +267,7 @@ namespace test {
|
|||
ASSERT (!unbelievable);
|
||||
|
||||
// but because the miracle isn't yet defined, any use throws
|
||||
VERIFY_ERROR (INVALID_COMMAND, Command::get("miracle"));
|
||||
VERIFY_ERROR (INVALID_COMMAND, unbelievable.bind("abracadabra"));
|
||||
VERIFY_ERROR (INVALID_COMMAND, Command::get("miracle"));
|
||||
|
||||
ASSERT (Command::remove("test.command1.1"));
|
||||
ASSERT (Command::remove("test.command1.2"));
|
||||
|
|
|
|||
|
|
@ -191,17 +191,17 @@ namespace test {
|
|||
Command com = Command::get("test.command2");
|
||||
|
||||
blowUp_ = false;
|
||||
com.exec(HandlingPattern::THROW_SYNC);
|
||||
com.exec(HandlingPattern::SYNC_THROW);
|
||||
ASSERT (protocolled(randVal_));
|
||||
|
||||
blowUp_ = true;
|
||||
string current = command2::check_.str();
|
||||
VERIFY_ERROR( EXTERNAL, com.exec(HandlingPattern::THROW_SYNC) );
|
||||
VERIFY_ERROR( EXTERNAL, com.exec(HandlingPattern::get(SYNC_THROW)) );
|
||||
ASSERT (command2::check_.str() == current);
|
||||
|
||||
// we can achieve the same effect,
|
||||
// after changing the default HandlingPatern for this command instance
|
||||
com.setHandlingPattern(HandlingPattern::THROW_SYNC);
|
||||
com.setHandlingPattern(HandlingPattern::SYNC_THROW);
|
||||
com.storeDef ("test.command2.1");
|
||||
|
||||
Command com2 = Command::get("test.command2.1");
|
||||
|
|
|
|||
Loading…
Reference in a new issue