FrameworkConvert.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_FRAMEWORK_FRAMEWORKCONVERT_H
#define SURGSIM_FRAMEWORK_FRAMEWORKCONVERT_H
#include <memory>
#include <unordered_map>
#include <yaml-cpp/yaml.h>
namespace SurgSim
{
namespace Framework
{
class Asset;
class Component;
class SceneElement;
class Scene;
}
}
namespace YAML
{
template <class T>
struct convert<std::shared_ptr<T>>
{
static YAML::Node encode(
const typename std::enable_if <std::is_base_of <SurgSim::Framework::Component, T>::value,
std::shared_ptr<T>>::type rhs);
static bool decode(
const Node& node,
typename std::enable_if <std::is_base_of<SurgSim::Framework::Component, T>::value,
std::shared_ptr<T>>::type& rhs); //NOLINT
};
template <>
struct convert<std::shared_ptr<SurgSim::Framework::Component>>
{
static Node encode(const std::shared_ptr<SurgSim::Framework::Component> rhs);
static bool decode(const Node& node, std::shared_ptr<SurgSim::Framework::Component>& rhs); //NOLINT
typedef std::unordered_map<std::string, std::shared_ptr<SurgSim::Framework::Component>> RegistryType;
static RegistryType& getRegistry();
};
template<>
struct convert<SurgSim::Framework::Component>
{
static Node encode(const SurgSim::Framework::Component& rhs);
};
template<>
struct convert<std::shared_ptr<SurgSim::Framework::SceneElement>>
{
static Node encode(const std::shared_ptr<SurgSim::Framework::SceneElement> rhs);
static bool decode(const Node& node, std::shared_ptr<SurgSim::Framework::SceneElement>& rhs); //NOLINT
};
template<>
struct convert <std::vector<std::shared_ptr<SurgSim::Framework::SceneElement>>>
{
static bool decode(const Node& node,
std::vector<std::shared_ptr<SurgSim::Framework::SceneElement>>& rhs, //NOLINT
std::vector<std::string>* stack = nullptr);
};
template<>
struct convert<SurgSim::Framework::SceneElement>
{
static Node encode(const SurgSim::Framework::SceneElement& rhs);
};
template<>
struct convert<std::shared_ptr<SurgSim::Framework::Scene>>
{
static Node encode(const std::shared_ptr<SurgSim::Framework::Scene> rhs);
static bool decode(const Node& node, std::shared_ptr<SurgSim::Framework::Scene>& rhs); //NOLINT
};
template<>
struct convert<std::shared_ptr<SurgSim::Framework::Asset>>
{
static Node encode(const std::shared_ptr<SurgSim::Framework::Asset> rhs);
static bool decode(const Node& node, std::shared_ptr<SurgSim::Framework::Asset>& rhs); //NOLINT
};
};
#include "SurgSim/Framework/FrameworkConvert-inl.h"
#endif // SURGSIM_FRAMEWORK_FRAMEWORKCONVERT_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
YAML::convert< std::shared_ptr< SurgSim::Framework::Component > >::RegistryType
std::unordered_map< std::string, std::shared_ptr< SurgSim::Framework::Component > > RegistryType
Definition: FrameworkConvert.h:72
std
STL namespace.
SurgSim::Framework::Component
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:42
SurgSim::Framework::convert
SurgSim::Math::Matrix44f convert(boost::any val)
Specialization for convert<T>() to correctly cast Matrix44d to Matrix44f, will throw if the val is no...
Definition: Accessible.cpp:210
FrameworkConvert-inl.h
YAML
Definition: DataStructuresConvert.h:28
SurgSim::Framework::SceneElement
SceneElement is the basic part of a scene, it is a container of components.
Definition: SceneElement.h:51