Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/CodeGen/svc_db_impl.h.grantlee
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
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>
2026-09-15 18:20:26 +00:00

103 lines
4.2 KiB
Plaintext

/**
* @RDE_HEADER@
* Template for 'real' structures including insert/update/delete functions for db
* $Id$
* $HeadURL$
* $Author$
*/
{% autoescape off %}
// filename: {{ namespace_abbr }}_db_impl.h
#pragma once
#include <QPointF>
#include <QString>
#include <QVector>
#include <QSqlDriver>
#include <QSqlDatabase>
#include <QtSql/QSqlError>
#include <{{ include_prefix }}/{{ namespace_abbr }}_enums.hpp>
#include <{{ include_prefix }}/{{ namespace_abbr }}_db.h>
#include <{{ include_prefix }}/logger.h>
class NSqlQuery;
namespace {{ namespace }}
{
class {{ namespace_abbr_upper }}_COMMON_EXPORT DatabaseInterfaceImpl {% if not custom_db_procs %}final {%endif %}: public DatabaseInterface
{
Q_OBJECT
public:
explicit DatabaseInterfaceImpl(int exerciseId);
~DatabaseInterfaceImpl();
bool init(const QSqlDatabase &dbConnection) override final;
bool init(const QString &dbUser,
const QString &dbPasswd,
const QString &dbDriver,
const QString &dbHost,
const QString &dbName) override final;
QString schemaName() const override final;
QString dbUser() const override final;
const QSqlDatabase &database() const override final { return m_dbConnection; }
void setEmitMessageOnError(bool bEmit) override final;
QSqlError getLastError() const override final;
{% for cpp_struct in cpp_structs %}
// Database::{{ cpp_struct.name }}
bool insert(Database::{{ cpp_struct.name }} &data) override final;
bool upsert(Database::{{ cpp_struct.name }} &data) override final;
bool update(const Database::{{ cpp_struct.name }} &data) override final;
{% if cpp_struct.insertStructures|length == 1 %}
bool insert(std::vector<Database::{{ cpp_struct.name }}> &cont) override final;
bool upsert(std::vector<Database::{{ cpp_struct.name }}> &cont) override final;
bool update(const std::vector<Database::{{ cpp_struct.name }}> &cont) override final;
{% endif %}
bool select(QVector<Database::{{ cpp_struct.name }}> &dataVec) override final;
bool select(const std::function<void(const Database::{{ cpp_struct.name }} &data)> &cb) override final;
{% for fk in cpp_struct.selectRemoveMember %}
bool selectBy{{ fk.cppMemberNameCc }}(QVector<Database::{{ cpp_struct.name }}> &dataVec, const {{ fk.cppType }} &{{ fk.cppMemberName }}, const QString &orderBy = QString()) override final;
bool selectBy{{ fk.cppMemberNameCc }}(const std::function<void(const Database::{{ cpp_struct.name }} &data)> &cb, const {{ fk.cppType }} &{{ fk.cppMemberName }}, const QString &orderBy = QString()) override final;
{% endfor %}
protected:
bool selectPrepareInternal{{ cpp_struct.name }}(const QString &where);
bool selectFetchInternal{{ cpp_struct.name }}(const std::function<void(const Database::{{ cpp_struct.name }} &data)> &cb);
public:
bool select{{ cpp_struct.name }}({{ cpp_struct.primaryKey.cppType }} {{ cpp_struct.primaryKey.cppMemberName }}, Database::{{ cpp_struct.name }} &data) override final;
bool remove{{ cpp_struct.name }}({{ cpp_struct.primaryKey.cppType }} {{ cpp_struct.primaryKey.cppMemberName }}) override final;
{% if cpp_struct.deleteWithoutPkAllowed %} {% for fk in cpp_struct.selectRemoveMember %}
bool remove{{ cpp_struct.nameCc }}By{{ fk.cppMemberNameCc }}(const {{ fk.cppType }} &{{ fk.cppMemberName }}) override final;
{% endfor %} {% endif %}
bool fixUpSequence{{ cpp_struct.name }}() override final;
bool truncate{{ cpp_struct.name }}() override final;
// Database::{{ cpp_struct.name }}
{% endfor %}
{% for data_struct in data_structs %}
// read only struct{{ data_struct.name }}
bool select(QVector<Database::{{ data_struct.name }}> &dataVec) override final;
{% endfor %}
protected:
QString getTableName(const QString &tableName) const;
{% if has_db_notifications %}
private Q_SLOTS:
void onNotification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload);
{% endif %}
protected:
QSqlDatabase m_dbConnection;
std::unique_ptr<NSqlQuery> m_query;
QSqlError m_lastError;
int m_exerciseId;
bool m_bEmitMessageOnError;
bool m_bCanHandleSchemas;
bool m_ownDatabaseConnection;
LOGGER_T m_logger;
private:
bool initInternal();
};// class DatabaseInterfaceImpl
} // namespace {{ namespace }}
{% endautoescape %}