fixed and stubbed until it passes compiler again

This commit is contained in:
Fischlurch 2009-08-02 20:57:04 +02:00
parent 327cbc822a
commit 853aff1228
7 changed files with 56 additions and 40 deletions

View file

@ -107,7 +107,7 @@ namespace util {
/** shortcut for set value containment test */
template <typename T>
inline bool
contains (std::set<T>& set, const T& val)
contains (std::set<T>& set, T const& val)
{
return set.end() != set.find (val);
}
@ -247,7 +247,7 @@ namespace util {
\endverbatim
* @see sanitised-identifier-test.cpp
*/
string sanitise (const string& org);
string sanitise (string const& org);
@ -256,7 +256,7 @@ namespace util {
* usable for printf with objects providing to-string conversion.
*/
inline const char*
cStr (const string& org)
cStr (string const& org)
{
return org.c_str();
}

View file

@ -161,11 +161,5 @@ namespace control {
};
// inline ostream& operator<< (ostream& os, Mutation const& muta) { return os << string(muta); }
/** storage for the singleton factory used to access CommandRegistry */
lumiera::Singleton<CommandRegistry> CommandRegistry::instance;
} // namespace control
#endif

View file

@ -63,6 +63,11 @@ namespace control {
LUMIERA_ERROR_DEFINE (MISSING_MEMENTO, "Undo functor not yet usable, because no undo state has been captured");
/** storage for the singleton factory used to access CommandRegistry */
lumiera::Singleton<CommandRegistry> CommandRegistry::instance;
Command::~Command() { }
@ -81,6 +86,19 @@ namespace control {
}
/** @todo this is a "nice-to-have"; it would allow to call a function as a command,
* almost as if it was a normal function. But this function needs to be defined
* as a command previously, together with a suitable UNDO function. Moreover
* this would probably require to build an additional index;
* thus this feature is unimplemented for the time being.
*/
Command
Command::get (FuncPtr funcP)
{
UNIMPLEMENTED ("find a command definition which was based on the given function (ptr)");
}
Command
Command::fetchDef (Symbol cmdID)
{
@ -221,33 +239,34 @@ namespace control {
void
ExecResult
Command::undo ()
{
HandlingPattern const& defaultPattern
= HandlingPattern::get (getDefaultHandlingPattern());
exec (defaultPattern.howtoUNDO());
return exec (defaultPattern.howtoUNDO());
}
void
ExecResult
Command::exec (HandlingPattern const& execPattern)
{
execPattern (*this);
return execPattern (*this);
}
void
ExecResult
Command::exec (HandlingPattern::ID pattID)
{
HandlingPattern::get(pattID) (*this);
return HandlingPattern::get(pattID) (*this);
}
void
ExecResult
Command::execSync ()
{
exec (HandlingPattern::get(HandlingPattern::SYNC_THROW));
return exec (HandlingPattern::get(HandlingPattern::SYNC_THROW));
}
@ -263,17 +282,6 @@ namespace control {
{
UNIMPLEMENTED ("manage handling patterns in general");
}
template<typename TYPES>
void
Command::bindArg (Tuple<TYPES> const& args)
{
UNIMPLEMENTED ("create an argument-binding, with runtime type check");
}

View file

@ -62,6 +62,8 @@ namespace control {
LUMIERA_ERROR_DECLARE (INVALID_ARGUMENTS); ///< Arguments provided for binding doesn't match stored command function parameters
typedef void* FuncPtr;
class CommandDef;
class CommandImpl;
@ -80,6 +82,7 @@ namespace control {
public:
/* === command registry === */
static Command get (Symbol cmdID);
static Command get (FuncPtr func);
static bool remove (Symbol cmdID);
static bool undef (Symbol cmdID);
@ -149,6 +152,16 @@ namespace control {
}
template<typename TYPES>
inline Command&
Command::bindArg (Tuple<TYPES> const&)
{
UNIMPLEMENTED("delegate argument binding to command-impl");
return *this;
}
inline bool
operator== (Command const& c1, Command const& c2)
{

View file

@ -32,7 +32,7 @@
//#include "proc/mobject/placement.hpp"
//#include "proc/mobject/placement-index.hpp"
//#include "proc/mobject/explicitplacement.hpp"
#include "proc/control/command.hpp"
#include "proc/control/command-invocation.hpp"
#include "proc/control/command-def.hpp"
//#include "lib/lumitime.hpp"
#include "lib/format.hpp"
@ -157,11 +157,11 @@ namespace test {
ASSERT ( 0 == command1::check_);
// the following shortcut does the same:
Command::invoke ("test.command1.2", 1234);
invoke ("test.command1.2") (1234);
ASSERT ( 1234 == command1::check_);
// another shortcut, with static type check:
invoke (command1::operate, 5678);
invoke (command1::operate) (5678);
ASSERT ( 1234+5678 == command1::check_);
com.undo();
@ -282,6 +282,7 @@ namespace test {
ASSERT (Command::get("test.command1.4"));
VERIFY_ERROR (INVALID_COMMAND, Command::get("miracle"));
VERIFY_ERROR (INVALID_COMMAND, invoke ("miracle") (1,2,3));
CommandDef unbelievable ("miracle");
ASSERT (!unbelievable);

View file

@ -100,7 +100,7 @@ namespace test {
.captureUndo (command1::capture)
.undoOperation (command1::undoIt);
UNIMPLEMENTED ("more elaborate command handling patterns")
UNIMPLEMENTED ("more elaborate command handling patterns");
////////////////////////////////////////////////////////////////////////////////TODO: devise tests for async, repeated and compound sequences
ASSERT (cnt_inst == Command::instance_count());

View file

@ -86,21 +86,21 @@ namespace test {
namespace command1 { ///< test command just adding a given value
long check_ = 0;
static long check_ = 0;
void
inline void
operate (int someVal)
{
check_ += someVal;
}
long
inline long
capture (int)
{
return check_;
}
void
inline void
undoIt (int, long oldVal)
{
check_ = oldVal;
@ -117,12 +117,12 @@ namespace test {
using lumiera::error::External;
ostringstream check_;
static ostringstream check_;
typedef function<string()> FunS;
void
inline void
operate (FunS func, bool fail)
{
if (fail) throw External("simulated exception");
@ -130,13 +130,13 @@ namespace test {
check_ << func();
}
string
inline string
capture (FunS, bool)
{
return check_.str();
}
void
inline void
undoIt (FunS, bool fail, string previousProtocol)
{
if (fail) throw External("simulated exception in UNDO");