2009-06-08 21:29:09 +02:00
|
|
|
/*
|
|
|
|
|
CommandBasic(Test) - checking simple ProcDispatcher command definition and execution
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2009, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
2009-06-12 20:10:27 +02:00
|
|
|
#include "lib/test/test-helper.hpp"
|
2009-06-08 21:29:09 +02:00
|
|
|
//#include "proc/asset/media.hpp"
|
|
|
|
|
//#include "proc/mobject/session.hpp"
|
|
|
|
|
//#include "proc/mobject/session/edl.hpp"
|
|
|
|
|
//#include "proc/mobject/session/testclip.hpp"
|
2009-06-10 03:42:23 +02:00
|
|
|
//#include "proc/mobject/test-dummy-mobject.hpp"
|
|
|
|
|
#include "lib/p.hpp"
|
2009-06-08 21:29:09 +02:00
|
|
|
//#include "proc/mobject/placement.hpp"
|
|
|
|
|
//#include "proc/mobject/placement-index.hpp"
|
|
|
|
|
//#include "proc/mobject/explicitplacement.hpp"
|
|
|
|
|
#include "proc/control/command-def.hpp"
|
2009-06-10 05:00:01 +02:00
|
|
|
#include "lib/lumitime.hpp"
|
2009-06-08 21:29:09 +02:00
|
|
|
//#include "lib/util.hpp"
|
|
|
|
|
|
2009-06-10 05:00:01 +02:00
|
|
|
#include "lib/meta/typelist.hpp"
|
2009-06-30 04:54:50 +02:00
|
|
|
#include "lib/meta/typelist-util.hpp"
|
2009-06-14 05:38:35 +02:00
|
|
|
#include "lib/meta/generator.hpp"
|
2009-06-17 06:55:18 +02:00
|
|
|
|
2009-06-10 05:00:01 +02:00
|
|
|
|
2009-06-10 03:42:23 +02:00
|
|
|
#include <tr1/functional>
|
2009-06-08 21:29:09 +02:00
|
|
|
//#include <boost/format.hpp>
|
2009-06-12 20:10:27 +02:00
|
|
|
#include <iostream>
|
2009-06-24 06:01:14 +02:00
|
|
|
#include <cstdlib>
|
2009-06-08 21:29:09 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
2009-06-10 05:00:01 +02:00
|
|
|
using std::tr1::bind;
|
|
|
|
|
//using std::tr1::placeholders::_1;
|
|
|
|
|
//using std::tr1::placeholders::_2;
|
2009-06-10 03:42:23 +02:00
|
|
|
using std::tr1::function;
|
2009-06-08 21:29:09 +02:00
|
|
|
//using boost::format;
|
2009-06-10 05:00:01 +02:00
|
|
|
using lumiera::Time;
|
2009-06-08 21:29:09 +02:00
|
|
|
//using util::contains;
|
|
|
|
|
using std::string;
|
2009-06-24 06:01:14 +02:00
|
|
|
using std::rand;
|
2009-06-12 20:10:27 +02:00
|
|
|
using std::cout;
|
|
|
|
|
using std::endl;
|
2009-06-08 21:29:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace control {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
2009-06-12 20:10:27 +02:00
|
|
|
using lib::test::showSizeof;
|
|
|
|
|
|
2009-06-08 21:29:09 +02:00
|
|
|
// using session::test::TestClip;
|
2009-06-10 05:00:01 +02:00
|
|
|
using lumiera::P;
|
2009-06-10 03:42:23 +02:00
|
|
|
|
|
|
|
|
|
2009-07-10 19:04:01 +02:00
|
|
|
//using lumiera::typelist::BuildTupleAccessor;
|
2009-06-08 21:29:09 +02:00
|
|
|
|
2009-06-19 05:57:06 +02:00
|
|
|
|
2009-06-10 03:42:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////
|
|
|
|
|
/////////////////////////////
|
2009-06-12 20:10:27 +02:00
|
|
|
|
|
|
|
|
//////////////////////////// start of the actual Test....
|
|
|
|
|
|
2009-06-19 05:57:06 +02:00
|
|
|
|
|
|
|
|
|
2009-07-23 03:47:27 +02:00
|
|
|
namespace {
|
|
|
|
|
|
2009-06-10 03:42:23 +02:00
|
|
|
void
|
2009-06-10 05:00:01 +02:00
|
|
|
operate (P<Time> dummyObj, int randVal)
|
2009-06-10 03:42:23 +02:00
|
|
|
{
|
2009-06-10 05:00:01 +02:00
|
|
|
*dummyObj += Time(randVal);
|
2009-06-10 03:42:23 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-10 05:00:01 +02:00
|
|
|
Time
|
|
|
|
|
capture (P<Time> dummyObj, int)
|
2009-06-10 03:42:23 +02:00
|
|
|
{
|
|
|
|
|
return *dummyObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2009-06-10 05:00:01 +02:00
|
|
|
undoIt (P<Time> dummyObj, int, Time oldVal)
|
2009-06-10 03:42:23 +02:00
|
|
|
{
|
|
|
|
|
*dummyObj = oldVal;
|
|
|
|
|
}
|
2009-06-08 21:29:09 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
* @test basic usage of the Proc-Layer command dispatch system.
|
|
|
|
|
* Shows how to define a simple command inline and another
|
|
|
|
|
* simple command as dedicated class. Finally triggers
|
|
|
|
|
* execution of both commands and verifies the command
|
|
|
|
|
* action has been invoked.
|
|
|
|
|
*
|
|
|
|
|
* @todo currently rather a scrapbook for trying out first ideas on the command system !!!!!!!!!!!!!!!
|
|
|
|
|
*
|
|
|
|
|
* @see control::Command
|
|
|
|
|
* @see control::CommandDef
|
|
|
|
|
* @see mobject::ProcDispatcher
|
|
|
|
|
*/
|
|
|
|
|
class CommandBasic_test : public Test
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
run (Arg)
|
2009-06-10 03:42:23 +02:00
|
|
|
{
|
2009-06-15 04:57:23 +02:00
|
|
|
P<Time> obj (new Time(5));
|
|
|
|
|
int randVal ((rand() % 10) - 5);
|
|
|
|
|
|
2009-06-19 05:57:06 +02:00
|
|
|
CommandDef ("test.command1")
|
2009-07-23 03:47:27 +02:00
|
|
|
.operation (operate)
|
|
|
|
|
.captureUndo (capture)
|
|
|
|
|
.undoOperation (undoIt)
|
2009-06-15 04:57:23 +02:00
|
|
|
.bind (obj, randVal)
|
2009-06-10 03:42:23 +02:00
|
|
|
;
|
2009-06-19 05:57:06 +02:00
|
|
|
|
|
|
|
|
|
2009-06-19 19:11:33 +02:00
|
|
|
Command& ourCmd = Command::get("test.command1");
|
2009-07-21 04:49:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////TODO: isn't this unlogical? Do I want a *definition* or an *instance* ??
|
2009-06-19 05:57:06 +02:00
|
|
|
|
|
|
|
|
// invoke the command
|
2009-06-19 19:11:33 +02:00
|
|
|
ASSERT (*obj == Time(5));
|
2009-06-19 05:57:06 +02:00
|
|
|
ourCmd();
|
2009-06-19 19:11:33 +02:00
|
|
|
ASSERT (*obj == Time(5) + Time(randVal));
|
2009-06-19 05:57:06 +02:00
|
|
|
|
|
|
|
|
// undo the effect of the command
|
|
|
|
|
ourCmd.undo();
|
2009-06-19 19:11:33 +02:00
|
|
|
ASSERT (*obj == Time(5));
|
2009-06-08 21:29:09 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
LAUNCHER (CommandBasic_test, "unit controller");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace control::test
|