Lumiera
0.pre.03
»edit your freedom«
|
#include "steam/fixture/model-port-registry.hpp"
Management facility for tracking model ports.
ModelPort handles are exposed as frontend for usage by client code. Model ports are discovered by the builder when re-creating the low-level model; during such an ongoing build process, newly discovered ports are accumulated within a transaction, which then gets committed atomically when the new model is complete and ready for use.
Definition at line 79 of file model-port-registry.hpp.
Public Member Functions | |
void | clear () |
schedule removal of all registry contents. More... | |
void | commit () |
activate pending model port changes. More... | |
bool | contains (PID) const |
does the transaction currently being built already contain a model port registration for the given ID? More... | |
ModelPortDescriptor const & | definePort (PID pipe, StID element_exposing_this_port) |
create and register a new model port entry, within the pending transaction | |
ModelPortDescriptor const & | get (PID) const |
basic access operation: access the descriptor of a currently valid model port. More... | |
bool | isRegistered (PID) const |
void | remove (PID) |
remove a model port entry from the pending transaction | |
void | rollback () |
discard pending changes. More... | |
Static Public Member Functions | |
static ModelPortDescriptor const & | accessDescriptor (PID) |
access the globally valid model port for the given pipe. More... | |
static ModelPortRegistry & | globalInstance () |
access the globally valid registry instance. More... | |
static ModelPortRegistry * | setActiveInstance (ModelPortRegistry &newRegistry) |
switch the implicit link to the global ModelPort registry to point to the given implementation instance. More... | |
static void | shutdown () |
globally deactivate access to model ports | |
Classes | |
class | ModelPortDescriptor |
ModelPortDescriptor records are used as actual storage within the model port registration table; they are immutable value objects and never exposed to client code directly. More... | |
Private Types | |
typedef std::map< PID, ModelPortDescriptor > | MPTable |
typedef ID< Pipe > | PID |
typedef ID< Struct > | StID |
Private Attributes | |
MPTable | currentReg_ |
MPTable | transaction_ |
Static Private Attributes | |
static lib::OptionalRef< ModelPortRegistry > | theGlobalRegistry |
storage for the link to the global Registry instance currently in charge | |
Additional Inherited Members | |
Private Member Functions inherited from NonCopyable | |
NonCopyable (NonCopyable const &)=delete | |
NonCopyable & | operator= (NonCopyable const &)=delete |
|
static |
switch the implicit link to the global ModelPort registry to point to the given implementation instance.
Typically used within the Builder subsystem lifecycle methods, or for temporarily exchanging the registry for unit tests
NULL
Definition at line 83 of file model-port-registry.cpp.
References ModelPortRegistry::theGlobalRegistry.
Referenced by SimulatedBuilderContext::~SimulatedBuilderContext(), and TestContext::~TestContext().
|
static |
access the globally valid registry instance.
error::State | if this global registry is already closed or not yet initialised. |
Definition at line 99 of file model-port-registry.cpp.
References ModelPortRegistry::theGlobalRegistry.
Referenced by ModelPort::exists().
|
static |
access the globally valid model port for the given pipe.
This (static) function locks and accesses the global model port registry to fetch the descriptor record. Typically invoked by client code through the ModelPort frontend
error::State | when registry is down or the model port is disconnected |
error::Logic | when the given key wasn't registered for a model port |
Definition at line 167 of file model-port-registry.cpp.
References ModelPortRegistry::theGlobalRegistry.
Referenced by ModelPort::holder(), ModelPort::ModelPort(), and ModelPort::pipe().
bool contains | ( | PID | ) | const |
does the transaction currently being built already contain a model port registration for the given ID?
Definition at line 116 of file model-port-registry.cpp.
Referenced by ModelPortRegistry::definePort().
bool isRegistered | ( | PID | ) | const |
Definition at line 130 of file model-port-registry.cpp.
Referenced by ModelPort::exists().
MPDescriptor get | ( | PID | ) | const |
basic access operation: access the descriptor of a currently valid model port.
error::Logic | if accessing a non registered port |
error::State | if accessing an invalid / disconnected port |
Definition at line 144 of file model-port-registry.cpp.
Referenced by WrappedStandardExeBuilder::__call__().
void clear | ( | ) |
schedule removal of all registry contents.
When the currently pending transaction is committed, all registered model ports will be removed
Definition at line 204 of file model-port-registry.cpp.
void commit | ( | ) |
activate pending model port changes.
transactional switch for new/modified model ports.
Any accumulated changes and newly defined model ports are promoted to become part of the current active configuration with a single atomic (transactional) switch.
Promote the registered model ports from the currently pending transaction to become the globally valid model ports
Definition at line 218 of file model-port-registry.cpp.
void rollback | ( | ) |
discard pending changes.
discard current transaction.
Silently drop model port definition changes since the last commit.
The global port registration thus remains unaltered.
Definition at line 232 of file model-port-registry.cpp.
References LUMIERA_ERROR_DEFINE.