opensurgsim
Manager.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, 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_GRAPHICS_MANAGER_H
17 #define SURGSIM_GRAPHICS_MANAGER_H
18 
19 #include "SurgSim/Framework/ComponentManager.h"
20 
21 #include <memory>
22 #include <vector>
23 
24 namespace SurgSim
25 {
26 
27 namespace Graphics
28 {
29 
30 class Group;
31 class Representation;
32 class View;
33 
38 {
39 public:
41  Manager();
43  virtual ~Manager();
44 
46  const std::vector<std::shared_ptr<Representation>>& getRepresentations() const
47  {
48  return m_representations;
49  }
50 
52  const std::unordered_map<std::string, std::shared_ptr<Group>>& getGroups() const
53  {
54  return m_groups;
55  }
56 
58  const std::vector<std::shared_ptr<View>>& getViews() const
59  {
60  return m_views;
61  }
62 
65  virtual void dumpDebugInfo() const = 0;
66 
67 protected:
68 
72  virtual bool executeAdditions(const std::shared_ptr<SurgSim::Framework::Component>& component);
73 
77  virtual bool executeRemovals(const std::shared_ptr<SurgSim::Framework::Component>& component);
78 
83  virtual bool addRepresentation(std::shared_ptr<Representation> representation);
84 
88  virtual bool addView(std::shared_ptr<View> view);
89 
93  virtual bool removeRepresentation(std::shared_ptr<Representation> representation);
94 
98  virtual bool removeView(std::shared_ptr<View> view);
99 
102  virtual bool doUpdate(double dt);
103 
105  int getType() const override;
106 
110  virtual std::shared_ptr<Group> getOrCreateGroup(const std::string& name) = 0;
111 
112 protected:
115  virtual void addGroup(std::shared_ptr<Group> group);
116 
117  void doBeforeStop() override;
118 
119 private:
120 
121 
122 
125  virtual bool doInitialize();
126 
129  virtual bool doStartUp();
130 
132  std::vector<std::shared_ptr<Representation>> m_representations;
134  std::unordered_map<std::string, std::shared_ptr<Group>> m_groups;
136  std::vector<std::shared_ptr<View>> m_views;
137 };
138 
139 }; // namespace Graphics
140 
141 }; // namespace SurgSim
142 
143 #endif // SURGSIM_GRAPHICS_MANAGER_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual bool addRepresentation(std::shared_ptr< Representation > representation)
Adds an representation to the manager.
Definition: Manager.cpp:74
virtual std::shared_ptr< Group > getOrCreateGroup(const std::string &name)=0
Fetch a group with a given name, if the group does not exist, create it.
virtual ~Manager()
Destructor.
Definition: Manager.cpp:36
Base Component Manager class.
Definition: ComponentManager.h:49
const std::vector< std::shared_ptr< Representation > > & getRepresentations() const
Returns the representations assigned to the manager.
Definition: Manager.h:46
virtual void dumpDebugInfo() const =0
Generic unspecified debug handle, there are no requirements on this interface the manager implementat...
virtual bool removeRepresentation(std::shared_ptr< Representation > representation)
Removes an representation from the manager.
Definition: Manager.cpp:134
const std::vector< std::shared_ptr< View > > & getViews() const
Returns the views assigned to the manager.
Definition: Manager.h:58
virtual bool executeRemovals(const std::shared_ptr< SurgSim::Framework::Component > &component)
Removes a component.
Definition: Manager.cpp:40
Manager()
Constructor.
Definition: Manager.cpp:31
virtual bool removeView(std::shared_ptr< View > view)
Removes a view from the manager.
Definition: Manager.cpp:158
Basic graphics manager class which manages graphics components to provide a visualization of the scen...
Definition: Manager.h:37
virtual void addGroup(std::shared_ptr< Group > group)
Adds a group to the manager, override for manager specific behavior when adding.
Definition: Manager.cpp:209
virtual bool doUpdate(double dt)
Performs an update for a single timestep.
Definition: Manager.cpp:185
virtual bool addView(std::shared_ptr< View > view)
Adds a view to the manager.
Definition: Manager.cpp:118
void doBeforeStop() override
Prepares the thread for its execution to be stopped.
Definition: Manager.cpp:218
virtual bool executeAdditions(const std::shared_ptr< SurgSim::Framework::Component > &component)
Adds a component.
Definition: Manager.cpp:57
const std::unordered_map< std::string, std::shared_ptr< Group > > & getGroups() const
Returns the groups assigned to the manager.
Definition: Manager.h:52
int getType() const override
Overrides ComponentManager::getType()
Definition: Manager.cpp:204