WIP towards CommandRegistry implementation
This commit is contained in:
parent
4517766517
commit
c9f3a345dc
2 changed files with 20 additions and 3 deletions
|
|
@ -51,14 +51,18 @@
|
||||||
#include "proc/control/typed-allocation-manager.hpp"
|
#include "proc/control/typed-allocation-manager.hpp"
|
||||||
//#include "proc/control/memento-tie.hpp"
|
//#include "proc/control/memento-tie.hpp"
|
||||||
|
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <tr1/unordered_map>
|
||||||
#include <tr1/memory>
|
#include <tr1/memory>
|
||||||
//#include <iostream>
|
//#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace control {
|
namespace control {
|
||||||
|
|
||||||
|
using boost::noncopyable;
|
||||||
using std::tr1::shared_ptr;
|
using std::tr1::shared_ptr;
|
||||||
// using std::ostream;
|
// using std::ostream;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
@ -71,9 +75,16 @@ namespace control {
|
||||||
*/
|
*/
|
||||||
class CommandRegistry
|
class CommandRegistry
|
||||||
: public lib::Sync<>
|
: public lib::Sync<>
|
||||||
|
, noncopyable
|
||||||
{
|
{
|
||||||
TypedAllocationManager allocator_;
|
TypedAllocationManager allocator_;
|
||||||
|
|
||||||
|
typedef std::tr1::unordered_map<Symbol, Command> CmdIndex;
|
||||||
|
typedef std::map<void*, Symbol> ReverseIndex;
|
||||||
|
|
||||||
|
CmdIndex index_;
|
||||||
|
ReverseIndex ridx_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static lumiera::Singleton<CommandRegistry> instance;
|
static lumiera::Singleton<CommandRegistry> instance;
|
||||||
|
|
@ -87,6 +98,14 @@ namespace control {
|
||||||
{
|
{
|
||||||
Lock sync(this);
|
Lock sync(this);
|
||||||
UNIMPLEMENTED ("place a commandHandle into the command index, or return the command already registered there");
|
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& ??
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,7 @@ namespace test {
|
||||||
// represented internally by a prototype instance
|
// represented internally by a prototype instance
|
||||||
ASSERT (1+cnt_inst == registry.instance_count());
|
ASSERT (1+cnt_inst == registry.instance_count());
|
||||||
cnt_inst++;
|
cnt_inst++;
|
||||||
|
|
||||||
UNIMPLEMENTED ("cover all relevant API functions");
|
|
||||||
checkRegistration (registry);
|
checkRegistration (registry);
|
||||||
checkAllocation(registry);
|
checkAllocation(registry);
|
||||||
|
|
||||||
|
|
@ -226,7 +225,6 @@ namespace test {
|
||||||
ASSERT (!isSameObject (*pImpl, *clone));
|
ASSERT (!isSameObject (*pImpl, *clone));
|
||||||
ASSERT (*pImpl == *clone);
|
ASSERT (*pImpl == *clone);
|
||||||
|
|
||||||
///////////////////////////////////////////////TODO: maybe do a simulated command lifecycle here?
|
|
||||||
ASSERT (!pImpl->canExec());
|
ASSERT (!pImpl->canExec());
|
||||||
typedef Types<int> ArgType;
|
typedef Types<int> ArgType;
|
||||||
TypedArguments<Tuple<ArgType> > arg (Tuple<ArgType>(98765));
|
TypedArguments<Tuple<ArgType> > arg (Tuple<ArgType>(98765));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue