blob: 3902598908042c9438268a6c1607c593f0cba51f [file] [log] [blame]
Thomas Psotab49d8df2019-11-27 15:55:41 +01001/*
2 * ElementMap.h
3 *
4 * Author: wendel
5 */
6
7#ifndef BASYX_AAS_METAMODEL_ELEMENTMAP_H_
8#define BASYX_AAS_METAMODEL_ELEMENTMAP_H_
9
10#include "basyx/object.h"
11
12namespace basyx {
13namespace vab {
14
15
16class ElementMap
17{
18protected:
19 mutable basyx::object map;
Johannes Wendel10dc5522019-12-04 11:20:14 +010020
21protected:
22 void insertMapElement(const std::string & key, const ElementMap & element);
23
Thomas Psotab49d8df2019-11-27 15:55:41 +010024public:
25 ElementMap();
26 ElementMap(basyx::object object);
Johannes Wendel10dc5522019-12-04 11:20:14 +010027 ElementMap(const ElementMap & other);
Thomas Psotab49d8df2019-11-27 15:55:41 +010028 virtual ~ElementMap() = default;
29
30 basyx::object getMap() const;
Johannes Wendel10dc5522019-12-04 11:20:14 +010031
Thomas Psotab49d8df2019-11-27 15:55:41 +010032public:
33 template<typename AbstractType, typename SpecificType>
34 static basyx::specificCollection_t<AbstractType> make_specific_collection(basyx::object::object_list_t & obj_list)
35 {
36 basyx::specificCollection_t<AbstractType> list;
37
38 for (auto & obj : obj_list)
39 list.emplace_back(std::make_shared<SpecificType>(obj));
40
41 return list;
42 };
43
44 template<typename AbstractType, typename SpecificType>
45 static basyx::object make_object_list(const basyx::specificCollection_t<AbstractType> & abst_list)
46 {
47 auto list = basyx::object::make_list<basyx::object>();
48
49 for (auto & abstract : abst_list)
50 list.insert(SpecificType{ *abstract }.getMap());
51
52 return list;
53 };
54};
55
56}
57}
58
59#endif