VariantHelperFactory.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotAPI
17 * @author Christoph Pohl ( christoph dot pohl at kit dot edu )
18 * @date 04.11.22
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <list>
26
29
32
34{
35 namespace factories
36 {
37 struct VariantHelper : armarx::Factory<VariantHelper, type::Descriptor>
38 {
39 explicit VariantHelper(Key){};
40
41 virtual ~VariantHelper() = default;
42
43 virtual std::string to_string(const armarx::aron::data::VariantPtr&) const = 0;
44
46 const std::string& string) const = 0;
47
48 virtual aron::data::VariantPtr from_string(const std::string&,
49 const armarx::aron::Path& path) const = 0;
50 };
51 } // namespace factories
52
53 namespace products
54 {
55 template <type::Descriptor DescT>
56 struct VariantHelper : factories::VariantHelper::Registrar<VariantHelper<DescT>>
57 {
58 using RegistrarT = factories::VariantHelper::Registrar<VariantHelper<DescT>>;
59 static constexpr type::Descriptor id = DescT;
60
61 explicit VariantHelper() : RegistrarT(typename RegistrarT::Registration()){};
62
63 [[nodiscard]] std::string to_string(const data::VariantPtr& ptr) const override;
64
66 const std::string& string) const override;
67
68 [[nodiscard]] aron::data::VariantPtr
69 from_string(const std::string&, const armarx::aron::Path& path) const override;
70 };
71
72 } // namespace products
73
74 template <>
75 std::string
77
78 template <>
80 const std::string&,
81 const armarx::aron::Path& path) const;
82
83 template <>
86 const std::string&) const;
87
88 template <>
89 std::string
91
92 template <>
94 const std::string&,
95 const armarx::aron::Path& path) const;
96
97 template <>
100 const std::string&) const;
101
102 template <>
103 std::string
105
106 template <>
108 const std::string&,
109 const armarx::aron::Path& path) const;
110
111 template <>
114 const std::string&) const;
115
116 template <>
117 std::string
119
120 template <>
122 const std::string&,
123 const armarx::aron::Path& path) const;
124
125 template <>
128 const std::string&) const;
129
130 template <>
131 std::string
133
134 template <>
136 const std::string&,
137 const armarx::aron::Path& path) const;
138
139 template <>
142 const std::string&) const;
143
144 template <>
146 const data::VariantPtr& ptr) const;
147
148 template <>
150 const std::string&,
151 const armarx::aron::Path& path) const;
152
153 template <>
156 const std::string&) const;
157
158 static inline const std::list<type::Descriptor> implementedListDescriptors = {
165 };
172} // namespace armarx::aron::component_config
The Path class.
Definition Path.h:36
std::shared_ptr< Variant > VariantPtr
virtual void set_value_from_string(const armarx::aron::data::VariantPtr &, const std::string &string) const =0
virtual std::string to_string(const armarx::aron::data::VariantPtr &) const =0
virtual aron::data::VariantPtr from_string(const std::string &, const armarx::aron::Path &path) const =0
std::string to_string(const data::VariantPtr &ptr) const override
aron::data::VariantPtr from_string(const std::string &, const armarx::aron::Path &path) const override
void set_value_from_string(const armarx::aron::data::VariantPtr &variant, const std::string &string) const override
factories::VariantHelper::Registrar< VariantHelper< DescT > > RegistrarT