16 #ifndef SURGSIM_FRAMEWORK_RUNTIME_H 17 #define SURGSIM_FRAMEWORK_RUNTIME_H 19 #include <boost/thread/mutex.hpp> 20 #include <boost/thread/thread.hpp> 27 #include "SurgSim/Framework/Messenger.h" 40 class ApplicationData;
42 class ComponentManager;
53 class Runtime :
public std::enable_shared_from_this<Runtime>
64 explicit Runtime(
const std::string& configFilePath);
70 void addManager(std::shared_ptr<ComponentManager> thread);
73 std::vector<std::weak_ptr<ComponentManager>> getManagers()
const;
77 std::shared_ptr<T> getManager()
const;
83 std::shared_ptr<Scene> getScene();
86 std::shared_ptr<Scene> getScene()
const;
91 bool addSceneElement(std::shared_ptr<SceneElement> sceneElement);
98 bool start(
bool paused =
false);
124 bool isRunning()
const;
128 bool isPaused()
const;
132 static std::shared_ptr<const ApplicationData> getApplicationData();
136 static std::shared_ptr<ThreadPool> getThreadPool();
142 void addComponent(
const std::shared_ptr<Component>& component);
146 void removeComponent(
const std::shared_ptr<Component>& component);
152 void loadScene(
const std::string& fileName);
174 void addSceneElements(
const std::string& fileName);
182 std::vector<std::shared_ptr<SceneElement>> duplicateSceneElements(
const std::string& fileName);
186 void saveScene(
const std::string& fileName)
const;
192 void preprocessSceneElements();
197 void addComponents(
const std::vector<std::shared_ptr<SurgSim::Framework::Component>>& components);
202 void initSearchPaths(
const std::string& configFilePath);
209 bool tryConvertElements(
const std::string& fileName,
const YAML::Node& node,
210 std::vector<std::shared_ptr<SceneElement>>* elements);
214 std::shared_ptr<Runtime> getSharedPtr();
215 std::atomic<bool> m_isRunning;
216 std::vector<std::shared_ptr<ComponentManager>> m_managers;
217 std::shared_ptr<Scene> m_scene;
218 static std::shared_ptr<ApplicationData> m_applicationData;
221 boost::thread m_messengerThread;
223 boost::mutex m_sceneHandling;
225 std::shared_ptr<Barrier> m_barrier;
236 std::shared_ptr<T> result;
237 for (
auto& manager : m_managers)
239 result = std::dynamic_pointer_cast<T>(manager);
240 if (result !=
nullptr)
252 bool tryLoadNode(
const std::string& fileName, YAML::Node* node);
258 #endif // SURGSIM_FRAMEWORK_RUNTIME_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::shared_ptr< T > getManager() const
Definition: Runtime.h:234
Definition: DataStructuresConvert.h:28
Messenger implements asynchronous communication to OSS, components can add themselves as subscribers ...
Definition: Messenger.h:40
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:53