Emit record_replay fromQVariant for plain enums; document PPM MOC exclusion
This commit is contained in:
3 files changed
+59
-4
No files matched your search
+30
-1
@@ -171,8 +171,20 @@ std::vector<T> fromJson(const QVariant &jsonData, type<std::vector<T>>)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Primary fallback for any migrated plain-`enum class` enumerators that have no
|
||||
// explicit specialization below - most importantly the nested foreign
|
||||
// ProjectDataManagement / Core enums a plugin reads back from the database (they are
|
||||
// not in this service's idl_enums, so the per-own-enum specializations do not cover
|
||||
// them). Giving the primary template a body (rather than leaving it declaration-only)
|
||||
// is what lets those foreign-enum instantiations resolve, so the plugin .so links. The
|
||||
// explicit specializations for primitives / own enums / structs / vectors / optionals
|
||||
// all take precedence over this fallback, so it is only ever instantiated for an enum
|
||||
// type, where `static_cast<T>(val.toInt())` is the correct conversion.
|
||||
template<typename T>
|
||||
T fromQVariant(const QVariant &val, type<T>);
|
||||
T fromQVariant(const QVariant &val, type<T>)
|
||||
{
|
||||
return static_cast<T>(val.toInt());
|
||||
}
|
||||
|
||||
template<>
|
||||
bool fromQVariant(const QVariant &val, type<bool>)
|
||||
@@ -266,6 +278,23 @@ T fromQVariant(const QVariant &val)
|
||||
return fromQVariant(val, type<T>{});
|
||||
}
|
||||
|
||||
// rtiddsgen 7.7 spells the migrated enumerators as plain `enum class` in the service
|
||||
// namespace (the legacy dds::core::safe_enum<T> wrapper is gone). The record_replay
|
||||
// plugin still instantiates fromQVariant<Enum>() for each enum member it reads back,
|
||||
// and none of the generic overloads above are ever deduced for those types, so each of
|
||||
// this service's own enumerations needs its own explicit specialization. `idl_enums`
|
||||
// carries the service's own enumerations by local name and this block runs inside
|
||||
// `namespace {{ namespace }}`, so the local name resolves to the fully-qualified enum
|
||||
// type. (Nested foreign PDM enumerations are still not covered - same limitation as the
|
||||
// documented svcBuildings exclusion.)
|
||||
{% for enumeration in idl_enums %}
|
||||
template<>
|
||||
{{ enumeration.name }} fromQVariant(const QVariant &val, type<{{ enumeration.name }}>)
|
||||
{
|
||||
return static_cast<{{ enumeration.name }}>(val.toInt());
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
{% for dt in serializeTopics.member %}
|
||||
//
|
||||
// Begin {{ dt.typeFq }}
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ protected:
|
||||
int64_t m_snapshot{{ dt.name }}MapTime = -1; // time for which the snapshot is valid
|
||||
{% endif %} {% endfor %}
|
||||
|
||||
NGL::INGLLogger* m_logger;
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user