VariantReader.cpp
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 // STD/STL
22 #include <memory>
23 #include <numeric>
24 
25 // Header
26 #include "VariantReader.h"
27 
28 // ArmarX
32 
34 {
35 
38  {
40  }
41 
42  void
44  std::string& name,
45  std::vector<std::string>& templates,
46  std::vector<std::string>& templateInstantiations,
47  std::map<std::string, aron::type::VariantPtr>& memberTypes,
48  type::Maybe& maybe,
49  Path& p)
50  {
53 
54  name = o->getObjectName();
55  templates = o->getTemplates();
56  templateInstantiations = o->getTemplateInstantiations();
57  maybe = o->getMaybe();
58  memberTypes = o->getMemberTypes();
59  p = o->getPath();
60  }
61 
62  void
64  aron::type::VariantPtr& acceptedType,
65  type::Maybe& maybe,
66  Path& p)
67  {
70 
71  maybe = o->getMaybe();
72  acceptedType = o->getAcceptedType();
73  p = o->getPath();
74  }
75 
76  void
78  aron::type::VariantPtr& acceptedType,
79  type::Maybe& maybe,
80  Path& p)
81  {
84 
85  maybe = o->getMaybe();
86  acceptedType = o->getAcceptedType();
87  p = o->getPath();
88  }
89 
90  void
92  std::vector<aron::type::VariantPtr>& acceptedTypes,
93  type::Maybe& maybe,
94  Path& p)
95  {
98 
99  maybe = o->getMaybe();
100  acceptedTypes = o->getAcceptedTypes();
101  p = o->getPath();
102  }
103 
104  void
106  aron::type::VariantPtr& acceptedType1,
107  aron::type::VariantPtr& acceptedType2,
108  type::Maybe& maybe,
109  Path& p)
110  {
113 
114  maybe = o->getMaybe();
115  acceptedType1 = o->getAcceptedTypes().first;
116  acceptedType2 = o->getAcceptedTypes().second;
117  p = o->getPath();
118  }
119 
120  void
122  int& ndim,
124  std::string& defaultValue,
125  type::Maybe& maybe,
126  Path& p)
127  {
130 
131  maybe = o->getMaybe();
132  ndim = o->getNumberDimensions();
133  type = o->getElementType();
134  defaultValue = o->getDefaultValue();
135  p = o->getPath();
136  }
137 
138  void
140  int& rows,
141  int& cols,
143  std::string& defaultValue,
144  type::Maybe& maybe,
145  Path& p)
146  {
149 
150  maybe = o->getMaybe();
151  rows = o->getRows();
152  cols = o->getCols();
153  type = o->getElementType();
154  defaultValue = o->getDefaultValue();
155  p = o->getPath();
156  }
157 
158  void
161  std::string& defaultValue,
162  type::Maybe& maybe,
163  Path& p)
164  {
167 
168  maybe = o->getMaybe();
169  type = o->getElementType();
170  defaultValue = o->getDefaultValue();
171  p = o->getPath();
172  }
173 
174  void
176  type::pointcloud::VoxelType& type,
177  std::string& defaultValue,
178  type::Maybe& maybe,
179  Path& p)
180  {
183 
184  maybe = o->getMaybe();
185  type = o->getVoxelType();
186  defaultValue = o->getDefaultValue();
187  p = o->getPath();
188  }
189 
190  void
192  type::image::PixelType& type,
193  std::string& defaultValue,
194  type::Maybe& maybe,
195  Path& p)
196  {
199 
200  maybe = o->getMaybe();
201  type = o->getPixelType();
202  defaultValue = o->getDefaultValue();
203  p = o->getPath();
204  }
205 
206  void
208  std::string& name,
209  std::map<std::string, int>& acceptedValues,
210  std::string& defaultValue,
211  type::Maybe& maybe,
212  Path& p)
213  {
216 
217  name = o->getEnumName();
218  acceptedValues = o->getAcceptedValueMap();
219  maybe = o->getMaybe();
220  defaultValue = o->getDefaultValueName();
221  p = o->getPath();
222  }
223 
224  void
226  std::optional<int>& defaultValue,
227  type::Maybe& maybe,
228  Path& p)
229  {
232 
233  maybe = o->getMaybe();
234  defaultValue = o->getDefaultValue();
235  p = o->getPath();
236  }
237 
238  void
240  std::optional<long>& defaultValue,
241  type::Maybe& maybe,
242  Path& p)
243  {
246 
247  maybe = o->getMaybe();
248  defaultValue = o->getDefaultValue();
249  p = o->getPath();
250  }
251 
252  void
254  std::optional<float>& defaultValue,
255  type::Maybe& maybe,
256  Path& p)
257  {
260 
261  maybe = o->getMaybe();
262  defaultValue = o->getDefaultValue();
263  p = o->getPath();
264  }
265 
266  void
268  std::optional<double>& defaultValue,
269  type::Maybe& maybe,
270  Path& p)
271  {
274 
275  maybe = o->getMaybe();
276  defaultValue = o->getDefaultValue();
277  p = o->getPath();
278  }
279 
280  void
282  std::optional<std::string>& defaultValue,
283  type::Maybe& maybe,
284  Path& p)
285  {
288 
289  maybe = o->getMaybe();
290  defaultValue = o->getDefaultValue();
291  p = o->getPath();
292  }
293 
294  void
296  std::optional<bool>& defaultValue,
297  type::Maybe& maybe,
298  Path& p)
299  {
302 
303  maybe = o->getMaybe();
304  defaultValue = o->getDefaultValue();
305  p = o->getPath();
306  }
307 
308  void
310  {
313 
314  maybe = o->getMaybe();
315  p = o->getPath();
316  }
317 } // 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::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
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
VariantVisitor.h
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_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
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
All.h
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
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
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::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
Exception.h
armarx::aron::type::detail::SpecializedVariantBase< type::dto::AronObject, Object >::DynamicCastAndCheck
static std::shared_ptr< Object > DynamicCastAndCheck(const VariantPtr &n)
Definition: SpecializedVariant.h:124
VariantReader.h
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::ConstVariantVisitor::GetDescriptor
static type::Descriptor GetDescriptor(Input &n)
Definition: VariantVisitor.cpp:35
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::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::Path::getPath
std::vector< std::string > getPath() const
Definition: Path.cpp:85