factor out generic map based state manager implementation

This commit is contained in:
Fischlurch 2016-02-13 14:33:27 +01:00
parent 15c1343fae
commit c54dfd6a94
2 changed files with 72 additions and 63 deletions

View file

@ -40,10 +40,11 @@
#include "lib/error.hpp"
//#include "gui/ctrl/bus-term.hpp"
//#include "lib/idi/entry-id.hpp"
#include "lib/idi/entry-id.hpp"
#include "lib/diff/gen-node.hpp"
#include "gui/interact/presentation-state-manager.hpp"
#include "gui/interact/state-map-grouping-storage.hpp"
#include "gui/ctrl/bus-term.hpp"
//#include "lib/symbol.hpp"
//#include "lib/util.hpp"
@ -56,21 +57,82 @@ namespace interact {
// using lib::HashVal;
// using util::isnil;
using gui::ctrl::BusTerm;
using lib::diff::GenNode;
using std::string;
using ID = lib::idi::BareEntryID;
/**
* Map storage for captured presentation state information.
* Simple map based implementation of the
* PresentationStateManager interface.
*
* @todo write type comment...
*/
class StateRecorder
: boost::noncopyable
: public PresentationStateManager
{
protected:
StateMapGroupingStorage storage_;
BusTerm& uiBusConnection_;
/* === PresentationStateManager interface === */
virtual lib::diff::GenNode const&
currentState (string elementSymbol, string propertyID) const override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayState (string elementSymbol, string propertyID) override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayAllState() override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayAllState (string propertyID) override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayAllProperties (string elementSymbol) override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
clearState() override
{
UNIMPLEMENTED ("discard all stored state information");
}
public:
StateRecorder (BusTerm& busConnection)
: uiBusConnection_(busConnection)
, storage_()
{ }
private:
void
record (ID const& elementID, lib::diff::GenNode const& stateMark)
{
UNIMPLEMENTED ("handle and record a state mark message");
}
};

View file

@ -49,7 +49,7 @@
#include "test/test-nexus.hpp"
#include "lib/test/event-log.hpp"
#include "gui/ctrl/nexus.hpp"
#include "gui/interact/state-map-grouping-storage.hpp"
#include "gui/interact/state-recorder.hpp"
#include "proc/control/command.hpp"
#include "lib/diff/gen-node.hpp"
#include "lib/idi/entry-id.hpp"
@ -76,7 +76,7 @@ using lib::idi::instanceTypeID;
using lib::test::EventLog;
using gui::ctrl::BusTerm;
using gui::interact::PresentationStateManager;
using gui::interact::StateMapGroupingStorage;
using gui::interact::StateRecorder;
using proc::control::Command;
using proc::control::CommandImpl;
using proc::control::HandlingPattern;
@ -555,68 +555,15 @@ namespace test{
using ID = lib::idi::BareEntryID;
class SimulatedStateManager
: public PresentationStateManager
: public StateRecorder
{
StateMapGroupingStorage state_;
BusTerm& uiBus_;
/* === PresentationStateManager interface === */
virtual lib::diff::GenNode const&
currentState (string elementSymbol, string propertyID) const override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayState (string elementSymbol, string propertyID) override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayAllState() override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayAllState (string propertyID) override
{
UNIMPLEMENTED ("retrieve captured state");
}
virtual void
replayAllProperties (string elementSymbol) override
{
UNIMPLEMENTED ("retrieve captured state");
}
public:
SimulatedStateManager()
: state_()
, uiBus_(testNexus())
: StateRecorder{testNexus()}
{ }
virtual void
clearState() override
{
UNIMPLEMENTED ("discard all stored state information");
}
void
record (ID const& elementID, lib::diff::GenNode const& stateMark)
{
UNIMPLEMENTED ("handle and record a state mark message");
}
using PresentationStateManager::clearState;
};
lib::Depend<SimulatedStateManager> stateManager;