Manager.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_MANAGER_H
#define SURGSIM_GRAPHICS_MANAGER_H
#include "SurgSim/Framework/ComponentManager.h"
#include <memory>
#include <vector>
namespace SurgSim
{
namespace Graphics
{
class Group;
class Representation;
class View;
class Manager : public SurgSim::Framework::ComponentManager
{
public:
Manager();
virtual ~Manager();
const std::vector<std::shared_ptr<Representation>>& getRepresentations() const
{
return m_representations;
}
const std::unordered_map<std::string, std::shared_ptr<Group>>& getGroups() const
{
return m_groups;
}
const std::vector<std::shared_ptr<View>>& getViews() const
{
return m_views;
}
virtual void dumpDebugInfo() const = 0;
protected:
virtual bool executeAdditions(const std::shared_ptr<SurgSim::Framework::Component>& component);
virtual bool executeRemovals(const std::shared_ptr<SurgSim::Framework::Component>& component);
virtual bool addRepresentation(std::shared_ptr<Representation> representation);
virtual bool addView(std::shared_ptr<View> view);
virtual bool removeRepresentation(std::shared_ptr<Representation> representation);
virtual bool removeView(std::shared_ptr<View> view);
virtual bool doUpdate(double dt);
int getType() const override;
virtual std::shared_ptr<Group> getOrCreateGroup(const std::string& name) = 0;
protected:
virtual void addGroup(std::shared_ptr<Group> group);
void doBeforeStop() override;
private:
virtual bool doInitialize();
virtual bool doStartUp();
std::vector<std::shared_ptr<Representation>> m_representations;
std::unordered_map<std::string, std::shared_ptr<Group>> m_groups;
std::vector<std::shared_ptr<View>> m_views;
};
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_MANAGER_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::Manager::m_groups
std::unordered_map< std::string, std::shared_ptr< Group > > m_groups
Groups assigned to the manager.
Definition: Manager.h:134
SurgSim::Graphics::Manager::addRepresentation
virtual bool addRepresentation(std::shared_ptr< Representation > representation)
Adds an representation to the manager.
Definition: Manager.cpp:74
SurgSim::Graphics::Manager::m_representations
std::vector< std::shared_ptr< Representation > > m_representations
Representations assigned to the manager.
Definition: Manager.h:132
SurgSim::Graphics::Manager::getOrCreateGroup
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.
SurgSim::Graphics::Manager::~Manager
virtual ~Manager()
Destructor.
Definition: Manager.cpp:36
SurgSim::Framework::ComponentManager
Base Component Manager class.
Definition: ComponentManager.h:49
SurgSim::Graphics::Manager::getRepresentations
const std::vector< std::shared_ptr< Representation > > & getRepresentations() const
Returns the representations assigned to the manager.
Definition: Manager.h:46
SurgSim::Graphics::Manager::dumpDebugInfo
virtual void dumpDebugInfo() const =0
Generic unspecified debug handle, there are no requirements on this interface the manager implementat...
SurgSim::Graphics::Manager::removeRepresentation
virtual bool removeRepresentation(std::shared_ptr< Representation > representation)
Removes an representation from the manager.
Definition: Manager.cpp:134
SurgSim::Graphics::Manager::getViews
const std::vector< std::shared_ptr< View > > & getViews() const
Returns the views assigned to the manager.
Definition: Manager.h:58
SurgSim::Graphics::Manager::doInitialize
virtual bool doInitialize()
Initializes the manager.
Definition: Manager.cpp:175
SurgSim::Graphics::Manager::executeRemovals
virtual bool executeRemovals(const std::shared_ptr< SurgSim::Framework::Component > &component)
Removes a component.
Definition: Manager.cpp:40
SurgSim::Graphics::Manager::Manager
Manager()
Constructor.
Definition: Manager.cpp:31
SurgSim::Graphics::Manager::removeView
virtual bool removeView(std::shared_ptr< View > view)
Removes a view from the manager.
Definition: Manager.cpp:158
SurgSim::Graphics::Manager
Basic graphics manager class which manages graphics components to provide a visualization of the scen...
Definition: Manager.h:37
ComponentManager.h
SurgSim::Graphics::Manager::addGroup
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
SurgSim::Graphics::Manager::m_views
std::vector< std::shared_ptr< View > > m_views
Views assigned to the manager.
Definition: Manager.h:136
SurgSim::Graphics::Manager::doUpdate
virtual bool doUpdate(double dt)
Performs an update for a single timestep.
Definition: Manager.cpp:185
SurgSim::Graphics::Manager::addView
virtual bool addView(std::shared_ptr< View > view)
Adds a view to the manager.
Definition: Manager.cpp:118
SurgSim::Graphics::Manager::doBeforeStop
void doBeforeStop() override
Prepares the thread for its execution to be stopped.
Definition: Manager.cpp:218
SurgSim::Graphics::Manager::doStartUp
virtual bool doStartUp()
Starts up the manager after all threads have initialized.
Definition: Manager.cpp:180
SurgSim::Graphics::Manager::executeAdditions
virtual bool executeAdditions(const std::shared_ptr< SurgSim::Framework::Component > &component)
Adds a component.
Definition: Manager.cpp:57
SurgSim::Graphics::Manager::getGroups
const std::unordered_map< std::string, std::shared_ptr< Group > > & getGroups() const
Returns the groups assigned to the manager.
Definition: Manager.h:52
SurgSim::Graphics::Manager::getType
int getType() const override
Overrides ComponentManager::getType()
Definition: Manager.cpp:204