15 #ifndef DD_DATA_MODEL_INFO_H_INCLUDED
16 #define DD_DATA_MODEL_INFO_H_INCLUDED
24 #include <unordered_map>
56 template <
typename INFO_T>
67 return INFO_T::INFO_TYPE_ID;
115 template <
typename INFO_T>
118 return dynamic_cast<const INFO_T*
>(
getInfo(INFO_T::INFO_TYPE_ID));
126 template <
typename INFO_T>
129 return dynamic_cast<INFO_T*
>(
getInfo(INFO_T::INFO_TYPE_ID));
138 template <
typename INFO_T>
139 void setInfo(
const std::shared_ptr<INFO_T>& info)
141 std::shared_ptr<IInfo> info_downcast = info;
142 if (info_downcast->getInfoType() == INFO_T::INFO_TYPE_ID) {
148 "Registration not possible, runtime info is differnt then compiletime info");
155 auto found = _infos.find(info_type);
156 if (found != _infos.end()) {
157 return found->second.get();
163 const IInfo*
getInfo(uint8_t info_type)
const
165 auto found = _infos.find(info_type);
166 if (found != _infos.cend()) {
167 return found->second.get();
173 void setInfo(
const std::shared_ptr<IInfo>& info)
175 _infos[info->getInfoType()] = info;
178 #if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
179 #pragma GCC diagnostic push
180 #pragma GCC diagnostic ignored "-Wattributes"
183 std::unordered_map<uint8_t, std::shared_ptr<IInfo>> _infos;
185 #if defined(__GNUC__) && ((__GNUC__ == 5) && (__GNUC_MINOR__ == 2))
186 #pragma GCC diagnostic pop
Basic Info interface can be added to the InfoMap.
virtual ~IInfo()=default
virtual DTOR for IInfo object
virtual uint8_t getInfoType() const =0
Get the Info Type ID.
Helper template class to create valid IInfo objects.
uint8_t getInfoType() const override
Get the Info Type object.
Info Map for the datamodel to hold a set of optional IInfo instances.
INFO_T * getInfo()
Get the Info Pointer.
InfoMap & operator=(InfoMap &&)
move assignment operator
const INFO_T * getInfo() const
Get the Info Pointer.
InfoMap(const InfoMap &)
copy CTOR
InfoMap & operator=(const InfoMap &)
copy assignment operator
InfoMap(InfoMap &&)
move CTOR
void setInfo(const std::shared_ptr< INFO_T > &info)
Set the Info object as shared pointer.
DataDefinition Model-Observer pattern utility.
OO DataDefinition Redesign.
Definition of preprocessor macros to disable/enable compiler warnings.
Error
Enumerates possible error values for filesystem interaction.
definition of the ddl namespace