Lumiera  0.pre.03
»edit your freedom«
ModelPortRegistry Class Reference

#include "steam/fixture/model-port-registry.hpp"

Description

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 ModelPortRegistryglobalInstance ()
 access the globally valid registry instance. More...
 
static ModelPortRegistrysetActiveInstance (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, ModelPortDescriptorMPTable
 
typedef ID< PipePID
 
typedef ID< StructStID
 

Private Attributes

MPTable currentReg_
 
MPTable transaction_
 

Static Private Attributes

static lib::OptionalRef< ModelPortRegistrytheGlobalRegistry
 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
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Member Function Documentation

◆ setActiveInstance()

ModelPortRegistry * setActiveInstance ( ModelPortRegistry newRegistry)
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

Returns
the registry instance previously in use or NULL

Definition at line 83 of file model-port-registry.cpp.

References ModelPortRegistry::theGlobalRegistry.

Referenced by SimulatedBuilderContext::~SimulatedBuilderContext(), and TestContext::~TestContext().

+ Here is the caller graph for this function:

◆ globalInstance()

ModelPortRegistry & globalInstance ( )
static

access the globally valid registry instance.

Exceptions
error::Stateif 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().

+ Here is the caller graph for this function:

◆ accessDescriptor()

MPDescriptor accessDescriptor ( PID  )
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

Exceptions
error::Statewhen registry is down or the model port is disconnected
error::Logicwhen 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().

+ Here is the caller graph for this function:

◆ contains()

bool contains ( PID  ) const

does the transaction currently being built already contain a model port registration for the given ID?

Note
this does not query registration state of the global registry; use isRegistered for that...

Definition at line 116 of file model-port-registry.cpp.

Referenced by ModelPortRegistry::definePort().

+ Here is the caller graph for this function:

◆ isRegistered()

bool isRegistered ( PID  ) const
Returns
true if the given pipe-ID actually denotes an existing, connected and usable model port.
Note
reflects the state of the publicly visible model port registry, not any model ports being registered within a pending transaction (ongoing build process).

Definition at line 130 of file model-port-registry.cpp.

Referenced by ModelPort::exists().

+ Here is the caller graph for this function:

◆ get()

MPDescriptor get ( PID  ) const

basic access operation: access the descriptor of a currently valid model port.

Note
no locking (but accessDescriptor does lock!)
Exceptions
error::Logicif accessing a non registered port
error::Stateif accessing an invalid / disconnected port

Definition at line 144 of file model-port-registry.cpp.

Referenced by WrappedStandardExeBuilder::__call__().

+ Here is the caller graph for this function:

◆ clear()

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.

◆ commit()

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

Note
automatically starts a new transaction, initialised with the now published mappings.

Definition at line 218 of file model-port-registry.cpp.

◆ rollback()

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.

+ Inheritance diagram for ModelPortRegistry:
+ Collaboration diagram for ModelPortRegistry:

The documentation for this class was generated from the following files: