Falcon
Loading...
Searching...
No Matches
dummy_data.cpp
1#pragma once
2#include <string>
3#include "idata.hpp"
4
5namespace nsDummyType {
6using ParentType = AnyType;
7using Capabilities = ParentType::Capabilities;
8using Parameters = ParentType::Parameters;
9
10class Data : public IData<Data, ParentType> {
11 private:
12 std::string value_;
13 size_t hash_;
14
15 public:
16 using BaseClass = IData<Data, ParentType>;
17 Data() : Data("hello") {}
18 Data(const std::string& value) { set_value(value); }
19 Data(const Parameters _) : Data("hello") {}
20
21 size_t hash() const { return hash_; }
22 size_t size() const { return value_.size(); }
23 std::string value() const { return value_; }
24 void set_value(const std::string& val) {
25 value_ = val;
26 hash_ = std::hash<std::string>()(value_);
27 }
28};
29
30} // namespace nsDummyType
31
32using DummyType = DefineType<nsDummyType::Data, AnyType, true, nsDummyType::Capabilities,
33 nsDummyType::Parameters>;
34
35namespace YAML {
36template <>
37struct convert<DummyType::Data> {
38 static Node encode(const DummyType::Data& rhs) {
39 Node node;
40 node = rhs.value();
41 return node;
42 }
43
44 static bool decode(const Node& node, DummyType::Data& rhs) {
45 rhs.set_value(node.as<std::string>());
46 return true;
47 }
48};
49} // namespace YAML
Convenient template class to define data types.
Definition idata.hpp:75
Base class of all data object classes.
Definition idata.hpp:95
Definition dummy_data.cpp:10