Object.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 <map>
28 #include <string>
29 
30 // Base Class
31 #include "../detail/ContainerVariant.h"
32 
33 namespace armarx::aron::type
34 {
35  class Object;
36  using ObjectPtr = std::shared_ptr<Object>;
37 
38  /**
39  * @brief The Object class. It represents the object type
40  * An object may have different types for each member, here represented as a map, mapping from the member name (as string) to the type (as a variant)
41  */
42  class Object : public detail::ContainerVariant<type::dto::AronObject, Object>
43  {
44  public:
45  // constructors
46  Object(const Path& = Path());
47  Object(const type::dto::AronObject&, const Path& = Path());
48 
49  static ObjectPtr FromAronObjectDTO(const type::dto::AronObjectPtr&,
50  const aron::Path& path = aron::Path());
51  static type::dto::AronObjectPtr ToAronObjectDTO(const ObjectPtr&);
52 
53  // public member functions
54  bool checkObjectName(const std::string&) const;
55 
56  std::map<std::string, VariantPtr> getMemberTypes() const;
57  std::map<std::string, VariantPtr> getDirectMemberTypes() const;
58  VariantPtr getMemberType(const std::string&) const;
59  std::string getObjectName() const;
60  std::shared_ptr<Object> getExtends() const;
61  std::vector<std::string> getTemplates() const;
62  std::vector<std::string> getTemplateInstantiations() const;
63 
64  void setObjectName(const std::string&);
65  void setExtends(const std::shared_ptr<Object>&);
66 
67  void setMemberTypes(const std::map<std::string, VariantPtr>&);
68  void addMemberType(const std::string&, const VariantPtr&);
69  void setTemplates(const std::vector<std::string>&);
70  void addTemplate(const std::string&) const;
71  void setTemplateInstantiations(const std::vector<std::string>&) const;
72  void addTemplateInstantiation(const std::string&) const;
73 
74  bool hasMemberType(const std::string&) const;
75 
76  std::string getObjectNameWithoutNamespace() const;
77  std::string getObjectNameWithTemplates() const;
78  std::string getObjectNameWithTemplateInstantiations() const;
79 
80  std::vector<std::string> getAllKeys() const;
81 
82  type::dto::AronObjectPtr toAronObjectDTO() const;
83 
84  // virtual implementations
85  VariantPtr navigateAbsolute(const Path& path) const override;
86 
87  std::string getShortName() const override;
88  std::string getFullName() const override;
89  std::vector<VariantPtr> getChildren() const override;
90  size_t childrenSize() const override;
91 
92  static std::string GetFullNamePrefix();
93  static std::string GetNamePrefix();
94 
95  private:
96  // members
97  std::shared_ptr<Object> extends;
98  std::map<std::string, VariantPtr> memberTypes;
99  };
100 } // namespace armarx::aron::type
armarx::aron::type::Object::GetFullNamePrefix
static std::string GetFullNamePrefix()
Definition: Object.cpp:324
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::aron::type::Object::getMemberType
VariantPtr getMemberType(const std::string &) const
Definition: Object.cpp:128
armarx::aron::type::Object::getAllKeys
std::vector< std::string > getAllKeys() const
Definition: Object.cpp:261
armarx::aron::type::Object::getObjectNameWithTemplates
std::string getObjectNameWithTemplates() const
Definition: Object.cpp:203
armarx::aron::type::Object::setObjectName
void setObjectName(const std::string &)
Definition: Object.cpp:162
armarx::aron::type::detail::ContainerVariant
Definition: ContainerVariant.h:39
armarx::aron::type::Object
The Object class.
Definition: Object.h:42
armarx::aron::type::Object::getExtends
std::shared_ptr< Object > getExtends() const
Definition: Object.cpp:255
armarx::aron::type::Object::getObjectName
std::string getObjectName() const
Definition: Object.cpp:249
armarx::aron::type::Object::getTemplateInstantiations
std::vector< std::string > getTemplateInstantiations() const
Definition: Object.cpp:243
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::type::Object::getChildren
std::vector< VariantPtr > getChildren() const override
get all child elements
Definition: Object.cpp:286
armarx::aron::type::Object::setExtends
void setExtends(const std::shared_ptr< Object > &)
Definition: Object.cpp:170
armarx::aron::type::Object::navigateAbsolute
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
Definition: Object.cpp:336
armarx::aron::type::Object::FromAronObjectDTO
static ObjectPtr FromAronObjectDTO(const type::dto::AronObjectPtr &, const aron::Path &path=aron::Path())
Definition: Object.cpp:54
armarx::aron::type::Object::hasMemberType
bool hasMemberType(const std::string &) const
Definition: Object.cpp:180
armarx::aron::type
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:9
armarx::aron::type::Object::setTemplateInstantiations
void setTemplateInstantiations(const std::vector< std::string > &) const
Definition: Object.cpp:102
armarx::aron::type::Object::setMemberTypes
void setMemberTypes(const std::map< std::string, VariantPtr > &)
Definition: Object.cpp:86
armarx::aron::type::Object::getDirectMemberTypes
std::map< std::string, VariantPtr > getDirectMemberTypes() const
Definition: Object.cpp:122
armarx::aron::type::Object::GetNamePrefix
static std::string GetNamePrefix()
Definition: Object.cpp:330
armarx::aron::type::Object::childrenSize
size_t childrenSize() const override
Definition: Object.cpp:304
armarx::aron::type::Object::Object
Object(const Path &=Path())
Definition: Object.cpp:34
armarx::aron::type::Object::ToAronObjectDTO
static type::dto::AronObjectPtr ToAronObjectDTO(const ObjectPtr &)
Definition: Object.cpp:64
armarx::aron::type::Object::addTemplate
void addTemplate(const std::string &) const
Definition: Object.cpp:213
armarx::aron::type::Object::addMemberType
void addMemberType(const std::string &, const VariantPtr &)
Definition: Object.cpp:147
armarx::aron::type::Object::addTemplateInstantiation
void addTemplateInstantiation(const std::string &) const
Definition: Object.cpp:224
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::aron::type::Object::getFullName
std::string getFullName() const override
get the full name of this specific type
Definition: Object.cpp:317
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::aron::type::Object::setTemplates
void setTemplates(const std::vector< std::string > &)
Definition: Object.cpp:96
armarx::aron::type::Variant::path
const Path path
Definition: Variant.h:139
armarx::aron::type::Object::getMemberTypes
std::map< std::string, VariantPtr > getMemberTypes() const
Definition: Object.cpp:108
armarx::aron::type::Object::getShortName
std::string getShortName() const override
get a short name of this specific type
Definition: Object.cpp:310
armarx::aron::type::Object::checkObjectName
bool checkObjectName(const std::string &) const
Definition: Object.cpp:74
armarx::aron::type::Object::toAronObjectDTO
type::dto::AronObjectPtr toAronObjectDTO() const
Definition: Object.cpp:279
armarx::aron::type::Object::getTemplates
std::vector< std::string > getTemplates() const
Definition: Object.cpp:237
armarx::aron::type::Object::getObjectNameWithTemplateInstantiations
std::string getObjectNameWithTemplateInstantiations() const
Definition: Object.cpp:193
armarx::aron::type::Object::getObjectNameWithoutNamespace
std::string getObjectNameWithoutNamespace() const
Definition: Object.cpp:186