VariantReader.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 * @author Fabian Peller (fabian dot peller at kit dot edu)
17 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18 * GNU General Public License
19 */
20 
21 #pragma once
22 
23 // STD/STL
24 #include <memory>
25 #include <stack>
26 
27 // BaseClass
29 
30 // ArmarX
32 
34 {
35  class VariantReader : public ReaderInterface<const aron::type::VariantPtr>
36  {
37  public:
38  // constructors
39  VariantReader() = default;
40 
42 
44  std::string& name,
45  std::vector<std::string>& templates,
46  std::vector<std::string>& templateInstantiations,
47  std::map<std::string, InputTypeNonConst>& memberTypes,
48  type::Maybe& maybe,
49  Path& p = *std::unique_ptr<Path>(new Path())) override;
50  void readList(InputType& input,
51  InputTypeNonConst& acceptedType,
52  type::Maybe& maybe,
53  Path& p = *std::unique_ptr<Path>(new Path())) override;
54  void readDict(InputType& input,
55  InputTypeNonConst& acceptedType,
56  type::Maybe& maybe,
57  Path& p = *std::unique_ptr<Path>(new Path())) override;
59  std::vector<InputTypeNonConst>& acceptedTypes,
60  type::Maybe& maybe,
61  Path& p = *std::unique_ptr<Path>(new Path())) override;
62  void readPair(InputType& input,
63  InputTypeNonConst& acceptedType1,
64  InputTypeNonConst& acceptedType2,
65  type::Maybe& maybe,
66  Path& p = *std::unique_ptr<Path>(new Path())) override;
67 
69  int& ndim,
71  std::string& defaultValue,
72  type::Maybe& maybe,
73  Path& p = *std::unique_ptr<Path>(new Path())) override;
75  int& rows,
76  int& cols,
78  std::string& defaultValue,
79  type::Maybe& maybe,
80  Path& p = *std::unique_ptr<Path>(new Path())) override;
83  std::string& defaultValue,
84  type::Maybe& maybe,
85  Path& p = *std::unique_ptr<Path>(new Path())) override;
87  type::pointcloud::VoxelType& type,
88  std::string& defaultValue,
89  type::Maybe& maybe,
90  Path& p = *std::unique_ptr<Path>(new Path())) override;
92  type::image::PixelType& type,
93  std::string& defaultValue,
94  type::Maybe& maybe,
95  Path& p = *std::unique_ptr<Path>(new Path())) override;
96 
98  std::string& name,
99  std::map<std::string, int>& acceptedValues,
100  std::string& defaultValue,
101  type::Maybe& maybe,
102  Path& p = *std::unique_ptr<Path>(new Path())) override;
103 
104  void readInt(InputType& input,
105  std::optional<int>& defaultValue,
106  type::Maybe& maybe,
107  Path& p = *std::unique_ptr<Path>(new Path())) override;
108  void readLong(InputType& input,
109  std::optional<long>& defaultvalue,
110  type::Maybe& maybe,
111  Path& p = *std::unique_ptr<Path>(new Path())) override;
112  void readFloat(InputType& input,
113  std::optional<float>& defaultValue,
114  type::Maybe& maybe,
115  Path& p = *std::unique_ptr<Path>(new Path())) override;
116  void readDouble(InputType& input,
117  std::optional<double>& defaultValue,
118  type::Maybe& maybe,
119  Path& p = *std::unique_ptr<Path>(new Path())) override;
120  void readString(InputType& input,
121  std::optional<std::string>& defaultValue,
122  type::Maybe& maybe,
123  Path& p = *std::unique_ptr<Path>(new Path())) override;
124  void readBool(InputType& input,
125  std::optional<bool>& defaultValue,
126  type::Maybe& maybe,
127  Path& p = *std::unique_ptr<Path>(new Path())) override;
128 
130  type::Maybe& maybe,
131  Path& p = *std::unique_ptr<Path>(new Path())) override;
132  };
133 } // namespace armarx::aron::type::reader
armarx::aron::type::reader::VariantReader::readTuple
void readTuple(InputType &input, std::vector< InputTypeNonConst > &acceptedTypes, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:91
armarx::aron::type::ReaderInterface< const aron::type::VariantPtr >::InputTypeNonConst
typename std::remove_const< InputType >::type InputTypeNonConst
Definition: Reader.h:42
armarx::aron::type::reader
Definition: NlohmannJSONReader.cpp:34
armarx::aron::type::reader::VariantReader::readDouble
void readDouble(InputType &input, std::optional< double > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::readFloat
void readFloat(InputType &input, std::optional< float > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::readString
void readString(InputType &input, std::optional< std::string > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::readImage
void readImage(InputType &input, type::image::PixelType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:191
armarx::aron::type::reader::VariantReader::readObject
void readObject(InputType &input, std::string &name, std::vector< std::string > &templates, std::vector< std::string > &templateInstantiations, std::map< std::string, InputTypeNonConst > &memberTypes, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:43
armarx::aron::type::reader::VariantReader::getDescriptor
type::Descriptor getDescriptor(InputType &input) final
Definition: VariantReader.cpp:37
armarx::aron::type::ReaderInterface< const aron::type::VariantPtr >::InputType
const aron::type::VariantPtr InputType
Definition: Reader.h:41
armarx::aron::type::reader::VariantReader::readMatrix
void readMatrix(InputType &input, int &rows, int &cols, type::matrix::ElementType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:139
armarx::aron::type::reader::VariantReader::readNDArray
void readNDArray(InputType &input, int &ndim, type::ndarray::ElementType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::readList
void readList(InputType &input, InputTypeNonConst &acceptedType, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::readIntEnum
void readIntEnum(InputType &input, std::string &name, std::map< std::string, int > &acceptedValues, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:207
armarx::aron::Path
The Path class.
Definition: Path.h:36
Variant.h
armarx::aron::type::reader::VariantReader::readAnyObject
void readAnyObject(InputType &input, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:309
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
Reader.h
armarx::ElementTypes::ElementType
ElementType
Definition: AbstractObjectSerializer.h:32
armarx::aron::type::reader::VariantReader::readBool
void readBool(InputType &input, std::optional< bool > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::readPair
void readPair(InputType &input, InputTypeNonConst &acceptedType1, InputTypeNonConst &acceptedType2, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:105
armarx::aron::type::reader::VariantReader
Definition: VariantReader.h:35
armarx::aron::type::reader::VariantReader::readPointCloud
void readPointCloud(InputType &input, type::pointcloud::VoxelType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:175
armarx::aron::type::reader::VariantReader::readQuaternion
void readQuaternion(InputType &input, type::quaternion::ElementType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: VariantReader.cpp:159
armarx::aron::type::reader::VariantReader::readInt
void readInt(InputType &input, std::optional< int > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::aron::type::reader::VariantReader::readDict
void readDict(InputType &input, InputTypeNonConst &acceptedType, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::VariantReader::VariantReader
VariantReader()=default
armarx::aron::type::Descriptor
Descriptor
Definition: Descriptor.h:76
armarx::aron::type::reader::VariantReader::readLong
void readLong(InputType &input, std::optional< long > &defaultvalue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::ReaderInterface
The ReaderInterface class.
Definition: Reader.h:38