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>
60 explicit Runtime(
const std::string& configFilePath);
66 void addManager(std::shared_ptr<ComponentManager> thread);
69 std::vector<std::weak_ptr<ComponentManager>> getManagers()
const;
73 std::shared_ptr<T> getManager()
const;
76 std::shared_ptr<Scene> getScene();
79 std::shared_ptr<Scene> getScene()
const;
84 bool addSceneElement(std::shared_ptr<SceneElement> sceneElement);
91 bool start(
bool paused =
false);
117 bool isRunning()
const;
121 bool isPaused()
const;
125 static std::shared_ptr<const ApplicationData> getApplicationData();
129 static std::shared_ptr<ThreadPool> getThreadPool();
133 void addComponent(
const std::shared_ptr<Component>& component);
137 void removeComponent(
const std::shared_ptr<Component>& component);
143 void loadScene(
const std::string& fileName);
165 void addSceneElements(
const std::string& fileName);
173 std::vector<std::shared_ptr<SceneElement>> duplicateSceneElements(
const std::string& fileName);
177 void saveScene(
const std::string& fileName)
const;
183 void preprocessSceneElements();
188 void addComponents(
const std::vector<std::shared_ptr<SurgSim::Framework::Component>>& components);
193 void initSearchPaths(
const std::string& configFilePath);
200 bool tryConvertElements(
const std::string& fileName,
const YAML::Node& node,
201 std::vector<std::shared_ptr<SceneElement>>* elements);
205 std::shared_ptr<Runtime> getSharedPtr();
223 std::shared_ptr<T> result;
224 for (
auto& manager : m_managers)
226 result = std::dynamic_pointer_cast<T>(manager);
227 if (result !=
nullptr)
239 bool tryLoadNode(
const std::string& fileName, YAML::Node* node);
245 #endif // SURGSIM_FRAMEWORK_RUNTIME_H Definition: CompoundShapeToGraphics.cpp:29
std::vector< std::shared_ptr< ComponentManager > > m_managers
Definition: Runtime.h:207
bool tryLoadNode(const std::string &fileName, YAML::Node *node)
Perform a YAML load operation.
Definition: Runtime.cpp:424
bool m_isStopped
Definition: Runtime.h:216
bool m_isRunning
Definition: Runtime.h:206
std::shared_ptr< T > getManager() const
Definition: Runtime.h:221
boost::mutex m_sceneHandling
Definition: Runtime.h:211
bool m_isPaused
Definition: Runtime.h:214
Definition: DataStructuresConvert.h:28
std::shared_ptr< Barrier > m_barrier
Definition: Runtime.h:213
std::shared_ptr< Scene > m_scene
Definition: Runtime.h:208
static std::shared_ptr< ApplicationData > m_applicationData
Definition: Runtime.h:209
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:49