VariantVisitor.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 // Header
25 #include "VariantVisitor.h"
26 
27 #include "../../variant/All.h"
28 
29 namespace armarx::aron::type
30 {
31  /****************************************************************************
32  * VariantVisitor
33  ***************************************************************************/
36  {
37  if (!n)
38  {
40  }
41  return n->getDescriptor();
42  }
43 
46  {
47  return GetDescriptor(n);
48  }
49 
50  void
52  {
53  auto aron = type::Object::DynamicCastAndCheck(i);
54  visitAronVariant(aron);
55  }
56 
57  void
59  {
60  auto aron = type::Dict::DynamicCastAndCheck(i);
61  visitAronVariant(aron);
62  }
63 
64  void
66  {
67  auto aron = type::Pair::DynamicCastAndCheck(i);
68  visitAronVariant(aron);
69  }
70 
71  void
73  {
74  auto aron = type::Tuple::DynamicCastAndCheck(i);
75  visitAronVariant(aron);
76  }
77 
78  void
80  {
81  auto aron = type::List::DynamicCastAndCheck(i);
82  visitAronVariant(aron);
83  }
84 
85  void
87  {
88  auto aron = type::Matrix::DynamicCastAndCheck(i);
89  visitAronVariant(aron);
90  }
91 
92  void
94  {
96  visitAronVariant(aron);
97  }
98 
99  void
101  {
103  visitAronVariant(aron);
104  }
105 
106  void
108  {
109  auto aron = type::Image::DynamicCastAndCheck(i);
110  visitAronVariant(aron);
111  }
112 
113  void
115  {
117  visitAronVariant(aron);
118  }
119 
120  void
122  {
123  auto aron = type::IntEnum::DynamicCastAndCheck(i);
124  visitAronVariant(aron);
125  }
126 
127  void
129  {
130  auto aron = type::Int::DynamicCastAndCheck(i);
131  visitAronVariant(aron);
132  }
133 
134  void
136  {
137  auto aron = type::Long::DynamicCastAndCheck(i);
138  visitAronVariant(aron);
139  }
140 
141  void
143  {
144  auto aron = type::Float::DynamicCastAndCheck(i);
145  visitAronVariant(aron);
146  }
147 
148  void
150  {
151  auto aron = type::Double::DynamicCastAndCheck(i);
152  visitAronVariant(aron);
153  }
154 
155  void
157  {
158  auto aron = type::Bool::DynamicCastAndCheck(i);
159  visitAronVariant(aron);
160  }
161 
162  void
164  {
165  auto aron = type::String::DynamicCastAndCheck(i);
166  visitAronVariant(aron);
167  }
168 
169  void
171  {
173  visitAronVariant(aron);
174  }
175 
176  void
178  {
179  }
180 
181  void
183  {
184  }
185 
186  void
188  {
189  }
190 
191  void
193  {
194  }
195 
196  void
198  {
199  }
200 
201  void
203  {
204  }
205 
206  void
208  {
209  }
210 
211  void
213  {
214  }
215 
216  void
218  {
219  }
220 
221  void
223  {
224  }
225 
226  void
228  {
229  }
230 
231  void
233  {
234  }
235 
236  void
238  {
239  }
240 
241  void
243  {
244  }
245 
246  void
248  {
249  }
250 
251  void
253  {
254  }
255 
256  void
258  {
259  }
260 
261  void
263  {
264  }
265 
266  /****************************************************************************
267  * RecursiveVariantVisitor
268  ***************************************************************************/
271  {
273  }
274 
277  {
279  return o->getMemberTypes();
280  }
281 
284  {
285  return GetObjectAcceptedTypes(t);
286  }
287 
290  {
292  return o->getAcceptedType();
293  }
294 
297  {
298  return GetDictAcceptedType(t);
299  }
300 
303  {
305  return o->getAcceptedType();
306  }
307 
310  {
311  return GetListAcceptedType(t);
312  }
313 
316  {
318  return o->getAcceptedTypes();
319  }
320 
323  {
324  return GetPairAcceptedTypes(t);
325  }
326 
329  {
331  return o->getAcceptedTypes();
332  }
333 
336  {
337  return GetTupleAcceptedTypes(t);
338  }
339 
340  void
342  {
343  auto aron = type::Object::DynamicCastAndCheck(i);
344  visitAronVariantEnter(aron);
345  }
346 
347  void
349  {
350  auto aron = type::Object::DynamicCastAndCheck(i);
351  visitAronVariantExit(aron);
352  }
353 
354  void
356  {
357  auto aron = type::Dict::DynamicCastAndCheck(i);
358  visitAronVariantEnter(aron);
359  }
360 
361  void
363  {
364  auto aron = type::Dict::DynamicCastAndCheck(i);
365  visitAronVariantExit(aron);
366  }
367 
368  void
370  {
371  auto aron = type::Pair::DynamicCastAndCheck(i);
372  visitAronVariantEnter(aron);
373  }
374 
375  void
377  {
378  auto aron = type::Pair::DynamicCastAndCheck(i);
379  visitAronVariantExit(aron);
380  }
381 
382  void
384  {
385  auto aron = type::Tuple::DynamicCastAndCheck(i);
386  visitAronVariantEnter(aron);
387  }
388 
389  void
391  {
392  auto aron = type::Tuple::DynamicCastAndCheck(i);
393  visitAronVariantExit(aron);
394  }
395 
396  void
398  {
399  auto aron = type::List::DynamicCastAndCheck(i);
400  visitAronVariantEnter(aron);
401  }
402 
403  void
405  {
406  auto aron = type::List::DynamicCastAndCheck(i);
407  visitAronVariantExit(aron);
408  }
409 
410  void
412  {
413  auto aron = type::Matrix::DynamicCastAndCheck(i);
414  visitAronVariant(aron);
415  }
416 
417  void
419  {
420  auto aron = type::NDArray::DynamicCastAndCheck(i);
421  visitAronVariant(aron);
422  }
423 
424  void
426  {
428  visitAronVariant(aron);
429  }
430 
431  void
433  {
434  auto aron = type::Image::DynamicCastAndCheck(i);
435  visitAronVariant(aron);
436  }
437 
438  void
440  {
442  visitAronVariant(aron);
443  }
444 
445  void
447  {
448  auto aron = type::IntEnum::DynamicCastAndCheck(i);
449  visitAronVariant(aron);
450  }
451 
452  void
454  {
455  auto aron = type::Int::DynamicCastAndCheck(i);
456  visitAronVariant(aron);
457  }
458 
459  void
461  {
462  auto aron = type::Long::DynamicCastAndCheck(i);
463  visitAronVariant(aron);
464  }
465 
466  void
468  {
469  auto aron = type::Float::DynamicCastAndCheck(i);
470  visitAronVariant(aron);
471  }
472 
473  void
475  {
476  auto aron = type::Double::DynamicCastAndCheck(i);
477  visitAronVariant(aron);
478  }
479 
480  void
482  {
483  auto aron = type::Bool::DynamicCastAndCheck(i);
484  visitAronVariant(aron);
485  }
486 
487  void
489  {
490  auto aron = type::String::DynamicCastAndCheck(i);
491  visitAronVariant(aron);
492  }
493 
494  void
496  {
498  visitAronVariant(aron);
499  }
500 
501  void
503  {
504  }
505 
506  void
508  {
509  }
510 
511  void
513  {
514  }
515 
516  void
518  {
519  }
520 
521  void
523  {
524  }
525 
526  void
528  {
529  }
530 
531  void
533  {
534  }
535 
536  void
538  {
539  }
540 
541  void
543  {
544  }
545 
546  void
548  {
549  }
550 
551  void
553  {
554  }
555 
556  void
558  {
559  }
560 
561  void
563  {
564  }
565 
566  void
568  {
569  }
570 
571  void
573  {
574  }
575 
576  void
578  {
579  }
580 
581  void
583  {
584  }
585 
586  void
588  {
589  }
590 
591  void
593  {
594  }
595 
596  void
598  {
599  }
600 
601  void
603  {
604  }
605 
606  void
608  {
609  }
610 
611  void
613  {
614  }
615 } // namespace armarx::aron::type
armarx::aron::type::RecursiveVisitor< const type::VariantPtr >::ObjectElements
std::map< std::string, InputNonConst > ObjectElements
Definition: RecursiveVisitor.h:132
armarx::aron::type::VisitorBase< const type::VariantPtr >::Input
const type::VariantPtr Input
Definition: Visitor.h:94
armarx::aron::type::ConstVariantVisitor::visitList
void visitList(Input &) override
Definition: VariantVisitor.cpp:79
armarx::aron::type::MatrixPtr
std::shared_ptr< class Matrix > MatrixPtr
Definition: forward_declarations.h:20
armarx::aron::type::RecursiveConstVariantVisitor::visitTupleOnEnter
void visitTupleOnEnter(Input &) override
Definition: VariantVisitor.cpp:383
armarx::aron::type::AnyObjectPtr
std::shared_ptr< class AnyObject > AnyObjectPtr
Definition: forward_declarations.h:34
VariantVisitor.h
armarx::aron::type::RecursiveConstVariantVisitor::GetTupleAcceptedTypes
static TupleElements GetTupleAcceptedTypes(Input &t)
Definition: VariantVisitor.cpp:328
armarx::aron::type::RecursiveConstVariantVisitor::visitInt
void visitInt(Input &) override
Definition: VariantVisitor.cpp:453
armarx::aron::type::RecursiveConstVariantVisitor::visitString
void visitString(Input &) override
Definition: VariantVisitor.cpp:488
armarx::aron::type::ConstVariantVisitor::visitQuaternion
void visitQuaternion(Input &) override
Definition: VariantVisitor.cpp:100
armarx::aron::type::ImagePtr
std::shared_ptr< class Image > ImagePtr
Definition: forward_declarations.h:22
armarx::aron::type::NDArrayPtr
std::shared_ptr< class NDArray > NDArrayPtr
Definition: forward_declarations.h:19
armarx::aron::type::ConstVariantVisitor::visitInt
void visitInt(Input &) override
Definition: VariantVisitor.cpp:128
armarx::aron::type::ConstVariantVisitor::visitPair
void visitPair(Input &) override
Definition: VariantVisitor.cpp:65
armarx::aron::type::RecursiveVisitor< const type::VariantPtr >::TupleElements
std::vector< InputNonConst > TupleElements
Definition: RecursiveVisitor.h:134
armarx::aron::type::RecursiveConstVariantVisitor::visitPairOnEnter
void visitPairOnEnter(Input &) override
Definition: VariantVisitor.cpp:369
armarx::aron::type::RecursiveConstVariantVisitor::GetDictAcceptedType
static InputNonConst GetDictAcceptedType(Input &t)
Definition: VariantVisitor.cpp:289
armarx::aron::type::RecursiveVisitor< const type::VariantPtr >::PairElements
std::pair< InputNonConst, InputNonConst > PairElements
Definition: RecursiveVisitor.h:133
armarx::aron::type::TuplePtr
std::shared_ptr< class Tuple > TuplePtr
Definition: forward_declarations.h:17
armarx::aron::type::RecursiveConstVariantVisitor::visitPointCloud
void visitPointCloud(Input &) override
Definition: VariantVisitor.cpp:439
armarx::aron::type::RecursiveConstVariantVisitor::getPairAcceptedTypes
PairElements getPairAcceptedTypes(Input &t) override
Definition: VariantVisitor.cpp:322
armarx::aron::type::RecursiveConstVariantVisitor::GetObjectAcceptedTypes
static ObjectElements GetObjectAcceptedTypes(Input &t)
Definition: VariantVisitor.cpp:276
armarx::aron::type::ConstVariantVisitor::visitString
void visitString(Input &) override
Definition: VariantVisitor.cpp:163
armarx::aron::type::PointCloudPtr
std::shared_ptr< class PointCloud > PointCloudPtr
Definition: forward_declarations.h:23
armarx::aron::type::RecursiveVisitor< const type::VariantPtr >::Input
typename VisitorBase< const type::VariantPtr >::Input Input
Definition: RecursiveVisitor.h:129
armarx::aron::type::ConstVariantVisitor::visitNDArray
void visitNDArray(Input &) override
Definition: VariantVisitor.cpp:93
armarx::aron::type::FloatPtr
std::shared_ptr< class Float > FloatPtr
Definition: forward_declarations.h:29
armarx::aron::type::RecursiveVisitor< const type::VariantPtr >::InputNonConst
typename std::remove_const< Input >::type InputNonConst
Definition: RecursiveVisitor.h:130
armarx::aron::type::ListPtr
std::shared_ptr< class List > ListPtr
Definition: forward_declarations.h:14
armarx::aron::type::RecursiveConstVariantVisitor::getObjectAcceptedTypes
ObjectElements getObjectAcceptedTypes(Input &t) override
Definition: VariantVisitor.cpp:283
armarx::aron::type::RecursiveConstVariantVisitor::visitObjectOnExit
void visitObjectOnExit(Input &) override
Definition: VariantVisitor.cpp:348
armarx::aron::type::LongPtr
std::shared_ptr< class Long > LongPtr
Definition: forward_declarations.h:28
armarx::aron::type::RecursiveConstVariantVisitor::visitNDArray
void visitNDArray(Input &) override
Definition: VariantVisitor.cpp:418
armarx::aron::type::StringPtr
std::shared_ptr< class String > StringPtr
Definition: forward_declarations.h:31
armarx::aron::type::RecursiveConstVariantVisitor::visitTupleOnExit
void visitTupleOnExit(Input &) override
Definition: VariantVisitor.cpp:390
armarx::aron::type::RecursiveConstVariantVisitor::getDescriptor
type::Descriptor getDescriptor(Input &n) override
Definition: VariantVisitor.cpp:270
armarx::aron::type::ConstVariantVisitor::visitAnyObject
void visitAnyObject(Input &) override
Definition: VariantVisitor.cpp:170
armarx::aron::type::ConstVariantVisitor::getDescriptor
type::Descriptor getDescriptor(Input &n) override
Definition: VariantVisitor.cpp:45
armarx::aron::type::RecursiveConstVariantVisitor::getListAcceptedType
InputNonConst getListAcceptedType(Input &t) override
Definition: VariantVisitor.cpp:309
armarx::aron::type::RecursiveConstVariantVisitor::visitPairOnExit
void visitPairOnExit(Input &) override
Definition: VariantVisitor.cpp:376
armarx::aron::type::ConstVariantVisitor::visitIntEnum
void visitIntEnum(Input &) override
Definition: VariantVisitor.cpp:121
armarx::aron::type::ConstVariantVisitor::visitAronVariant
virtual void visitAronVariant(const type::ObjectPtr &)
Definition: VariantVisitor.cpp:177
armarx::aron::type::RecursiveConstVariantVisitor::visitAronVariant
virtual void visitAronVariant(const type::MatrixPtr &)
Definition: VariantVisitor.cpp:557
armarx::aron::type::PairPtr
std::shared_ptr< class Pair > PairPtr
Definition: forward_declarations.h:16
armarx::aron::type::DictPtr
std::shared_ptr< class Dict > DictPtr
Definition: forward_declarations.h:13
armarx::aron::type::RecursiveConstVariantVisitor::visitImage
void visitImage(Input &) override
Definition: VariantVisitor.cpp:432
armarx::aron::type::RecursiveConstVariantVisitor::visitDouble
void visitDouble(Input &) override
Definition: VariantVisitor.cpp:474
armarx::aron::type
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:9
armarx::aron::type::RecursiveConstVariantVisitor::visitFloat
void visitFloat(Input &) override
Definition: VariantVisitor.cpp:467
armarx::aron::type::BoolPtr
std::shared_ptr< class Bool > BoolPtr
Definition: forward_declarations.h:32
armarx::aron::type::RecursiveConstVariantVisitor::GetListAcceptedType
static InputNonConst GetListAcceptedType(Input &t)
Definition: VariantVisitor.cpp:302
armarx::aron::type::ConstVariantVisitor::visitBool
void visitBool(Input &) override
Definition: VariantVisitor.cpp:156
armarx::aron::type::RecursiveConstVariantVisitor::visitBool
void visitBool(Input &) override
Definition: VariantVisitor.cpp:481
armarx::aron::type::RecursiveConstVariantVisitor::visitAronVariantEnter
virtual void visitAronVariantEnter(const type::ObjectPtr &)
Definition: VariantVisitor.cpp:502
armarx::aron::type::RecursiveConstVariantVisitor::getDictAcceptedType
InputNonConst getDictAcceptedType(Input &t) override
Definition: VariantVisitor.cpp:296
armarx::aron::type::ConstVariantVisitor::visitPointCloud
void visitPointCloud(Input &) override
Definition: VariantVisitor.cpp:114
armarx::aron::type::RecursiveConstVariantVisitor::GetPairAcceptedTypes
static PairElements GetPairAcceptedTypes(Input &t)
Definition: VariantVisitor.cpp:315
armarx::aron::type::ConstVariantVisitor::visitTuple
void visitTuple(Input &) override
Definition: VariantVisitor.cpp:72
armarx::aron::type::RecursiveConstVariantVisitor::visitListOnExit
void visitListOnExit(Input &) override
Definition: VariantVisitor.cpp:404
armarx::aron::type::ConstVariantVisitor::visitMatrix
void visitMatrix(Input &) override
Definition: VariantVisitor.cpp:86
armarx::aron::type::RecursiveConstVariantVisitor::visitMatrix
void visitMatrix(Input &) override
Definition: VariantVisitor.cpp:411
armarx::aron::type::Descriptor::UNKNOWN
@ UNKNOWN
armarx::aron::type::RecursiveConstVariantVisitor::visitDictOnEnter
void visitDictOnEnter(Input &) override
Definition: VariantVisitor.cpp:355
armarx::aron::type::RecursiveConstVariantVisitor::visitAronVariantExit
virtual void visitAronVariantExit(const type::ObjectPtr &)
Definition: VariantVisitor.cpp:507
armarx::aron::type::detail::SpecializedVariantBase< type::dto::AronObject, Object >::DynamicCastAndCheck
static std::shared_ptr< Object > DynamicCastAndCheck(const VariantPtr &n)
Definition: SpecializedVariant.h:124
armarx::aron::type::RecursiveConstVariantVisitor::visitQuaternion
void visitQuaternion(Input &) override
Definition: VariantVisitor.cpp:425
armarx::aron::type::ConstVariantVisitor::GetDescriptor
static type::Descriptor GetDescriptor(Input &n)
Definition: VariantVisitor.cpp:35
armarx::aron::type::IntEnumPtr
std::shared_ptr< IntEnum > IntEnumPtr
Definition: IntEnum.h:36
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::aron::type::RecursiveConstVariantVisitor::visitListOnEnter
void visitListOnEnter(Input &) override
Definition: VariantVisitor.cpp:397
armarx::aron::type::ConstVariantVisitor::visitFloat
void visitFloat(Input &) override
Definition: VariantVisitor.cpp:142
armarx::aron::type::QuaternionPtr
std::shared_ptr< class Quaternion > QuaternionPtr
Definition: forward_declarations.h:21
armarx::aron::type::IntPtr
std::shared_ptr< class Int > IntPtr
Definition: forward_declarations.h:27
armarx::aron::type::RecursiveConstVariantVisitor::visitLong
void visitLong(Input &) override
Definition: VariantVisitor.cpp:460
armarx::aron::type::Descriptor
Descriptor
Definition: Descriptor.h:76
armarx::aron::type::DoublePtr
std::shared_ptr< class Double > DoublePtr
Definition: forward_declarations.h:30
armarx::aron::type::RecursiveConstVariantVisitor::getTupleAcceptedTypes
TupleElements getTupleAcceptedTypes(Input &t) override
Definition: VariantVisitor.cpp:335
armarx::aron::type::ConstVariantVisitor::visitDouble
void visitDouble(Input &) override
Definition: VariantVisitor.cpp:149
armarx::aron::type::RecursiveConstVariantVisitor::visitDictOnExit
void visitDictOnExit(Input &) override
Definition: VariantVisitor.cpp:362
armarx::aron::type::ConstVariantVisitor::visitDict
void visitDict(Input &) override
Definition: VariantVisitor.cpp:58
armarx::aron::type::RecursiveConstVariantVisitor::visitObjectOnEnter
void visitObjectOnEnter(Input &) override
Definition: VariantVisitor.cpp:341
armarx::aron::type::ConstVariantVisitor::visitImage
void visitImage(Input &) override
Definition: VariantVisitor.cpp:107
armarx::aron::type::RecursiveConstVariantVisitor::visitIntEnum
void visitIntEnum(Input &) override
Definition: VariantVisitor.cpp:446
armarx::aron::type::RecursiveConstVariantVisitor::visitAnyObject
void visitAnyObject(Input &) override
Definition: VariantVisitor.cpp:495
armarx::aron::type::ConstVariantVisitor::visitLong
void visitLong(Input &) override
Definition: VariantVisitor.cpp:135
armarx::aron::type::ConstVariantVisitor::visitObject
void visitObject(Input &) override
Definition: VariantVisitor.cpp:51