WIP stubbing undefined operations...
This commit is contained in:
parent
f40282b2ff
commit
211a2dabdd
6 changed files with 147 additions and 10 deletions
|
|
@ -57,6 +57,7 @@
|
|||
#include "lib/meta/typelist.hpp"
|
||||
#include "lib/meta/typelist-util.hpp"
|
||||
#include "lib/meta/tuple.hpp"
|
||||
#include "lib/bool-checkable.hpp"
|
||||
|
||||
//#include <tr1/memory>
|
||||
#include <tr1/functional>
|
||||
|
|
@ -184,6 +185,7 @@ namespace control {
|
|||
*
|
||||
*/
|
||||
class CommandDef
|
||||
: public lib::BoolCheckable<CommandDef>
|
||||
{
|
||||
Symbol id_;
|
||||
|
||||
|
|
@ -200,6 +202,9 @@ namespace control {
|
|||
function<SIG> opera1 (operation_to_define);
|
||||
return stage::BasicDefinition<SIG>(opera1);
|
||||
}
|
||||
|
||||
|
||||
bool isValid() const;
|
||||
};
|
||||
|
||||
////////////////TODO currently just fleshing out the API....
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@
|
|||
|
||||
|
||||
#include "proc/control/command.hpp"
|
||||
#include "proc/control/command-def.hpp"
|
||||
#include "proc/control/command-registry.hpp"
|
||||
#include "proc/control/handling-pattern.hpp"
|
||||
//#include "proc/mobject/mobject-ref.hpp"
|
||||
//#include "proc/mobject/mobject.hpp"
|
||||
//#include "proc/mobject/placement.hpp"
|
||||
|
|
@ -46,6 +48,9 @@ namespace control {
|
|||
|
||||
|
||||
|
||||
Command::~Command() { }
|
||||
|
||||
|
||||
/** */
|
||||
Command&
|
||||
Command::get (Symbol cmdID)
|
||||
|
|
@ -53,6 +58,92 @@ namespace control {
|
|||
UNIMPLEMENTED ("fetch an existing command from the internal cmd registry");
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Command::remove (Symbol cmdID)
|
||||
{
|
||||
UNIMPLEMENTED ("de-register a single command instance");
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Command::undef (Symbol cmdID)
|
||||
{
|
||||
UNIMPLEMENTED ("completely drop a command definition, together with all dependent instances");
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t
|
||||
Command::definition_count()
|
||||
{
|
||||
UNIMPLEMENTED ("return number of command definitions currently in the registry");
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t
|
||||
Command::instance_count()
|
||||
{
|
||||
UNIMPLEMENTED ("return number individual command instances currently in the registry");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
CommandDef::isValid() const
|
||||
{
|
||||
UNIMPLEMENTED ("command *definition* validity self check");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
Command::isValid() const
|
||||
{
|
||||
UNIMPLEMENTED ("command validity self check");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
Command::canExec() const
|
||||
{
|
||||
UNIMPLEMENTED ("state check: sufficiently defined to be invoked");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
Command::canUndo() const
|
||||
{
|
||||
UNIMPLEMENTED ("state check: has undo state been captured?");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
Command::undo ()
|
||||
{
|
||||
exec (getDefaultHandlingPattern().howtoUNDO());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Command::exec (HandlingPattern const& execPattern)
|
||||
{
|
||||
execPattern.invoke (*this);
|
||||
}
|
||||
|
||||
|
||||
HandlingPattern const&
|
||||
Command::getDefaultHandlingPattern() const
|
||||
{
|
||||
UNIMPLEMENTED ("manage the default command handling pattern");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "include/symbol.hpp"
|
||||
#include "proc/control/command-mutation.hpp"
|
||||
#include "proc/control/command-closure.hpp"
|
||||
#include "lib/bool-checkable.hpp"
|
||||
|
||||
//#include <tr1/memory>
|
||||
|
||||
|
|
@ -51,24 +52,57 @@ namespace control {
|
|||
// using std::tr1::shared_ptr;
|
||||
|
||||
|
||||
class HandlingPattern;
|
||||
|
||||
|
||||
/**
|
||||
* @todo Type-comment
|
||||
*/
|
||||
class Command
|
||||
: public lib::BoolCheckable<Command>
|
||||
{
|
||||
|
||||
public:
|
||||
/* === command registry === */
|
||||
static Command& get (Symbol cmdID);
|
||||
static bool remove (Symbol cmdID);
|
||||
static bool undef (Symbol cmdID);
|
||||
|
||||
virtual ~Command() {};
|
||||
|
||||
virtual void operator() () =0;
|
||||
virtual void undo () =0;
|
||||
|
||||
~Command();
|
||||
|
||||
void operator() () ;
|
||||
void undo () ;
|
||||
|
||||
|
||||
/** core operation: invoke the command
|
||||
* @param execPattern describes the individual steps
|
||||
* necessary to get this command invoked properly
|
||||
*/
|
||||
void exec (HandlingPattern const& execPattern);
|
||||
|
||||
HandlingPattern const& getDefaultHandlingPattern() const;
|
||||
|
||||
|
||||
/* === diagnostics === */
|
||||
|
||||
static size_t definition_count();
|
||||
static size_t instance_count();
|
||||
|
||||
bool isValid() const;
|
||||
bool canExec() const;
|
||||
bool canUndo() const;
|
||||
};
|
||||
////////////////TODO currently just fleshing out the API....
|
||||
|
||||
|
||||
|
||||
inline void
|
||||
Command::operator() ()
|
||||
{
|
||||
exec (getDefaultHandlingPattern());
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace control
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ namespace control {
|
|||
|
||||
public:
|
||||
|
||||
virtual ~HandlingPattern() {}
|
||||
|
||||
virtual void invoke (Command& command) const =0;
|
||||
|
||||
virtual HandlingPattern const& howtoUNDO() const =0;
|
||||
|
||||
};
|
||||
////////////////TODO currently just fleshing out the API....
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace test {
|
|||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
command1::checksum_ = 0;
|
||||
command1::check_ = 0;
|
||||
uint cnt_defs = Command::definition_count();
|
||||
uint cnt_inst = Command::instance_count();
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ namespace test {
|
|||
.execSync()
|
||||
;
|
||||
|
||||
ASSERT (randVal == checksum_);
|
||||
ASSERT (randVal == command1::check_);
|
||||
|
||||
Command::get("test.command1.1").undo();
|
||||
ASSERT ( 0 == command1::check_);
|
||||
|
|
@ -250,10 +250,10 @@ namespace test {
|
|||
void
|
||||
undef()
|
||||
{
|
||||
ASSERT (CommandDef ("test.command1.1"))
|
||||
ASSERT (CommandDef ("test.command1.2"))
|
||||
ASSERT (CommandDef ("test.command1.3"))
|
||||
ASSERT (CommandDef ("test.command1.4"))
|
||||
ASSERT (CommandDef ("test.command1.1"));
|
||||
ASSERT (CommandDef ("test.command1.2"));
|
||||
ASSERT (CommandDef ("test.command1.3"));
|
||||
ASSERT (CommandDef ("test.command1.4"));
|
||||
|
||||
ASSERT (Command::get("test.command1.1"));
|
||||
ASSERT (Command::get("test.command1.2"));
|
||||
|
|
|
|||
|
|
@ -149,3 +149,4 @@ namespace test {
|
|||
|
||||
|
||||
}} // namespace control::test
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue