AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxPowerLine::PowerLineController Class Reference

Each type of physical dimension handled by the power line has to have a unique name. More...

#include <PowerLineController.h>

+ Inheritance diagram for agxPowerLine::PowerLineController:

Public Types

typedef std::function< Connector *()> ConnectorFactory
 
- Public Types inherited from agx::Singleton
enum  Priority { HIGHEST_PRIORITY = 2147483647 , LOWEST_PRIORITY = 10000 , DEFAULT_PRIORITY = 1073741824 }
 Specifies the ranges of the priority which can be assigned to a singleton at the time of creation. More...
 

Public Member Functions

void add (agxPowerLine::Connector *connector)
 The PowerLineController is in charge of keeping reference pointers to connectors that are created but not added to the simulation yet.
 
bool addPhysicalDimension (std::string name)
 Add a named physical dimension.
 
void clearStoredPhysicalDimensionIds ()
 Clear the stored-to-current type ID mappings so that future PowerLine restores doesn't accidentally use stored IDs from the previous restore.
 
agxPowerLine::Connector * createConnector (agxPowerLine::PhysicalDimension::Type inputType, agxPowerLine::PhysicalDimension::Type outputType) const
 
int getCurrentPhysicalDimensionId (int storedId)
 Converts a stored PhysicalDimension type ID to the corresponding ID for the current PowerLineController.
 
int getDimensionType (std::string name)
 
std::string getDimensionTypeName (size_t id)
 
agxPowerLine::PhysicalDimension::Type getNumberOfPhysicalDimensions ()
 
bool getPowerLines (agxSDK::Simulation *simulation, PowerLinePtrVector &powerLines)
 
int getStoredPhysicalDimensionId (int currentId)
 Usable during restore of power line to map between indices in PhysicalDimension::m_dimensions.
 
bool hasStoredDimensionsMappings () const
 Return true if mappings for stored dimensions IDs has been configured.
 
void registerDefaultConnector (agxPowerLine::PhysicalDimension::Type inputType, agxPowerLine::PhysicalDimension::Type outputType, ConnectorFactory connectorCreator)
 
void remove (agxPowerLine::Connector *connector)
 
void setStoredPhysicalDimensionId (int currentId, int previousId)
 Used while preparing power line for being restored.
 
- Public Member Functions inherited from agx::Singleton
 Singleton (int priority=DEFAULT_PRIORITY)
 Default constructor.
 
virtual std::string getClassName () const =0
 
int getPriority () const
 Return the shutdown priority of the singleton instance.
 
virtual void shutdown ()=0
 Implement this method to cleanup your Singleton class.
 

Static Public Member Functions

static PowerLineController * instance ()
 
static bool isInitialized ()
 

Protected Types

typedef agx::HashTable< DimTypePair, ConnectorFactory > ConnectorFactoryTable
 
typedef agx::HashTable< std::string, int > DimensionNameIdTable
 
typedef agx::SymmetricPair< agxPowerLine::PhysicalDimension::Type > DimTypePair
 
typedef agx::HashTable< agxSDK::Simulation *, PowerLinesHandlerRef > SimulationPowerLinesHash
 

Protected Member Functions

 PowerLineController ()
 
virtual ~PowerLineController ()
 
DimensionNameIdTable::iterator findIndex (int index)
 
void replaceIndexWhenRestoring (std::string name, int index)
 
virtual void shutdown () override
 Implement this method to cleanup your Singleton class.
 
- Protected Member Functions inherited from agx::Singleton
virtual ~Singleton ()
 Destructor.
 
void _shutdown ()
 

Protected Attributes

ConnectorFactoryTable m_connectorFactories
 
DimensionNameIdTable m_nameIdTable
 
SimulationPowerLinesHash m_powerLinesInSimulation
 
agx::HashVector< int, int > m_storeRestoreIdTranslator
 

Detailed Description

Each type of physical dimension handled by the power line has to have a unique name.

When a physical dimension object is created its unique name will be indexed and hashed in the power line dimension name singleton.

The indices could as well be a pre defined enum. But then each new implementation of a physical dimension would have to be added to the enum and AGX would have to be recompiled.

Using this approach a user with only the agx binaries and .h files can add his own physical dimension.

Definition at line 88 of file PowerLineController.h.

Member Typedef Documentation

◆ ConnectorFactory

Definition at line 91 of file PowerLineController.h.

◆ ConnectorFactoryTable

◆ DimensionNameIdTable

Definition at line 204 of file PowerLineController.h.

◆ DimTypePair

◆ SimulationPowerLinesHash

Constructor & Destructor Documentation

◆ PowerLineController()

agxPowerLine::PowerLineController::PowerLineController ( )
protected

◆ ~PowerLineController()

virtual agxPowerLine::PowerLineController::~PowerLineController ( )
protectedvirtual

Member Function Documentation

◆ add()

void agxPowerLine::PowerLineController::add ( agxPowerLine::Connector *  connector)

The PowerLineController is in charge of keeping reference pointers to connectors that are created but not added to the simulation yet.

This is needed since ConnectOperations creates default connectors that are hidden to the user.

◆ addPhysicalDimension()

bool agxPowerLine::PowerLineController::addPhysicalDimension ( std::string  name)

Add a named physical dimension.

(introduce it to the name singleton and the simulation).

◆ clearStoredPhysicalDimensionIds()

void agxPowerLine::PowerLineController::clearStoredPhysicalDimensionIds ( )

Clear the stored-to-current type ID mappings so that future PowerLine restores doesn't accidentally use stored IDs from the previous restore.

◆ createConnector()

agxPowerLine::Connector * agxPowerLine::PowerLineController::createConnector ( agxPowerLine::PhysicalDimension::Type  inputType,
agxPowerLine::PhysicalDimension::Type  outputType 
) const

◆ findIndex()

DimensionNameIdTable::iterator agxPowerLine::PowerLineController::findIndex ( int  index)
protected

◆ getCurrentPhysicalDimensionId()

int agxPowerLine::PowerLineController::getCurrentPhysicalDimensionId ( int  storedId)

Converts a stored PhysicalDimension type ID to the corresponding ID for the current PowerLineController.

If no mapping has been registered for the given ID then agx::InvalidIndex is returned.

Parameters
storedIdA PhysicalDimension type ID read from a serialization.
Returns
The PhysicalDimension type ID currently used for the same dimension type.

◆ getDimensionType()

int agxPowerLine::PowerLineController::getDimensionType ( std::string  name)
Returns
the indexed value for a named physical dimension. Will index a non existing name by a call to bool addPhysicalDimension(std::string name);
-1 if the name is not indexed and the name fails to be indexed(how?).

◆ getDimensionTypeName()

std::string agxPowerLine::PowerLineController::getDimensionTypeName ( size_t  id)
Returns
the name (string) of the physical dimension with ID

◆ getNumberOfPhysicalDimensions()

agxPowerLine::PhysicalDimension::Type agxPowerLine::PowerLineController::getNumberOfPhysicalDimensions ( )
Returns
the number of different types of physical dimensions introduced (added) to the simulation

◆ getPowerLines()

bool agxPowerLine::PowerLineController::getPowerLines ( agxSDK::Simulation *  simulation,
PowerLinePtrVector &  powerLines 
)

◆ getStoredPhysicalDimensionId()

int agxPowerLine::PowerLineController::getStoredPhysicalDimensionId ( int  currentId)

Usable during restore of power line to map between indices in PhysicalDimension::m_dimensions.

If there is no mapping then agx::InvalidIndex is returned.

Parameters
currentId- The id for the physical dimension in this simulation.
Returns
The id of a specific physical dimension id, what it was in the stored simulation.

◆ hasStoredDimensionsMappings()

bool agxPowerLine::PowerLineController::hasStoredDimensionsMappings ( ) const

Return true if mappings for stored dimensions IDs has been configured.

False otherwise.

The mappings are controlled by PowerLine and configured during PowerLine:: restore. Mappings are unavailable if PowerLine components are serialized without going via a PowerLine.

◆ instance()

static PowerLineController * agxPowerLine::PowerLineController::instance ( )
static
Returns
a pointer to the PowerLineDimensionNameSingleton singleton.

◆ isInitialized()

static bool agxPowerLine::PowerLineController::isInitialized ( )
static
Returns
true if Singleton is initialized (instance() returns != 0)

◆ registerDefaultConnector()

void agxPowerLine::PowerLineController::registerDefaultConnector ( agxPowerLine::PhysicalDimension::Type  inputType,
agxPowerLine::PhysicalDimension::Type  outputType,
ConnectorFactory  connectorCreator 
)

◆ remove()

void agxPowerLine::PowerLineController::remove ( agxPowerLine::Connector *  connector)

◆ replaceIndexWhenRestoring()

void agxPowerLine::PowerLineController::replaceIndexWhenRestoring ( std::string  name,
int  index 
)
protected

◆ setStoredPhysicalDimensionId()

void agxPowerLine::PowerLineController::setStoredPhysicalDimensionId ( int  currentId,
int  previousId 
)

Used while preparing power line for being restored.

Parameters
currentId- the id for the physical dimension in this simulation
previousId- the id for the physical dimension in the restored simulation

◆ shutdown()

virtual void agxPowerLine::PowerLineController::shutdown ( )
overrideprotectedvirtual

Implement this method to cleanup your Singleton class.

Implements agx::Singleton.

Member Data Documentation

◆ m_connectorFactories

ConnectorFactoryTable agxPowerLine::PowerLineController::m_connectorFactories
protected

Definition at line 224 of file PowerLineController.h.

◆ m_nameIdTable

DimensionNameIdTable agxPowerLine::PowerLineController::m_nameIdTable
protected

Definition at line 216 of file PowerLineController.h.

◆ m_powerLinesInSimulation

SimulationPowerLinesHash agxPowerLine::PowerLineController::m_powerLinesInSimulation
protected

Definition at line 220 of file PowerLineController.h.

◆ m_storeRestoreIdTranslator

agx::HashVector<int,int> agxPowerLine::PowerLineController::m_storeRestoreIdTranslator
protected

Definition at line 217 of file PowerLineController.h.


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