Base Component Manager class.
More...
#include <ComponentManager.h>
|
template<class T > |
std::shared_ptr< T > | tryAddComponent (std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container) |
| Template version of the addComponent method. More...
|
|
template<class T > |
bool | tryRemoveComponent (std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container) |
| Template version of the removeComponent method. More...
|
|
void | processComponents () |
| Processes all the components that are scheduled for addition or removal, this needs to be called inside the doUpdate() function. More...
|
|
void | processBehaviors (const double dt) |
| Processes behaviors This needs to be called inside doUpdate() function in each 'sub' manager. More...
|
|
virtual int | getType () const =0 |
| Returns the type of Manager.
|
|
void | copyScheduledComponents (std::vector< std::shared_ptr< Component >> *inflightAdditions, std::vector< std::shared_ptr< Component >> *inflightRemovals, std::vector< std::shared_ptr< SceneElement >> *inflightElements) |
| Helper, blocks access to the additions and removal queue and copies the components from there to the intermediate inflight queues, after this call, the incoming queues will be empty. More...
|
|
std::shared_ptr< SurgSim::Framework::Logger > | getLogger () const |
| Returns this manager's logger.
|
|
void | doBeforeStop () override |
| Prepares the thread for its execution to be stopped. More...
|
|
template<class T > |
void | retireComponents (const std::vector< std::shared_ptr< T >> &container) |
|
bool | initialize () |
| Trigger the initialization of this object, this will be called before all other threads doStartup() are called. More...
|
|
bool | startUp () |
| Trigger the startup of this object, this will be called after all other threads doInit() was called the thread will only enter the run loop triggering upated() if all threads doInit() and doStartup() returned true. More...
|
|
bool | waitForBarrier (bool success) |
|
Base Component Manager class.
Component Managers manage a collection of components. The runtime will present each new component to the manager, and it is up to the manger to decide whether to handle a component of a given type or not. Adding and removing components is thread-safe, when the [add|remove]Component call is made, the component is added to an intermediary data structure, each ComponentManager implementation must call processComponents() to trigger the actual addition and removal. Each ComponentManager subclass needs to implement doAddComponent() and doRemoveComponent() to the actual addition and removal of components. ComponentManager implements a custom executeInitialization() method that lets the runtime schedule initialization of components that exist at the start of the simulation
§ copyScheduledComponents()
void SurgSim::Framework::ComponentManager::copyScheduledComponents |
( |
std::vector< std::shared_ptr< Component >> * |
inflightAdditions, |
|
|
std::vector< std::shared_ptr< Component >> * |
inflightRemovals, |
|
|
std::vector< std::shared_ptr< SceneElement >> * |
inflightElements |
|
) |
| |
|
protected |
Helper, blocks access to the additions and removal queue and copies the components from there to the intermediate inflight queues, after this call, the incoming queues will be empty.
§ doBeforeStop()
void SurgSim::Framework::ComponentManager::doBeforeStop |
( |
| ) |
|
|
overrideprotectedvirtual |
§ enqueueAddComponent()
bool SurgSim::Framework::ComponentManager::enqueueAddComponent |
( |
const std::shared_ptr< Component > & |
component | ) |
|
Queues a component to be added later.
- Parameters
-
component | The component to be added. |
- Returns
- true if the component was scheduled for addition, this does not indicate that the component will actually be added to this manager
§ enqueueRemoveComponent()
bool SurgSim::Framework::ComponentManager::enqueueRemoveComponent |
( |
const std::shared_ptr< Component > & |
component | ) |
|
Queues a component to be removed.
- Parameters
-
component | The component to be removed. |
- Returns
- true if the component was scheduled for removal, this does not indicate that the component will actually be removed from this manager
§ getRuntime()
std::shared_ptr< Runtime > SurgSim::Framework::ComponentManager::getRuntime |
( |
| ) |
const |
§ processBehaviors()
void SurgSim::Framework::ComponentManager::processBehaviors |
( |
const double |
dt | ) |
|
|
protected |
Processes behaviors This needs to be called inside doUpdate() function in each 'sub' manager.
§ processComponents()
void SurgSim::Framework::ComponentManager::processComponents |
( |
| ) |
|
|
protected |
Processes all the components that are scheduled for addition or removal, this needs to be called inside the doUpdate() function.
§ tryAddComponent()
template<class T >
std::shared_ptr< T > SurgSim::Framework::ComponentManager::tryAddComponent |
( |
std::shared_ptr< SurgSim::Framework::Component > |
component, |
|
|
std::vector< std::shared_ptr< T >> * |
container |
|
) |
| |
|
protected |
Template version of the addComponent method.
Executes the add component operation.
- Template Parameters
-
T | Specific type of the component that is being added. |
- Parameters
-
| component | The component that needs to be added. |
[in,out] | container | If non-null, the container that should receive the component if of the correct type. |
- Returns
- the correctly cast component pointer if successful and the component did not already exist in the container
- Template Parameters
-
T | Type of the component to be added. |
- Parameters
-
| component | The component that is being added. |
[in,out] | container | The container that the component is being added to. |
- Returns
- The correctly cast component if it is of type T and does not exist in the container yet, nullptr otherwise.
§ tryRemoveComponent()
template<class T >
bool SurgSim::Framework::ComponentManager::tryRemoveComponent |
( |
std::shared_ptr< SurgSim::Framework::Component > |
component, |
|
|
std::vector< std::shared_ptr< T >> * |
container |
|
) |
| |
|
protected |
Template version of the removeComponent method.
- Template Parameters
-
T | Specific type of the component that is being removed. |
- Parameters
-
| component | The component that needs to be removed. |
[in,out] | container | If non-null, the container, from which the component should be removed. |
- Returns
- true if the component exists in the container or the component did not cast to T, otherwise.
§ m_componentAdditions
std::vector<std::shared_ptr<Component> > SurgSim::Framework::ComponentManager::m_componentAdditions |
|
protected |
Data structures Contain components scheduled to be added/removed
The documentation for this class was generated from the following files: