This class contains all the information about the runtime environment of the simulation, all the running threads, the state, while it is de facto a singleton it should be passed around if needed.
More...
#include <SurgSim/Framework/Runtime.h>
This class contains all the information about the runtime environment of the simulation, all the running threads, the state, while it is de facto a singleton it should be passed around if needed.
Needs to be created as a shared object.
SurgSim::Framework::Runtime::Runtime |
( |
| ) |
|
SurgSim::Framework::Runtime::Runtime |
( |
const std::string & |
configFilePath | ) |
|
|
explicit |
Constructor, initializes the search path with paths from the given file.
- Parameters
-
configFilePath | Full pathname of the configuration file that contains paths, one per line, to search for application data. If no config file is given "." will be used as default path. |
SurgSim::Framework::Runtime::~Runtime |
( |
| ) |
|
void SurgSim::Framework::Runtime::addComponent |
( |
const std::shared_ptr< Component > & |
component | ) |
|
Adds a component.
- Parameters
-
Adds the components.
- Parameters
-
components | The components. |
- Returns
- true if it succeeds, false if it fails.
void SurgSim::Framework::Runtime::addManager |
( |
std::shared_ptr< ComponentManager > |
thread | ) |
|
Add a worker thread, this should probably only be possible if the system is not running.
bool SurgSim::Framework::Runtime::addSceneElement |
( |
std::shared_ptr< SceneElement > |
sceneElement | ) |
|
Adds a scene element.
- Parameters
-
sceneElement | The scene element. |
- Returns
- true if it succeeds, false if it fails.
bool SurgSim::Framework::Runtime::execute |
( |
| ) |
|
Start all the threads and block until one of them quits.
std::shared_ptr< const ApplicationData > SurgSim::Framework::Runtime::getApplicationData |
( |
| ) |
|
|
static |
Gets application data for the runtime.
- Returns
- The application data.
std::shared_ptr< Scene > SurgSim::Framework::Runtime::getScene |
( |
| ) |
|
- Returns
- The scene to be used for this runtime. Use this for any kind of scene manipulation.
std::shared_ptr<Scene> SurgSim::Framework::Runtime::getScene |
( |
| ) |
const |
std::shared_ptr< Runtime > SurgSim::Framework::Runtime::getSharedPtr |
( |
| ) |
|
|
private |
Gets a shared pointer to the runtime.
- Returns
- The shared pointer.
void SurgSim::Framework::Runtime::initSearchPaths |
( |
const std::string & |
configFilePath | ) |
|
|
private |
Initializes the search paths.
- Parameters
-
configFilePath | Full pathname of the configuration file, if path is empty "." will be used as default path. |
bool SurgSim::Framework::Runtime::isPaused |
( |
| ) |
const |
Query if this object is paused.
- Returns
- true if paused, false if not.
bool SurgSim::Framework::Runtime::isRunning |
( |
| ) |
const |
Query if this object is running.
- Returns
- true if running, false if not.
void SurgSim::Framework::Runtime::pause |
( |
| ) |
|
Pause all managers, this will set all managers to synchronous execution, they will all complete their updates and then wait for step() to proceed, call resume to go back to uninterupted execution.
- Note
- HS-2013-nov-01 this is mostly to be used as a facillity for testing and debugging, the threads are not executed at the correct rates against each other, this is an issue that can be resolved but is not necessary right now.
void SurgSim::Framework::Runtime::preprocessSceneElements |
( |
| ) |
|
|
private |
Preprocess scene elements.
This is called during the startup sequence and installs all the Components of the SceneElements in the worker threads
void SurgSim::Framework::Runtime::removeComponent |
( |
const std::shared_ptr< Component > & |
component | ) |
|
Removes the component described by component.
- Parameters
-
void SurgSim::Framework::Runtime::resume |
( |
| ) |
|
Resume from pause, causes all managers to resume normal processing.
- Warning
- This function is not thread safe, if stop is called when there are threads that are not waiting, this call will hang indefinitely.
bool SurgSim::Framework::Runtime::start |
( |
bool |
paused = false | ) |
|
Start all the threads non returns after the startup as succeeded.
- Returns
- true if it succeeds, false if it fails.
void SurgSim::Framework::Runtime::step |
( |
| ) |
|
Make all managers execute 1 update loop, afterwards they will wait for another step() call or resume()
bool SurgSim::Framework::Runtime::stop |
( |
| ) |
|
Stops the simulation.
The call will wait for all the threads to finish, except for any threads that have been detached.
- Warning
- This function is not thread safe, if stop is called when there are threads that are not waiting, this call will hang indefinitely.
- Returns
- true if it succeeds, false if it fails.
std::shared_ptr< ApplicationData > SurgSim::Framework::Runtime::m_applicationData |
|
staticprivate |
std::shared_ptr<Barrier> SurgSim::Framework::Runtime::m_barrier |
|
private |
bool SurgSim::Framework::Runtime::m_isPaused |
|
private |
bool SurgSim::Framework::Runtime::m_isRunning |
|
private |
std::vector< std::shared_ptr<ComponentManager> > SurgSim::Framework::Runtime::m_managers |
|
private |
boost::mutex SurgSim::Framework::Runtime::m_mutex |
|
private |
std::shared_ptr<Scene> SurgSim::Framework::Runtime::m_scene |
|
private |
The documentation for this class was generated from the following files: