- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document
C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+
Build status: BUILD_RTI=OFF successful (0 errors, warnings only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
199 lines
6.7 KiB
C++
199 lines
6.7 KiB
C++
|
|
|
|
#pragma once
|
|
|
|
#include "StructBuilder.h"
|
|
#include "codegen_base_export.h"
|
|
|
|
#include <QtCore/QSharedPointer>
|
|
#include <QtCore/QStringList>
|
|
|
|
namespace NGL
|
|
{
|
|
class INGLLogger;
|
|
}
|
|
|
|
namespace CodeGen
|
|
{
|
|
struct ColumnInformation;
|
|
struct ConstraintInformation;
|
|
struct EnumInformation;
|
|
struct ForeignKeyInformation;
|
|
struct TableInformation;
|
|
class XmlReader;
|
|
|
|
class CODEGEN_BASE_EXPORT SqlGenerator final
|
|
{
|
|
public:
|
|
struct SqlStatements
|
|
{
|
|
QStringList dropViews;
|
|
QStringList dropTables;
|
|
QStringList dropSequences;
|
|
QStringList dropConstraints;
|
|
|
|
QStringList createTables;
|
|
QStringList createSequences;
|
|
QStringList createPrimaryKeys;
|
|
QStringList createForeignKeys;
|
|
QStringList createViews;
|
|
QStringList createConstraints;
|
|
|
|
QStringList enumerationValues;
|
|
QStringList dbFunctions;
|
|
QStringList dbFunctionTrigger;
|
|
|
|
bool isEmpty() const
|
|
{
|
|
return dropViews.isEmpty() && dropTables.isEmpty() && dropSequences.isEmpty() && dropConstraints.isEmpty();
|
|
}
|
|
};
|
|
|
|
struct SqlItems
|
|
{
|
|
QStringList tables;
|
|
QStringList sequences;
|
|
QStringList primaryKeys;
|
|
QStringList foreignKeys;
|
|
QStringList constraints;
|
|
};
|
|
|
|
public:
|
|
Q_DISABLE_COPY(SqlGenerator)
|
|
|
|
explicit SqlGenerator(XmlReader* xmlReader, StructBuilder* structBuilder);
|
|
explicit SqlGenerator(const QString& xmlFile);
|
|
|
|
~SqlGenerator();
|
|
|
|
bool isValid() const
|
|
{
|
|
return m_isValid;
|
|
}
|
|
|
|
bool generateData(int exerciseId);
|
|
|
|
bool createStatementsForTable(const QString& tableName, const QString& tableNameOut);
|
|
|
|
SqlStatements getStatements(ExerciseDependency ed) const
|
|
{
|
|
return (ed == ExerciseDependency::Exercise ? m_sqlExercise : m_sqlGlobal);
|
|
}
|
|
|
|
SqlItems getSqlItems(ExerciseDependency ed) const
|
|
{
|
|
return (ed == ExerciseDependency::Exercise ? m_sqlItemsExercise : m_sqlItemsGlobal);
|
|
}
|
|
|
|
QStringList getEnumerationInsertValues(const QString& table, const QString& dbSchema) const;
|
|
|
|
QStringList getReferencedServices() const
|
|
{
|
|
return m_referencedSevices;
|
|
}
|
|
|
|
QStringList getDbSettings(const QString& dbSchema) const;
|
|
|
|
bool writeSql(const QString& filePath, ExerciseDependency ed);
|
|
|
|
bool writeSqlToFile(const QString& dbSchema, const QString& sqlFile, ExerciseDependency ed) const;
|
|
|
|
QString getServiceAbbr() const
|
|
{
|
|
return m_xmlReader->getServiceAbbr();
|
|
}
|
|
|
|
bool isServiceExerciseIndependent() const
|
|
{
|
|
return m_xmlReader->isServiceExerciseIndependent();
|
|
}
|
|
|
|
bool isServiceGlobal() const
|
|
{
|
|
return (m_xmlReader->defaultExerciseDependency() == CodeGen::ExerciseDependency::Global ||
|
|
m_xmlReader->defaultExerciseDependency() == CodeGen::ExerciseDependency::GlobalAndExercise);
|
|
}
|
|
|
|
CodeGen::ExerciseDependency getExerciseDependency() const
|
|
{
|
|
return m_xmlReader->defaultExerciseDependency();
|
|
}
|
|
|
|
QStringList getGroupNames() const
|
|
{
|
|
return m_xmlReader->getGroupNames();
|
|
}
|
|
|
|
QStringList getAllSqlStmts(const QString& dbSchema, ExerciseDependency ed) const;
|
|
|
|
protected:
|
|
NGL::INGLLogger& m_logger;
|
|
|
|
private:
|
|
bool handleTables();
|
|
bool handleViews();
|
|
bool handleTable(const CompleteTableInformation& cti);
|
|
bool handleView(const ViewInformation& vi);
|
|
QString getTableColumnCreateStatements(const QString& tableName, const QVector<MemberInformation>& columns,
|
|
QStringList* tableComments, ExerciseDependency ed);
|
|
QString generateSequence(const QString& tableName, const FullQualifiedColumnInformation& ci, ExerciseDependency ed);
|
|
void generatePrimaryKey(const QString& tableName, const FullQualifiedColumnInformation& ci, ExerciseDependency ed);
|
|
void generateForeignKeys(const QVector<QSharedPointer<ForeignKeyInformation>>& foreignKeys, ExerciseDependency ed);
|
|
void generateForeignKey(const QSharedPointer<ForeignKeyInformation>& foreignKey, ExerciseDependency ed);
|
|
void generateConstraints(const QString& tableName, const QVector<ConstraintInformation>& constraints,
|
|
ExerciseDependency ed);
|
|
void generateConstraint(const QString& tableName, const ConstraintInformation& constraint, ExerciseDependency ed);
|
|
bool handleEnumerations();
|
|
bool handleEnumeration(const EnumInformation& ei);
|
|
QStringList handleEnumeration(const EnumInformation& ei, const QString& dbSchema) const;
|
|
bool generateDbNotifications(const QString& tableName, const QVector<DbNotifcationInformation>& notifications,
|
|
ExerciseDependency ed);
|
|
void generateDbNotification(const DbNotifcationInformation& notification, ExerciseDependency ed);
|
|
bool generateDbNotificationTrigger(const QString& tableName, const DbNotifcationInformation& notification,
|
|
ExerciseDependency ed);
|
|
QString getNotificationFunctionName(const DbNotifcationInformation& notification) const;
|
|
static QString fixupComment(const QString& comment);
|
|
|
|
private:
|
|
XmlReader* m_xmlReader;
|
|
StructBuilder* m_structBuilder;
|
|
bool m_createdByXmlFile;
|
|
|
|
void addToDropSequences(const QString& stmt, ExerciseDependency ed);
|
|
void addToDropTables(const QString& stmt, ExerciseDependency ed);
|
|
void addToDropViews(const QString& stmt, ExerciseDependency ed);
|
|
void addToDropConstraints(const QString& stmt, ExerciseDependency ed);
|
|
|
|
void addToCreateConstraints(const QString& stmt, ExerciseDependency ed);
|
|
void addToCreateFks(const QString& stmt, ExerciseDependency ed);
|
|
void addToCreatePks(const QString& stmt, ExerciseDependency ed);
|
|
void addToCreateSequences(const QString& stmt, ExerciseDependency ed);
|
|
void addToCreateTables(const QString& stmt, ExerciseDependency ed);
|
|
void addToCreateTables(const QStringList& stmts, ExerciseDependency ed);
|
|
void addToCreateViews(const QString& stmt, ExerciseDependency ed);
|
|
|
|
void addToDbFunctions(const QString& stmt, ExerciseDependency ed);
|
|
void addToDbFunctionTrigger(const QString& stmt, ExerciseDependency ed);
|
|
|
|
void addToConstraints(const QString& name, ExerciseDependency ed);
|
|
void addToFks(const QString& name, ExerciseDependency ed);
|
|
void addToPks(const QString& name, ExerciseDependency ed);
|
|
void addToSequences(const QString& name, ExerciseDependency ed);
|
|
void addToTables(const QString& name, ExerciseDependency ed);
|
|
|
|
bool writeFile(const QString& fn, const QString& content) const;
|
|
|
|
SqlStatements m_sqlGlobal;
|
|
SqlStatements m_sqlExercise;
|
|
|
|
SqlItems m_sqlItemsGlobal;
|
|
SqlItems m_sqlItemsExercise;
|
|
|
|
QStringList m_referencedSevices;
|
|
|
|
bool m_isValid;
|
|
int m_exerciseId;
|
|
};
|
|
|
|
} // namespace CodeGen
|