Scene.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2016, 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_FRAMEWORK_SCENE_H
#define SURGSIM_FRAMEWORK_SCENE_H
#include <boost/thread/mutex.hpp>
#include <memory>
#include <string>
#include <vector>
#include "SurgSim/DataStructures/Groups.h"
#include "SurgSim/Framework/SceneElement.h"
namespace YAML
{
class Node;
}
namespace SurgSim
{
namespace Framework
{
class Logger;
class Runtime;
class Scene : public std::enable_shared_from_this<Scene>
{
public:
explicit Scene(std::weak_ptr<Runtime> runtime);
~Scene();
void addSceneElement(std::shared_ptr<SceneElement> element);
void removeSceneElement(std::shared_ptr<SceneElement> element);
void addSceneElements(std::vector<std::shared_ptr<SceneElement>> elements);
const std::vector<std::shared_ptr<SceneElement>>& getSceneElements() const;
const std::shared_ptr<SceneElement> getSceneElement(const std::string& name) const;
std::shared_ptr<Component> getComponent(const std::string& elementName, const std::string& componentName) const;
std::shared_ptr<Runtime> getRuntime();
YAML::Node encode() const;
bool decode(const YAML::Node& node);
SurgSim::DataStructures::Groups<std::string, std::shared_ptr<SceneElement>>& getGroups();
private:
std::shared_ptr<Scene> getSharedPtr();
std::weak_ptr<Runtime> m_runtime;
std::vector<std::shared_ptr<SceneElement>> m_elements;
// Used in a const function, need to declare mutable
mutable boost::mutex m_sceneElementsMutex;
SurgSim::DataStructures::Groups<std::string, std::shared_ptr<SceneElement>> m_groups;
std::shared_ptr<Framework::Logger> m_logger;
};
}; // namespace Framework
}; // namespace SurgSim
#endif // SURGSIM_FRAMEWORK_SCENE_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::Groups
Class to wrap grouping operations, gives access to the members of a group and the groups of members...
Definition: Groups.h:37
SurgSim::Framework::Scene::m_logger
std::shared_ptr< Framework::Logger > m_logger
Definition: Scene.h:109
SurgSim::Framework::Scene
Scene. Basic Container for SceneElements.
Definition: Scene.h:42
SurgSim::Framework::Scene::m_sceneElementsMutex
boost::mutex m_sceneElementsMutex
Definition: Scene.h:105
SurgSim::Framework::Scene::m_groups
SurgSim::DataStructures::Groups< std::string, std::shared_ptr< SceneElement > > m_groups
Definition: Scene.h:107
Groups.h
SurgSim::Framework::Scene::m_elements
std::vector< std::shared_ptr< SceneElement > > m_elements
Definition: Scene.h:102
YAML
Definition: DataStructuresConvert.h:28
SurgSim::Framework::Scene::m_runtime
std::weak_ptr< Runtime > m_runtime
Definition: Scene.h:100
SceneElement.h