LUMIERA.clone/src/proc/control/command.cpp

199 lines
4.3 KiB
C++
Raw Normal View History

2009-06-08 04:46:07 +02:00
/*
Command - Key abstraction for proc/edit operations and UNDO management
Copyright (C) Lumiera.org
2009-07-27 02:38:53 +02:00
2009, Hermann Vosseler <Ichthyostega@web.de>
2009-06-08 04:46:07 +02:00
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.
* *****************************************************/
/** @file command.cpp
** //TODO
**
** @see command.hpp
2009-07-21 04:49:00 +02:00
** @see command-registry.hpp
2009-06-08 04:46:07 +02:00
**
*/
#include "proc/control/command.hpp"
2009-07-24 17:50:14 +02:00
#include "proc/control/command-def.hpp"
2009-07-21 04:49:00 +02:00
#include "proc/control/command-registry.hpp"
2009-07-24 17:50:14 +02:00
#include "proc/control/handling-pattern.hpp"
2009-06-08 04:46:07 +02:00
//#include "proc/mobject/mobject-ref.hpp"
//#include "proc/mobject/mobject.hpp"
//#include "proc/mobject/placement.hpp"
//#include <boost/format.hpp>
//using boost::str;
namespace control {
2009-07-25 19:21:50 +02:00
LUMIERA_ERROR_DEFINE (INVALID_COMMAND, "Unknown or insufficiently defined command");
LUMIERA_ERROR_DEFINE (INVALID_ARGUMENTS, "Arguments provided for binding doesn't match stored command function parameters");
2009-07-12 18:55:33 +02:00
LUMIERA_ERROR_DEFINE (UNBOUND_ARGUMENTS, "Command mutation functor not yet usable, because arguments aren't bound");
2009-07-25 19:21:50 +02:00
LUMIERA_ERROR_DEFINE (MISSING_MEMENTO, "Undo functor not yet usable, because no undo state has been captured");
2009-06-08 04:46:07 +02:00
2009-07-29 16:55:15 +02:00
2009-07-24 17:50:14 +02:00
Command::~Command() { }
2009-07-29 16:55:15 +02:00
/** @internal to be invoked by #fetchDef */
Command::Command (CommandImpl* pImpl)
{
Handle::activate (pImpl, CommandRegistry::killCommandImpl);
}
2009-07-24 17:50:14 +02:00
/** */
Command&
Command::get (Symbol cmdID)
{
UNIMPLEMENTED ("fetch an existing command from the internal cmd registry");
}
2009-07-24 17:50:14 +02:00
2009-07-26 02:00:47 +02:00
Command&
Command::fetchDef (Symbol cmdID)
{
2009-07-29 16:55:15 +02:00
Command* cmd = CommandRegistry::queryIndex (cmdID);
if (cmd)
////////////////////////////////////////////////////////////////////////TODO: race
return *cmd;
Command newDefinition (CommandRegistry::newCommandImpl());
return CommandRegistry::track (cmdID, newDefinition);
2009-07-26 02:00:47 +02:00
}
CommandDef
Command::storeDef (Symbol newCmdID)
{
UNIMPLEMENTED ("create a new definition & prototype based on this command");
}
2009-07-24 17:50:14 +02:00
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);
}
2009-07-26 02:00:47 +02:00
void
Command::execSync ()
{
exec (HandlingPattern::get(HandlingPattern::SYNC_THROW));
}
2009-07-24 17:50:14 +02:00
HandlingPattern const&
Command::getDefaultHandlingPattern() const
{
UNIMPLEMENTED ("manage the default command handling pattern");
}
2009-07-25 19:21:50 +02:00
template<typename TYPES>
void
Command::bindArg (Tuple<TYPES> const& args)
{
UNIMPLEMENTED ("create an argument-binding, with runtime type check");
}
2009-07-24 17:50:14 +02:00
2009-06-08 04:46:07 +02:00
} // namespace control