15#ifndef UTILITIES_INFOMODEL_BASE_H_INCLUDED
16#define UTILITIES_INFOMODEL_BASE_H_INCLUDED
24#include <unordered_map>
57template <
typename INFO_T>
68 return INFO_T::INFO_TYPE_ID;
116 template <
typename INFO_T>
119 return dynamic_cast<const INFO_T*
>(
getInfo(INFO_T::INFO_TYPE_ID));
127 template <
typename INFO_T>
130 return dynamic_cast<INFO_T*
>(
getInfo(INFO_T::INFO_TYPE_ID));
139 template <
typename INFO_T>
140 void setInfo(
const std::shared_ptr<INFO_T>& info)
142 std::shared_ptr<IInfo> info_downcast = info;
143 if (info_downcast->getInfoType() == INFO_T::INFO_TYPE_ID) {
149 "Registration not possible, runtime info is differnt then compiletime info");
156 auto found = _infos.find(info_type);
157 if (found != _infos.end()) {
158 return found->second.get();
166 auto found = _infos.find(info_type);
167 if (found != _infos.cend()) {
168 return found->second.get();
174 void setInfo(
const std::shared_ptr<IInfo>& info)
176 _infos[info->getInfoType()] = info;
179#if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
180#pragma GCC diagnostic push
181#pragma GCC diagnostic ignored "-Wattributes"
184 std::unordered_map<uint8_t, std::shared_ptr<IInfo>> _infos;
186#if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
187#pragma GCC diagnostic pop
195 using ::ddl::dd::datamodel::IInfo;
196 using ::ddl::dd::datamodel::Info;
197 using ::ddl::dd::datamodel::InfoMap;
Exception helper class to collect information while parsing, adding DD Objects or other failed operat...
Definition ddl_error.h:31
Basic Info interface can be added to the ddl::dd::datamodel::InfoMap.
Definition infomodel_base.h:36
virtual uint8_t getInfoType() const =0
Get the Info Type ID.
virtual ~IInfo()=default
virtual DTOR for IInfo object
InfoMap & operator=(InfoMap &&)
move assignment operator
Definition infomodel_base.h:106
void setInfo(const std::shared_ptr< INFO_T > &info)
Set the Info object as shared pointer.
Definition infomodel_base.h:140
InfoMap(InfoMap &&)
move CTOR
Definition infomodel_base.h:91
INFO_T * getInfo()
Get the Info Pointer.
Definition infomodel_base.h:128
InfoMap & operator=(const InfoMap &)
copy assignment operator
Definition infomodel_base.h:97
InfoMap(const InfoMap &)
copy CTOR
Definition infomodel_base.h:86
const INFO_T * getInfo() const
Get the Info Pointer.
Definition infomodel_base.h:117
Helper template class to create valid IInfo objects.
Definition infomodel_base.h:58
uint8_t getInfoType() const override
Get the Info Type object.
Definition infomodel_base.h:66
Basic Info interface can be added to the ddl::dd::datamodel::InfoMap.
Definition infomodel_base.h:36
definition of the datamodel namespace
Definition datamodel_base.h:28
definition of the dd namespace
Definition datamodel_base.h:26
definition of the utility namespace
Definition ddl.h:66
definition of the ddl namespace
Definition codec.h:21