List.h
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#pragma once
25
26// STD/STL
27#include <memory>
28
29// Base class
31
32// ArmarX
36#include "Dict.h"
37
38namespace armarx::aron::data
39{
40 class List;
41 typedef std::shared_ptr<List> ListPtr;
42
43 class List : public detail::ContainerVariant<data::dto::List, List>
44 {
45 public:
46 // constructors
47 List(const Path& path = Path());
48 List(const data::dto::ListPtr&, const Path& path = Path());
49 List(const std::vector<VariantPtr>&, const Path& path = Path());
50
51 // operators
52 using detail::ContainerVariant<data::dto::List, List>::operator==;
53
54 bool operator==(const List&) const override;
55 bool operator==(const ListPtr&) const override;
56
57 // static methods
58 static PointerType FromAronListDTO(const data::dto::ListPtr& aron);
59 static data::dto::ListPtr ToAronListDTO(const PointerType& navigator);
60
61 // public member functions
62 DictPtr getAsDict() const;
63
64 data::dto::ListPtr toAronListDTO() const;
65
66 void addElement(const VariantPtr&);
67 void setElement(unsigned int, const VariantPtr&);
68 VariantPtr getElement(unsigned int) const;
69 bool hasElement(unsigned int) const;
70 std::vector<VariantPtr> getElements() const;
71
72 void removeElement(unsigned int);
73
74 void clear();
75
76 // virtual implementations
77 using detail::ContainerVariant<data::dto::List, List>::clone;
78 ListPtr clone(const Path& p) const override;
79
80 std::string getShortName() const override;
81 std::string getFullName() const override;
82 std::vector<VariantPtr> getChildren() const override;
83 size_t childrenSize() const override;
84
85 type::VariantPtr recalculateType() const override;
86 bool fullfillsType(const type::VariantPtr&) const override;
87
88 VariantPtr navigateAbsolute(const Path& path) const override;
89
90 private:
91 std::vector<VariantPtr> childrenNavigators;
92 };
93} // namespace armarx::aron::data
94
95namespace armarx::aron
96{
97 template <typename... _Args>
99 make_list(_Args&&... args)
100 {
101 return std::make_shared<aron::data::List>(args...);
102 }
103} // namespace armarx::aron
The Path class.
Definition Path.h:36
size_t childrenSize() const override
get the children size of a data variant
Definition List.cpp:353
std::string getShortName() const override
get a short str representation of this variant
Definition List.cpp:235
List(const Path &path=Path())
Definition List.cpp:39
VariantPtr getElement(unsigned int) const
Definition List.cpp:191
bool hasElement(unsigned int) const
Definition List.cpp:185
std::vector< VariantPtr > getElements() const
Definition List.cpp:206
void addElement(const VariantPtr &)
Definition List.cpp:141
type::VariantPtr recalculateType() const override
recalculate the type of a data variant. Please not tha the mapping ist NOT bijective,...
Definition List.cpp:248
std::string getFullName() const override
get the full str representation of this variant
Definition List.cpp:241
void removeElement(unsigned int)
Definition List.cpp:212
static PointerType FromAronListDTO(const data::dto::ListPtr &aron)
Definition List.cpp:115
data::dto::ListPtr toAronListDTO() const
Definition List.cpp:228
bool operator==(const List &) const override
Definition List.cpp:67
void setElement(unsigned int, const VariantPtr &)
Definition List.cpp:147
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
Definition List.cpp:359
bool fullfillsType(const type::VariantPtr &) const override
checks, if the current data variant fullfills the given type
Definition List.cpp:255
static data::dto::ListPtr ToAronListDTO(const PointerType &navigator)
Definition List.cpp:125
std::vector< VariantPtr > getChildren() const override
get the children of a data variant
Definition List.cpp:347
ListPtr clone(const Path &p) const override
Definition List.cpp:103
DictPtr getAsDict() const
Definition List.cpp:132
A convenience header to include all aron files (full include, not forward declared)
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
std::shared_ptr< List > ListPtr
Definition List.h:41
std::shared_ptr< Variant > VariantPtr
std::shared_ptr< Variant > VariantPtr
aron::data::ListPtr make_list(_Args &&... args)
Definition List.h:99