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 <string>
28 #include <map>
29 
30 // Base Class
31 #include "../detail/ContainerVariant.h"
32 
33 
34 namespace armarx::aron::type
35 {
36  class Object;
37  using ObjectPtr = std::shared_ptr<Object>;
38 
43  class Object :
44  public detail::ContainerVariant<type::dto::AronObject, Object>
45  {
46  public:
47  // constructors
48  Object(const std::string&, const std::vector<std::string>& templates = {}, const std::vector<std::string>& templateInstantiations = {}, const std::map<std::string, VariantPtr>& = {}, const Path& = Path());
49  Object(const type::dto::AronObject&, const Path& = Path());
50 
51  static ObjectPtr FromAronObjectDTO(const type::dto::AronObjectPtr&);
52  static type::dto::AronObjectPtr ToAronObjectDTO(const ObjectPtr&);
53 
54  // public member functions
55  bool checkObjectName(const std::string&) const;
56 
57  std::map<std::string, VariantPtr> getMemberTypes() const;
58  std::map<std::string, VariantPtr> getDirectMemberTypes() const;
59  VariantPtr getMemberType(const std::string&) const;
60  std::string getObjectName() const;
61  std::shared_ptr<Object> getExtends() const;
62  std::vector<std::string> getTemplates() const;
63  std::vector<std::string> getTemplateInstantiations() const;
64 
65  void setObjectName(const std::string&);
66  void setExtends(const std::shared_ptr<Object>&);
67  void addMemberType(const std::string&, const VariantPtr&);
68  void addTemplate(const std::string&) const;
69  void addTemplateInstantiation(const std::string&) const;
70 
71  bool hasMemberType(const std::string&) const;
72 
73  std::string getObjectNameWithoutNamespace() const;
74  std::string getObjectNameWithTemplates() const;
75  std::string getObjectNameWithTemplateInstantiations() const;
76 
77  std::vector<std::string> getAllKeys() const;
78 
79  type::dto::AronObjectPtr toAronObjectDTO() const;
80 
81  // virtual implementations
82  VariantPtr navigateAbsolute(const Path& path) const override;
83 
84  std::string getShortName() const override;
85  std::string getFullName() const override;
86  std::vector<VariantPtr> getChildren() const override;
87  size_t childrenSize() const override;
88 
89  private:
90  // members
91  std::shared_ptr<Object> extends;
92  std::map<std::string, VariantPtr> memberTypes;
93  };
94 }
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:106
armarx::aron::type::Object::getAllKeys
std::vector< std::string > getAllKeys() const
Definition: Object.cpp:214
armarx::aron::type::Object::getObjectNameWithTemplates
std::string getObjectNameWithTemplates() const
Definition: Object.cpp:167
armarx::aron::type::Object::setObjectName
void setObjectName(const std::string &)
Definition: Object.cpp:132
armarx::aron::type::detail::ContainerVariant
Definition: ContainerVariant.h:39
armarx::aron::type::Object
The Object class.
Definition: Object.h:43
armarx::aron::type::Object::getExtends
std::shared_ptr< Object > getExtends() const
Definition: Object.cpp:209
armarx::aron::type::Object::getObjectName
std::string getObjectName() const
Definition: Object.cpp:204
armarx::aron::type::Object::getTemplateInstantiations
std::vector< std::string > getTemplateInstantiations() const
Definition: Object.cpp:199
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::type::Object::Object
Object(const std::string &, const std::vector< std::string > &templates={}, const std::vector< std::string > &templateInstantiations={}, const std::map< std::string, VariantPtr > &={}, const Path &=Path())
Definition: Object.cpp:36
armarx::aron::type::Object::getChildren
std::vector< VariantPtr > getChildren() const override
get all child elements
Definition: Object.cpp:237
armarx::aron::type::Object::setExtends
void setExtends(const std::shared_ptr< Object > &)
Definition: Object.cpp:139
armarx::aron::type::Object::navigateAbsolute
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
Definition: Object.cpp:269
armarx::aron::type::Object::FromAronObjectDTO
static ObjectPtr FromAronObjectDTO(const type::dto::AronObjectPtr &)
Definition: Object.cpp:59
armarx::aron::type::Object::hasMemberType
bool hasMemberType(const std::string &) const
Definition: Object.cpp:147
armarx::aron::type
A convenience header to include all aron files (full include, not forward declared)
Definition: Descriptor.h:65
armarx::aron::type::Object::getDirectMemberTypes
std::map< std::string, VariantPtr > getDirectMemberTypes() const
Definition: Object.cpp:101
armarx::aron::type::Object::childrenSize
size_t childrenSize() const override
Definition: Object.cpp:254
armarx::aron::type::Object::ToAronObjectDTO
static type::dto::AronObjectPtr ToAronObjectDTO(const ObjectPtr &)
Definition: Object.cpp:68
armarx::aron::type::Object::addTemplate
void addTemplate(const std::string &) const
Definition: Object.cpp:176
armarx::aron::type::Object::addMemberType
void addMemberType(const std::string &, const VariantPtr &)
Definition: Object.cpp:119
armarx::aron::type::Object::addTemplateInstantiation
void addTemplateInstantiation(const std::string &) const
Definition: Object.cpp:185
armarx::aron::type::Object::getFullName
std::string getFullName() const override
get the full name of this specific type
Definition: Object.cpp:264
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:37
armarx::aron::type::Variant::path
const Path path
Definition: Variant.h:134
armarx::aron::type::Object::getMemberTypes
std::map< std::string, VariantPtr > getMemberTypes() const
Definition: Object.cpp:88
armarx::aron::type::Object::getShortName
std::string getShortName() const override
get a short name of this specific type
Definition: Object.cpp:259
armarx::aron::type::Object::checkObjectName
bool checkObjectName(const std::string &) const
Definition: Object.cpp:77
armarx::aron::type::Object::toAronObjectDTO
type::dto::AronObjectPtr toAronObjectDTO() const
Definition: Object.cpp:231
armarx::aron::type::Object::getTemplates
std::vector< std::string > getTemplates() const
Definition: Object.cpp:194
armarx::aron::type::Object::getObjectNameWithTemplateInstantiations
std::string getObjectNameWithTemplateInstantiations() const
Definition: Object.cpp:158
armarx::aron::type::Object::getObjectNameWithoutNamespace
std::string getObjectNameWithoutNamespace() const
Definition: Object.cpp:152