15#ifndef UTILITIES_INFOMODEL_BASE_H_INCLUDED
16#define UTILITIES_INFOMODEL_BASE_H_INCLUDED
62template <typename INFO_T>
73 return INFO_T::INFO_TYPE_ID;
83template <
typename INFO_T>
113 const INFO_T*
get() const noexcept
129 void set(std::shared_ptr<INFO_T> info)
noexcept
131 _info = std::move(info);
135 std::shared_ptr<INFO_T> _info;
182 template <
typename INFO_T>
185 static_assert(INFO_T::INFO_TYPE_ID < info_type_count,
"INFO_TYPE_ID is no InfoType");
186 const IInfo*
const info = _infos[INFO_T::INFO_TYPE_ID].get();
189 if (info !=
nullptr &&
typeid(*info) ==
typeid(INFO_T)) {
190 return static_cast<const INFO_T*
>(info);
192 return dynamic_cast<const INFO_T*
>(info);
200 template <
typename INFO_T>
203 return const_cast<INFO_T*
>(
static_cast<const InfoMap*
>(
this)->getInfo<INFO_T>());
212 template <
typename INFO_T>
213 void setInfo(
const std::shared_ptr<INFO_T>& info)
215 static_assert(INFO_T::INFO_TYPE_ID < info_type_count,
"INFO_TYPE_ID is no InfoType");
216 std::shared_ptr<IInfo> info_downcast = info;
217 if (info_downcast->getInfoType() == INFO_T::INFO_TYPE_ID) {
218 _infos[INFO_T::INFO_TYPE_ID] = std::move(info_downcast);
223 "Registration not possible, runtime info is differnt then compiletime info");
230#if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
231#pragma GCC diagnostic push
232#pragma GCC diagnostic ignored "-Wattributes"
237 std::array<std::shared_ptr<IInfo>, info_type_count> _infos;
239#if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
240#pragma GCC diagnostic pop
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:41
virtual ~IInfo()=default
virtual DTOR for IInfo object
virtual uint8_t getInfoType() const noexcept=0
Get the Info Type ID.
Info Map for the datamodel to hold a set of optional IInfo instances. Only one instance of one Info t...
Definition infomodel_base.h:142
InfoMap & operator=(InfoMap &&)
move assignment operator
Definition infomodel_base.h:172
void setInfo(const std::shared_ptr< INFO_T > &info)
Set the Info object as shared pointer.
Definition infomodel_base.h:213
INFO_T * getInfo() noexcept
Get the Info Pointer.
Definition infomodel_base.h:201
InfoMap(InfoMap &&)
move CTOR
Definition infomodel_base.h:157
InfoMap & operator=(const InfoMap &)
copy assignment operator
Definition infomodel_base.h:163
const INFO_T * getInfo() const noexcept
Get the Info Pointer.
Definition infomodel_base.h:183
InfoMap(const InfoMap &)
copy CTOR
Definition infomodel_base.h:152
InfoSlot(const InfoSlot &) noexcept
Creates an empty slot, the info of other is not copied.
Definition infomodel_base.h:89
~InfoSlot()=default
Destroys the slot and releases its info.
InfoSlot()=default
Creates an empty slot.
InfoSlot(InfoSlot &&) noexcept
Creates an empty slot, the info of other is not moved.
Definition infomodel_base.h:93
InfoSlot & operator=(const InfoSlot &) noexcept
Keeps the own info, the info of other is not copied.
Definition infomodel_base.h:97
const INFO_T * get() const noexcept
Get the info.
Definition infomodel_base.h:113
InfoSlot & operator=(InfoSlot &&) noexcept
Keeps the own info, the info of other is not moved.
Definition infomodel_base.h:102
void set(std::shared_ptr< INFO_T > info) noexcept
Set the info.
Definition infomodel_base.h:129
INFO_T * get() noexcept
Get the info.
Definition infomodel_base.h:121
Helper template class to create valid IInfo objects.
Definition infomodel_base.h:63
uint8_t getInfoType() const noexcept override
Get the Info Type object.
Definition infomodel_base.h:71
definition of the datamodel namespace
Definition datamodel_base.h:28
definition of the dd namespace
Definition datamodel_base.h:26
@ validation_service_info
Validation Info Service.
Definition dd_infomodel_type.h:36
definition of the ddl namespace
Definition codec.h:21