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
30 #include "../detail/SpecializedVariant.h"
31 
32 // ArmarX
33 #include "../../../type/variant/container/List.h"
34 #include "../../../type/variant/container/Pair.h"
35 #include "../../../type/variant/container/Tuple.h"
36 #include "Dict.h"
37 
38 namespace 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
53 
54  bool operator==(const List&) const override;
55  bool operator==(const ListPtr&) const override;
56 
57  // static methods
59  static data::dto::ListPtr ToAronListDTO(const PointerType& navigator);
60 
61  // public member functions
62  DictPtr getAsDict() const;
63 
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
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 
95 namespace 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
armarx::aron::data::List::fullfillsType
bool fullfillsType(const type::VariantPtr &) const override
checks, if the current data variant fullfills the given type
Definition: List.cpp:255
armarx::aron::data::List::List
List(const Path &path=Path())
Definition: List.cpp:39
armarx::aron::data::List::getElement
VariantPtr getElement(unsigned int) const
Definition: List.cpp:191
armarx::aron::data::List::getShortName
std::string getShortName() const override
get a short str representation of this variant
Definition: List.cpp:235
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::aron::data::List::getElements
std::vector< VariantPtr > getElements() const
Definition: List.cpp:206
armarx::aron::data::List::toAronListDTO
data::dto::ListPtr toAronListDTO() const
Definition: List.cpp:228
armarx::aron::data::List::clear
void clear()
Definition: List.cpp:221
armarx::aron::data::List::childrenSize
size_t childrenSize() const override
get the children size of a data variant
Definition: List.cpp:353
armarx::aron::data::Variant::PointerType
VariantPtr PointerType
Definition: Variant.h:63
armarx::aron::data::Variant::path
const Path path
Definition: Variant.h:156
armarx::aron::make_list
aron::data::ListPtr make_list(_Args &&... args)
Definition: List.h:99
armarx::aron::data::List
Definition: List.h:43
armarx::aron::data::List::getFullName
std::string getFullName() const override
get the full str representation of this variant
Definition: List.cpp:241
armarx::aron::data::List::recalculateType
type::VariantPtr recalculateType() const override
recalculate the type of a data variant. Please not tha the mapping ist NOT bijective,...
Definition: List.cpp:248
armarx::aron::data::detail::SpecializedVariantBase< data::dto::List, List >::clone
virtual PointerType clone() const
Definition: SpecializedVariant.h:82
Dict.h
armarx::aron::data::List::removeElement
void removeElement(unsigned int)
Definition: List.cpp:212
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::aron::data::List::ToAronListDTO
static data::dto::ListPtr ToAronListDTO(const PointerType &navigator)
Definition: List.cpp:125
armarx::aron::data::List::navigateAbsolute
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
Definition: List.cpp:359
armarx::aron
Definition: DataDisplayVisitor.cpp:5
armarx::aron::data::detail::ContainerVariant
Definition: ContainerVariant.h:37
armarx::aron::data
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:3
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::aron::data::List::FromAronListDTO
static PointerType FromAronListDTO(const data::dto::ListPtr &aron)
Definition: List.cpp:115
armarx::aron::data::List::operator==
bool operator==(const List &) const override
Definition: List.cpp:67
armarx::aron::data::List::getChildren
std::vector< VariantPtr > getChildren() const override
get the children of a data variant
Definition: List.cpp:347
armarx::aron::data::List::getAsDict
DictPtr getAsDict() const
Definition: List.cpp:132
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::aron::data::List::hasElement
bool hasElement(unsigned int) const
Definition: List.cpp:185
armarx::aron::data::List::setElement
void setElement(unsigned int, const VariantPtr &)
Definition: List.cpp:147
armarx::aron::data::ListPtr
std::shared_ptr< List > ListPtr
Definition: List.h:40
armarx::aron::data::List::addElement
void addElement(const VariantPtr &)
Definition: List.cpp:141
armarx::aron::data::detail::SpecializedVariantBase< data::dto::List, List >::aron
AronDataType::PointerType aron
Definition: SpecializedVariant.h:154