List.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 "List.h"
26 
27 namespace armarx::aron::type
28 {
29  // constructors
30  List::List(const Path& path) :
31  detail::ContainerVariant<type::dto::List, List>(type::Descriptor::LIST, path)
32  {
33  }
34 
35  List::List(const type::dto::List& o, const Path& path) :
36  detail::ContainerVariant<type::dto::List, List>(o, type::Descriptor::LIST, path),
37  acceptedType(FromAronDTO(*o.acceptedType, path.withAcceptedType()))
38  {
39  }
40 
41  // Member functions
44  {
45  return acceptedType;
46  }
47 
48  void
50  {
52  aron->acceptedType = a->toAronDTO();
53  acceptedType = a;
54  }
55 
56  // static methods
59  {
60  return aron;
61  }
62 
63  // virtual implementations
64  std::vector<VariantPtr>
66  {
67  return {acceptedType};
68  }
69 
70  size_t
72  {
73  return 1;
74  }
75 
76  std::string
78  {
79  return "List<" + acceptedType->getShortName() + ">";
80  }
81 
82  std::string
84  {
85  return "armarx::aron::type::List<" + acceptedType->getFullName() + ">";
86  }
87 
88  std::string
90  {
91  return "armarx::aron::type::List";
92  }
93 
94  std::string
96  {
97  return "List";
98  }
99 
100  VariantPtr
101  List::navigateAbsolute(const Path& path) const
102  {
103  if (!path.hasElement())
104  {
105  throw error::AronException(
106  __PRETTY_FUNCTION__, "Could not navigate without a valid path", path);
107  }
108 
109  if (path.size() != 1)
110  {
111  throw error::AronException(
112  __PRETTY_FUNCTION__, "Could not get more than 1 value from a dict.", path);
113  }
114 
115  std::string el = path.getFirstElement();
116  if (el != "::accepted_type")
117  {
119  __PRETTY_FUNCTION__, "Could not find an element of a path.", el, path);
120  }
121 
122 
123  return acceptedType;
124  }
125 } // namespace armarx::aron::type
armarx::aron::Path::getFirstElement
std::string getFirstElement() const
Definition: Path.cpp:102
armarx::aron::error::AronException
A base class for aron exceptions.
Definition: Exception.h:42
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::VariantType::List
const VariantContainerType List
Definition: SingleTypeVariantList.h:191
armarx::aron::Path::hasElement
bool hasElement() const
Definition: Path.cpp:113
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::Path::size
size_t size() const
Definition: Path.cpp:119
armarx::aron::type::List::getFullName
std::string getFullName() const override
get the full name of this specific type
Definition: List.cpp:83
armarx::aron::type::List
The List class.
Definition: List.h:39
armarx::aron::type::Descriptor::LIST
@ LIST
detail
Definition: OpenCVUtil.cpp:127
armarx::aron::type::List::List
List(const Path &path=Path())
Definition: List.cpp:30
armarx::aron::type::List::childrenSize
size_t childrenSize() const override
Definition: List.cpp:71
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::type::List::getChildren
std::vector< VariantPtr > getChildren() const override
get all child elements
Definition: List.cpp:65
armarx::aron::error::ValueNotValidException
The ValueNotValidException class.
Definition: Exception.h:145
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::aron::type::List::GetFullNamePrefix
static std::string GetFullNamePrefix()
Definition: List.cpp:89
armarx::aron::type::List::getShortName
std::string getShortName() const override
get a short name of this specific type
Definition: List.cpp:77
armarx::aron::type::detail::SpecializedVariantBase< type::dto::List, List >::aron
type::dto::List ::PointerType aron
Definition: SpecializedVariant.h:137
armarx::aron::type::List::toListDTO
type::dto::ListPtr toListDTO() const
Definition: List.cpp:58
armarx::aron::type
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:9
armarx::aron::type::List::getAcceptedType
VariantPtr getAcceptedType() const
Definition: List.cpp:43
armarx::aron::type::List::navigateAbsolute
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
Definition: List.cpp:101
armarx::aron::type::List::GetNamePrefix
static std::string GetNamePrefix()
Definition: List.cpp:95
armarx::aron::type::Variant::path
const Path path
Definition: Variant.h:139
List.h
armarx::aron::type::Descriptor
Descriptor
Definition: Descriptor.h:76
armarx::aron::data::ListPtr
std::shared_ptr< List > ListPtr
Definition: List.h:40
armarx::aron::type::List::setAcceptedType
void setAcceptedType(const VariantPtr &)
Definition: List.cpp:49