opensurgsim
Scene.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_FRAMEWORK_SCENE_H
17 #define SURGSIM_FRAMEWORK_SCENE_H
18 
19 #include <boost/thread/mutex.hpp>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "SurgSim/DataStructures/Groups.h"
25 #include "SurgSim/Framework/SceneElement.h"
26 
27 
28 namespace YAML
29 {
30 class Node;
31 }
32 
33 namespace SurgSim
34 {
35 namespace Framework
36 {
37 
38 class Logger;
39 class Runtime;
40 
42 class Scene : public std::enable_shared_from_this<Scene>
43 {
44 public:
45 
48  explicit Scene(std::weak_ptr<Runtime> runtime);
49 
51  ~Scene();
52 
55  void addSceneElement(std::shared_ptr<SceneElement> element);
56 
59  void removeSceneElement(std::shared_ptr<SceneElement> element);
60 
63  void addSceneElements(std::vector<std::shared_ptr<SceneElement>> elements);
64 
67  const std::vector<std::shared_ptr<SceneElement>>& getSceneElements() const;
68 
71  const std::shared_ptr<SceneElement> getSceneElement(const std::string& name) const;
72 
77  std::shared_ptr<Component> getComponent(const std::string& elementName, const std::string& componentName) const;
78 
81  std::shared_ptr<Runtime> getRuntime();
82 
85  YAML::Node encode() const;
86 
90  bool decode(const YAML::Node& node);
91 
94 
95 private:
96 
99  std::shared_ptr<Scene> getSharedPtr();
100  std::weak_ptr<Runtime> m_runtime;
101 
102  std::vector<std::shared_ptr<SceneElement>> m_elements;
103 
104  // Used in a const function, need to declare mutable
105  mutable boost::mutex m_sceneElementsMutex;
106 
108 
109  std::shared_ptr<Framework::Logger> m_logger;
110 };
111 
112 }; // namespace Framework
113 }; // namespace SurgSim
114 
115 #endif // SURGSIM_FRAMEWORK_SCENE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Class to wrap grouping operations, gives access to the members of a group and the groups of members...
Definition: Groups.h:37
Scene. Basic Container for SceneElements.
Definition: Scene.h:42
Definition: DataStructuresConvert.h:28