WIP towards CommandRegistry implementation

This commit is contained in:
Fischlurch 2009-09-24 05:09:51 +02:00
parent 4517766517
commit c9f3a345dc
2 changed files with 20 additions and 3 deletions

View file

@ -51,14 +51,18 @@
#include "proc/control/typed-allocation-manager.hpp"
//#include "proc/control/memento-tie.hpp"
#include <boost/noncopyable.hpp>
#include <tr1/unordered_map>
#include <tr1/memory>
//#include <iostream>
#include <string>
#include <map>
namespace control {
using boost::noncopyable;
using std::tr1::shared_ptr;
// using std::ostream;
using std::string;
@ -71,9 +75,16 @@ namespace control {
*/
class CommandRegistry
: public lib::Sync<>
, noncopyable
{
TypedAllocationManager allocator_;
typedef std::tr1::unordered_map<Symbol, Command> CmdIndex;
typedef std::map<void*, Symbol> ReverseIndex;
CmdIndex index_;
ReverseIndex ridx_;
public:
static lumiera::Singleton<CommandRegistry> instance;
@ -87,6 +98,14 @@ namespace control {
{
Lock sync(this);
UNIMPLEMENTED ("place a commandHandle into the command index, or return the command already registered there");
Command& indexSlot (index_[cmdID]);
if (!indexSlot)
{
indexSlot = commandHandle;
ridx_[&indexSlot] = cmdID;
}
return indexSlot;
///////////////////////////TODO possible to return a const& ??
}

View file

@ -124,8 +124,7 @@ namespace test {
// represented internally by a prototype instance
ASSERT (1+cnt_inst == registry.instance_count());
cnt_inst++;
UNIMPLEMENTED ("cover all relevant API functions");
checkRegistration (registry);
checkAllocation(registry);
@ -226,7 +225,6 @@ namespace test {
ASSERT (!isSameObject (*pImpl, *clone));
ASSERT (*pImpl == *clone);
///////////////////////////////////////////////TODO: maybe do a simulated command lifecycle here?
ASSERT (!pImpl->canExec());
typedef Types<int> ArgType;
TypedArguments<Tuple<ArgType> > arg (Tuple<ArgType>(98765));