Go to the documentation of this file.
16 #ifndef SURGSIM_FRAMEWORK_RUNTIME_H
17 #define SURGSIM_FRAMEWORK_RUNTIME_H
19 #include <boost/thread/mutex.hpp>
36 class ApplicationData;
38 class ComponentManager;
49 class Runtime :
public std::enable_shared_from_this<Runtime>
66 void addManager(std::shared_ptr<ComponentManager> thread);
69 std::vector<std::weak_ptr<ComponentManager>>
getManagers()
const;
79 std::shared_ptr<Scene>
getScene()
const;
91 bool start(
bool paused =
false);
133 void addComponent(
const std::shared_ptr<Component>& component);
188 void addComponents(
const std::vector<std::shared_ptr<SurgSim::Framework::Component>>& components);
201 std::vector<std::shared_ptr<SceneElement>>* elements);
223 std::shared_ptr<T> result;
224 for (
auto& manager : m_managers)
226 result = std::dynamic_pointer_cast<T>(manager);
227 if (result !=
nullptr)
245 #endif // SURGSIM_FRAMEWORK_RUNTIME_H
bool m_isPaused
Definition: Runtime.h:214
void resume()
Resume from pause, causes all managers to resume normal processing.
Definition: Runtime.cpp:240
void saveScene(const std::string &fileName) const
Write out the whole scene as a file.
Definition: Runtime.cpp:480
std::shared_ptr< T > getManager() const
Definition: Runtime.h:221
void loadScene(const std::string &fileName)
Loads the scene from the given file, clears all the elements in the scene, the old scene will be over...
Definition: Runtime.cpp:358
void addComponents(const std::vector< std::shared_ptr< SurgSim::Framework::Component >> &components)
Adds the components.
Definition: Runtime.cpp:104
bool m_isStopped
Definition: Runtime.h:216
static std::shared_ptr< const ApplicationData > getApplicationData()
Gets application data for the runtime.
Definition: Runtime.cpp:321
Runtime()
Default constructor.
Definition: Runtime.cpp:38
bool execute()
Start all the threads and block until one of them quits.
Definition: Runtime.cpp:125
static std::shared_ptr< ThreadPool > getThreadPool()
Gets the thread pool for the runtime.
Definition: Runtime.cpp:328
Definition: DataStructuresConvert.h:28
Definition: CompoundShapeToGraphics.cpp:29
void initSearchPaths(const std::string &configFilePath)
Initializes the search paths.
Definition: Runtime.cpp:307
std::vector< std::weak_ptr< ComponentManager > > getManagers() const
Definition: Runtime.cpp:72
static std::shared_ptr< ApplicationData > m_applicationData
Definition: Runtime.h:209
bool isPaused() const
Query if this object is paused.
Definition: Runtime.cpp:269
void step()
Make all managers execute 1 update loop, afterwards they will wait for another step() call or resume(...
Definition: Runtime.cpp:256
bool tryConvertElements(const std::string &fileName, const YAML::Node &node, std::vector< std::shared_ptr< SceneElement >> *elements)
Convert nodes to vector of elements.
Definition: Runtime.cpp:449
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:60
~Runtime()
Destructor.
Definition: Runtime.cpp:54
bool start(bool paused=false)
Start all the threads non returns after the startup as succeeded.
Definition: Runtime.cpp:149
std::shared_ptr< Barrier > m_barrier
Definition: Runtime.h:213
bool isRunning() const
Query if this object is running.
Definition: Runtime.cpp:264
std::vector< std::shared_ptr< SceneElement > > duplicateSceneElements(const std::string &fileName)
Loads and duplicates the scene elements from the file, the elements will not have common ids with any...
Definition: Runtime.cpp:396
void addComponent(const std::shared_ptr< Component > &component)
Adds a component.
Definition: Runtime.cpp:334
std::shared_ptr< Runtime > getSharedPtr()
Gets a shared pointer to the runtime.
Definition: Runtime.cpp:293
void removeComponent(const std::shared_ptr< Component > &component)
Removes the component described by component.
Definition: Runtime.cpp:345
void preprocessSceneElements()
Preprocess scene elements.
Definition: Runtime.cpp:274
bool m_isRunning
Definition: Runtime.h:206
This class contains all the information about the runtime environment of the simulation,...
Definition: Runtime.h:49
void addSceneElements(const std::string &fileName)
Adds the scene elements from the file to the current scene The file format should be just a list of s...
Definition: Runtime.cpp:375
std::shared_ptr< Scene > m_scene
Definition: Runtime.h:208
std::vector< std::shared_ptr< ComponentManager > > m_managers
Definition: Runtime.h:207
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
bool tryLoadNode(const std::string &fileName, YAML::Node *node)
Perform a YAML load operation.
Definition: Runtime.cpp:424
bool addSceneElement(std::shared_ptr< SceneElement > sceneElement)
Adds a scene element.
Definition: Runtime.cpp:92
boost::mutex m_sceneHandling
Definition: Runtime.h:211
bool stop()
Stops the simulation.
Definition: Runtime.cpp:191
void pause()
Pause all managers, this will set all managers to synchronous execution, they will all complete their...
Definition: Runtime.cpp:231
std::shared_ptr< Scene > getScene()
Definition: Runtime.cpp:82