16 #ifndef SURGSIM_DATASTRUCTURES_DATASTRUCTURESCONVERT_INL_H 17 #define SURGSIM_DATASTRUCTURES_DATASTRUCTURESCONVERT_INL_H 25 namespace DataStructures
37 YAML::Node YAML::convert<SurgSim::DataStructures::OptionalValue<T>>::encode(
54 bool YAML::convert<SurgSim::DataStructures::OptionalValue<T>>::decode(
66 catch (YAML::RepresentationException)
78 else if (node.IsScalar())
84 catch (YAML::RepresentationException)
94 template <
class Key,
class T>
95 YAML::Node YAML::convert<std::unordered_map<Key, T>>::encode(
const std::unordered_map<Key, T>& rhs)
97 Node node(NodeType::Map);
98 for (
auto it = std::begin(rhs); it != std::end(rhs); ++it)
100 node[it->first] = it->second;
105 template <
class Key,
class T>
106 bool YAML::convert<std::unordered_map<Key, T>>::decode(
const Node& node, std::unordered_map<Key, T>& rhs)
114 for (
auto it = node.begin(); it != node.end(); ++it)
118 rhs[it->first.as<Key>()] = it->second.as<T>();
120 catch (YAML::RepresentationException)
124 SURGSIM_LOG(logger, WARNING) << __FUNCTION__ <<
": Bad conversion";
130 template <
class Value>
131 YAML::Node YAML::convert<std::unordered_set<Value>>::encode(
const std::unordered_set<Value>& rhs)
133 Node node(NodeType::Sequence);
134 for (
auto it = std::begin(rhs); it != std::end(rhs); ++it)
141 template <
class Value>
142 bool YAML::convert<std::unordered_set<Value>>::decode(
const Node& node, std::unordered_set<Value>& rhs)
144 if (!node.IsSequence())
150 for (
auto it = node.begin(); it != node.end(); ++it)
154 rhs.insert(it->as<Value>());
156 catch (YAML::RepresentationException)
160 SURGSIM_LOG(logger, WARNING) << __FUNCTION__ <<
": Bad conversion";
166 #endif // SURGSIM_DATASTRUCTURES_DATASTRUCTURESCONVERT_INL_H Definition: CompoundShapeToGraphics.cpp:29
void invalidate()
Mark this object as invalid.
Definition: OptionalValue.h:62
Container class that can indicate whether the object has been assigned a value.
Definition: OptionalValue.h:29
The convenience header that provides the entirety of the logging API.
static std::shared_ptr< Logger > getLogger(const std::string &name)
Get a logger by name from Logger Manager.
Definition: Logger.h:109
#define SURGSIM_LOG(logger, level)
Logs a message to the specified logger with the short level name.
Definition: LogMacros.h:60
const std::string hasValueName
Definition: DataStructuresConvert-inl.h:30
bool hasValue() const
Query if this object has been assigned a value.
Definition: OptionalValue.h:56
void setValue(const T &val)
Set the value of this object, and mark it as valid.
Definition: OptionalValue.h:69
const std::string valueName
Definition: DataStructuresConvert-inl.h:31
const std::string serializeLogger
Definition: DataStructuresConvert-inl.h:29
const T & getValue() const
Gets the value.
Definition: OptionalValue.h:78