Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
244 lines
8.7 KiB
C++
244 lines
8.7 KiB
C++
/**
|
|
* @RDE_HEADER@
|
|
* Wrapper-Objects for Grantlee engine
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLSE, 2015-08-04
|
|
*/
|
|
|
|
#include "GrantleeWrappers.h"
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
using namespace CodeGen;
|
|
|
|
QString IdlStructWrapper::extensibility2String(dds::core::xtypes::ExtensibilityKind extensiblity)
|
|
{
|
|
switch (extensiblity.underlying())
|
|
{
|
|
case dds::core::xtypes::ExtensibilityKind_def::FINAL:
|
|
return QStringLiteral("FINAL_EXTENSIBILITY");
|
|
case dds::core::xtypes::ExtensibilityKind_def::MUTABLE:
|
|
return QStringLiteral("MUTABLE_EXTENSIBILITY");
|
|
case dds::core::xtypes::ExtensibilityKind_def::EXTENSIBLE:
|
|
return QStringLiteral("EXTENSIBLE_EXTENSIBILITY");
|
|
}
|
|
Q_ASSERT_X(false, "IdlStructWrapper::extensibility2String", "Unknown extensiblity kind");
|
|
return QString();
|
|
}
|
|
|
|
QString DataTopicWrapper::typeFq() const
|
|
{
|
|
const QString &t = type();
|
|
const QString &s = serviceName();
|
|
if (s.isEmpty())
|
|
return t;
|
|
if (t.startsWith(s))
|
|
return t;
|
|
return s + QStringLiteral("::") + t;
|
|
}
|
|
|
|
QString MemberInformationWrapper::ddsToQVariant() const
|
|
{
|
|
return QStringLiteral("toQVariant(data.") + cppMemberName() + QStringLiteral("())");
|
|
}
|
|
|
|
QString MemberInformationWrapper::qVariantToDds() const
|
|
{
|
|
const QString ddsType = isOptional() ?
|
|
(QStringLiteral("dds::core::optional<") + cppDdsType() + QLatin1Char('>')) :
|
|
(cppDdsType());
|
|
|
|
return QStringLiteral("data.") + cppMemberName() +
|
|
QStringLiteral("() = fromQVariant<") + ddsType + QStringLiteral(">(q.value(i++))");
|
|
}
|
|
|
|
QString MemberInformationWrapper::ddsToJsonElement() const
|
|
{
|
|
// POD
|
|
// obj[QStringLiteral("inner")] = element;
|
|
|
|
// mandatory
|
|
// obj[QStringLiteral("vulnerabilityState")] = element.vulnerabilityState().underlying();
|
|
|
|
// optional
|
|
// if (element.chargeTypeId().is_set()) obj[QStringLiteral("chargeTypeId")] = element.chargeTypeId().get();
|
|
|
|
if (cppMemberName().isEmpty())
|
|
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
|
|
|
|
if (!isOptional())
|
|
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
|
|
cppToJsonPre() + QStringLiteral("element.") + cppMemberName() + QStringLiteral("()") + cppToJsonPost();
|
|
|
|
return QStringLiteral("if (element.") + cppMemberName() + QStringLiteral("().is_set()) ") +
|
|
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
|
|
cppToJsonPre() + QStringLiteral("element.") + cppMemberName() + QStringLiteral("().get()") + cppToJsonPost();
|
|
}
|
|
|
|
QString MemberInformationWrapper::jsonElementToDds() const
|
|
{
|
|
// POD
|
|
// element = objElement.value(QStringLiteral("inner")).toInt();
|
|
|
|
// common (mandatory and optional)
|
|
// const QJsonValue chargeTypeId(objElement.value(QStringLiteral("chargeTypeId")));
|
|
|
|
// mandatory
|
|
// element.vulnerabilityId(vulnerabilityId.toInt());
|
|
|
|
// optional
|
|
// if (!chargeTypeId.isNull()) element.chargeTypeId(chargeTypeId.toInt());
|
|
|
|
// POD?
|
|
if (cppMemberName().isEmpty())
|
|
return QStringLiteral("element = ") +
|
|
cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") + cppType() + QStringLiteral("\"))") + cppFromJsonPost();
|
|
|
|
QString ret(QStringLiteral("const QJsonValue val(objElement.value(QStringLiteral(\"") + cppMemberName() + QStringLiteral("\"))); "));
|
|
if (isOptional())
|
|
ret += QStringLiteral("if (!val.isNull()) ");
|
|
|
|
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral("(") +
|
|
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost() + QStringLiteral(")");
|
|
|
|
return ret;
|
|
}
|
|
|
|
QString MemberInformationWrapper::dbToJsonElement() const
|
|
{
|
|
// POD
|
|
// obj[QStringLiteral("inner")] = element;
|
|
|
|
// mandatory
|
|
// obj[QStringLiteral("vulnerabilityId")] = element.vulnerabilityId.toInt());
|
|
|
|
// optional
|
|
// if (!element.chargeTypeId.isNull()) obj[QStringLiteral("chargeTypeId")] = element.chargeTypeId().toInt();
|
|
|
|
if (cppMemberName().isEmpty())
|
|
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
|
|
|
|
if (isOptional() || cppType() == QStringLiteral("QDateTime"))
|
|
{
|
|
QString ret = QStringLiteral("if (") + ((cppType() == QStringLiteral("QDateTime")) ? QString() : QStringLiteral("!")) +
|
|
QStringLiteral("element.") + cppMemberName() +
|
|
((cppType() == QStringLiteral("QDateTime")) ? QStringLiteral(".isValid()) ") : QStringLiteral(".isNull()) ")) +
|
|
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ");
|
|
if (isOptional())
|
|
return ret += cppFromQvPre2() + QStringLiteral("element.") + cppMemberName() + cppFromQvPost();
|
|
}
|
|
|
|
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
|
|
cppToJsonPre() + QStringLiteral("element.") + cppMemberName() + cppToJsonPost();
|
|
}
|
|
|
|
QString MemberInformationWrapper::jsonElementToDb() const
|
|
{
|
|
// POD
|
|
// element = objElement.value(QStringLiteral("inner")).toInt();
|
|
|
|
// common (mandatory and optional)
|
|
// const QJsonValue val(objElement.value(QStringLiteral("chargeTypeId")));
|
|
|
|
// mandatory
|
|
// element.vulnerabilityId = (val.toInt());
|
|
|
|
// optional
|
|
// if (!chargeTypeId.isNull()) element.chargeTypeId(chargeTypeId.toInt());
|
|
|
|
// POD?
|
|
if (cppMemberName().isEmpty())
|
|
return QStringLiteral("element = ") +
|
|
cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") + cppType() + QStringLiteral("\"))") + cppFromJsonPost();
|
|
|
|
QString ret(QStringLiteral("const QJsonValue val(objElement.value(QStringLiteral(\"") + cppMemberName() + QStringLiteral("\"))); "));
|
|
if (isOptional())
|
|
ret += QStringLiteral("if (!val.isUndefined()) ");
|
|
|
|
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral(" = ") +
|
|
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost();
|
|
|
|
return ret;
|
|
}
|
|
|
|
QVariantList DbStructWrapper::insertStructures()
|
|
{
|
|
// todo: only buildup once
|
|
QStringList tableNames; // must be sorted
|
|
QMap<QString, QVector<MemberInformationWrapper *>> structures;
|
|
QMap<QString, MemberInformationWrapper *> primaryKeys;
|
|
QMap<QString, MemberInformationWrapper *> fkComplexTableKeys;
|
|
// silce clazy...
|
|
tableNames.reserve(5);
|
|
for (const QVariant &v : qAsConst(m_member))
|
|
{
|
|
MemberInformationWrapper *mi = v.value<MemberInformationWrapper *>();
|
|
const QString &tableName = mi->info().db.table;
|
|
if (mi->info().db.usedForInsert)
|
|
{
|
|
auto &tnStructure = structures[tableName];
|
|
tnStructure.append(mi);
|
|
if (!tableNames.contains(tableName))
|
|
tableNames.push_back(tableName);
|
|
}
|
|
if (mi->info().fk)
|
|
fkComplexTableKeys[mi->info().fk->destination.tableName] = mi;
|
|
if (mi->info().db.isPrimaryKey)
|
|
{
|
|
if (!primaryKeys.contains(tableName))
|
|
primaryKeys[tableName] = mi;
|
|
}
|
|
if (mi->info().db.isAssignmentForPrimaryTablePk)
|
|
fkComplexTableKeys[mi->info().db.table] = mi;
|
|
}
|
|
/*
|
|
* When a dbstruct is built from more than one table, we need to propagate
|
|
* the sequence ids from the base to the derived class:
|
|
* ppm_aggregate_entity : ppm_participant : ppm_entity
|
|
* ppm_participant.entity_id = ppm_entity.id
|
|
* ppm_aggregate_entity.participant_id = ppm_participant.id
|
|
* In the resulting structure we've 4 members:
|
|
* id -> ppm_entity.id
|
|
* entity_id -> ppm_entity.id
|
|
* participant_id -> ppm_participant.id
|
|
* aggregate_entity_id -> ppm_aggregate_entity.id
|
|
* Therefore we have to know the pk and corresponding fk in the single tables
|
|
*/
|
|
QVariantList vl;
|
|
vl.reserve(tableNames.size());
|
|
for (int i = 0; i < tableNames.size(); ++i)
|
|
{
|
|
const QString &tn = tableNames.at(i);
|
|
MemberInformationWrapper *serialMember = fkComplexTableKeys.value(tn);
|
|
MemberInformationWrapper *baseId = nullptr;
|
|
MemberInformationWrapper *primaryKey = primaryKeys.value(tn);
|
|
if (i == 0 && tableNames.size() > 1)
|
|
baseId = primaryKeys.value(tn);
|
|
|
|
// for structs with one table, all three MemberInformationWrapper - ptr
|
|
// are equal
|
|
if (tableNames.size() == 1)
|
|
{
|
|
baseId = nullptr; // should be null - otherwise we generate two assignments with the same values which is superfluous
|
|
// there are also primary keys without a serial on it
|
|
if (!primaryKey)
|
|
{
|
|
NGL::INGLLogger &logger = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DbStructWrapper");
|
|
WARNING_LOG(logger) << "Table " << tn << " has no primary key!";
|
|
}
|
|
else
|
|
{
|
|
if (primaryKey->dbHasSequence())
|
|
serialMember = primaryKey;
|
|
}
|
|
}
|
|
|
|
const QVector<MemberInformationWrapper *> members = structures.value(tn);
|
|
TableWrapper *tw = new TableWrapper(tn, members, serialMember, baseId, primaryKey, this);
|
|
vl += QVariant::fromValue(tw);
|
|
}
|
|
|
|
return vl;
|
|
}
|