16 #ifndef SURGSIM_FRAMEWORK_RUNTIME_H
17 #define SURGSIM_FRAMEWORK_RUNTIME_H
24 #include <boost/thread/mutex.hpp>
31 class ApplicationData;
33 class ComponentManager;
43 class Runtime :
public std::enable_shared_from_this<Runtime>
54 explicit Runtime(
const std::string& configFilePath);
60 void addManager(std::shared_ptr<ComponentManager> thread);
66 std::shared_ptr<Scene>
getScene()
const;
78 bool start(
bool paused =
false);
116 void addComponent(
const std::shared_ptr<Component>& component);
131 void addComponents(
const std::vector<std::shared_ptr<SurgSim::Framework::Component>>& components);
156 #endif // SURGSIM_FRAMEWORK_RUNTIME_H
bool isPaused() const
Query if this object is paused.
Definition: Runtime.cpp:229
void pause()
Pause all managers, this will set all managers to synchronous execution, they will all complete their...
Definition: Runtime.cpp:191
Definition: DriveElementFromInputBehavior.cpp:27
bool isRunning() const
Query if this object is running.
Definition: Runtime.cpp:224
bool start(bool paused=false)
Start all the threads non returns after the startup as succeeded.
Definition: Runtime.cpp:134
bool addSceneElement(std::shared_ptr< SceneElement > sceneElement)
Adds a scene element.
Definition: Runtime.cpp:77
bool stop()
Stops the simulation.
Definition: Runtime.cpp:174
std::shared_ptr< Runtime > getSharedPtr()
Gets a shared pointer to the runtime.
Definition: Runtime.cpp:253
~Runtime()
Destructor.
Definition: Runtime.cpp:50
void initSearchPaths(const std::string &configFilePath)
Initializes the search paths.
Definition: Runtime.cpp:267
void removeComponent(const std::shared_ptr< Component > &component)
Removes the component described by component.
Definition: Runtime.cpp:299
void addManager(std::shared_ptr< ComponentManager > thread)
Add a worker thread, this should probably only be possible if the system is not running.
Definition: Runtime.cpp:56
bool m_isRunning
Definition: Runtime.h:142
void resume()
Resume from pause, causes all managers to resume normal processing.
Definition: Runtime.cpp:200
bool execute()
Start all the threads and block until one of them quits.
Definition: Runtime.cpp:110
void addComponents(const std::vector< std::shared_ptr< SurgSim::Framework::Component >> &components)
Adds the components.
Definition: Runtime.cpp:89
std::vector< std::shared_ptr< ComponentManager > > m_managers
Definition: Runtime.h:143
void preprocessSceneElements()
Preprocess scene elements.
Definition: Runtime.cpp:234
void step()
Make all managers execute 1 update loop, afterwards they will wait for another step() call or resume(...
Definition: Runtime.cpp:216
bool m_isPaused
Definition: Runtime.h:150
Runtime()
Default constructor.
Definition: Runtime.cpp:36
boost::mutex m_mutex
Definition: Runtime.h:147
std::shared_ptr< Scene > getScene()
Definition: Runtime.cpp:67
void addComponent(const std::shared_ptr< Component > &component)
Adds a component.
Definition: Runtime.cpp:288
std::shared_ptr< Barrier > m_barrier
Definition: Runtime.h:149
static std::shared_ptr< const ApplicationData > getApplicationData()
Gets application data for the runtime.
Definition: Runtime.cpp:281
std::shared_ptr< Scene > m_scene
Definition: Runtime.h:144
static std::shared_ptr< ApplicationData > m_applicationData
Definition: Runtime.h:145
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.
Definition: Runtime.h:43