Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/CodeGen/svc_db.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

146 lines
5.0 KiB
Plaintext

/**
* @RDE_HEADER@
* Template for 'real' structures including insert/update/delete functions for db
* $Id$
* $HeadURL$
* $Author$
*/
{% autoescape off %}
// filename: {{ namespace_abbr }}_db.h
#pragma once
#include <QObject>
#include <functional>
#include <QtSql/QSqlError>
#include <{{ include_prefix }}/{{ namespace_abbr }}_export.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}_db_structs.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}_enums.hpp>
{% for ext_service in ext_services.member %}
#include <{{ ext_service.baseFilePath }}.hpp>
{% endfor %}
namespace NGL
{
class INGLLogger;
}
class QSqlDatabase;
namespace {{ namespace }}
{
class {{ namespace_abbr_upper }}_COMMON_EXPORT DatabaseInterface : public QObject
{
Q_OBJECT
public:
virtual ~DatabaseInterface() = default;
/**
* Create a new instance for {{ namespace }}::DatabaseInterface.
* @param exerciseId if <= 0 -> global service
*/
static std::shared_ptr<DatabaseInterface> create(int exerciseId);
/**
* @brief initialize the database interface (must be called after the db connection was opened!)
* @return true on succcess
*/
virtual bool init(const QSqlDatabase &dbConnection) = 0;
virtual bool init(const QString &dbUser,
const QString &dbPasswd,
const QString &dbDriver,
const QString &dbHost,
const QString &dbName) = 0;
/**
* @brief return the current schema name depending if exercise id > 0 or not
*/
virtual QString schemaName() const = 0;
/**
* @brief return the current database user dependening if exercise id > 0 or not
*/
virtual QString dbUser() const = 0;
/**
* @brief return the database connection used in this DatabaseInterface
*/
virtual const QSqlDatabase &database() const = 0;
/**
* emit an error message (ERROR_LOG) when a statement fails to execute (default: on)
*/
virtual void setEmitMessageOnError(bool bEmit) = 0;
virtual QSqlError getLastError() const = 0;
{% for cpp_struct in cpp_structs %}
//
// Database::{{ cpp_struct.name }}
//
public:
virtual bool insert(Database::{{ cpp_struct.name }} &data) = 0;
virtual bool upsert(Database::{{ cpp_struct.name }} &data) = 0;
virtual bool update(const Database::{{ cpp_struct.name }} &data) = 0;
{% if cpp_struct.insertStructures|length == 1 %}
virtual bool insert(std::vector<Database::{{ cpp_struct.name }}> &cont) = 0;
virtual bool upsert(std::vector<Database::{{ cpp_struct.name }}> &cont) = 0;
virtual bool update(const std::vector<Database::{{ cpp_struct.name }}> &cont) = 0;
{% endif %}
virtual bool select(QVector<Database::{{ cpp_struct.name }}> &dataVec) = 0;
virtual bool select(const std::function<void(const Database::{{ cpp_struct.name }} &data)> &cb) = 0;
{% for fk in cpp_struct.selectRemoveMember %}
virtual bool selectBy{{ fk.cppMemberNameCc }}(QVector<Database::{{ cpp_struct.name }}> &dataVec, const {{ fk.cppType }} &{{ fk.cppMemberName }}, const QString &orderBy = QString()) = 0;
virtual bool selectBy{{ fk.cppMemberNameCc }}(const std::function<void(const Database::{{ cpp_struct.name }} &data)> &cb, const {{ fk.cppType }} &{{ fk.cppMemberName }}, const QString &orderBy = QString()) = 0;
{% endfor %}
virtual bool select{{ cpp_struct.name }}({{ cpp_struct.primaryKey.cppType }} {{ cpp_struct.primaryKey.cppMemberName }}, Database::{{ cpp_struct.name }} &data) = 0;
virtual bool remove{{ cpp_struct.name }}({{ cpp_struct.primaryKey.cppType }} {{ cpp_struct.primaryKey.cppMemberName }}) = 0;
{% if cpp_struct.deleteWithoutPkAllowed %} {% for fk in cpp_struct.selectRemoveMember %}
virtual bool remove{{ cpp_struct.nameCc }}By{{ fk.cppMemberNameCc }}(const {{ fk.cppType }} &{{ fk.cppMemberName }}) = 0;
{% endfor %} {% endif %}
virtual bool fixUpSequence{{ cpp_struct.name }}() = 0;
virtual bool truncate{{ cpp_struct.name }}() = 0;
{% if cpp_struct.dbNotifications %}
Q_SIGNALS:
{% for dbnotify in cpp_struct.dbNotifications %}
// database notification on insert/update/delete
void {{ dbnotify }}(const QVariant &payload);
{% endfor %}
{% endif %}
//
// Database::{{ cpp_struct.name }} end
//
{% endfor %}
{% if data_structs|length > 0 %}
public:{% for data_struct in data_structs %}
// read only struct Database::{{ data_struct.name }}
virtual bool select(QVector<Database::{{ data_struct.name }}> &dataVec) = 0;
{% endfor %} {% endif %}
{% if custom_db_procs|length > 0 %}
public:{% for db_proc in custom_db_procs %}
// custom proc, body must be implemented by user
virtual {{ db_proc.signature }} = 0;
{% endfor %} {% endif %}
public:
// vector of database struct to/from JSON-array
// helper for BaseDownloader
template<typename T>
static QJsonArray toJson(const QVector<T> &dataVec)
{
return Database::toJson<T>(dataVec);
}
template<typename T>
static std::vector<T> fromJson(const QJsonArray &arr)
{
return Database::fromJson<T>(arr);
}
};// class DatabaseInterface
} // namespace {{ namespace }}
{% endautoescape %}