- 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>
168 lines
5.4 KiB
C++
168 lines
5.4 KiB
C++
|
|
|
|
#include "CppTopicGeneratorGrantlee.h"
|
|
#include "DaoGeneratorGrantlee.h"
|
|
#include "DatabaseGeneratorGrantlee.h"
|
|
#include "SqlGenerator.h"
|
|
#include "StructBuilder.h"
|
|
#include "XmlReader.h"
|
|
|
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
|
#include <NGLLogger/INGLLogger.h>
|
|
#include <QtCore/QDir>
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
|
|
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
|
{
|
|
public:
|
|
CmdLineParser() : LtsCommandLineParser(LtsCommandLineParser::LtsCommandLineParser::None)
|
|
{
|
|
addOption({QStringList() << QStringLiteral("s") << QStringLiteral("servicefile"),
|
|
QStringLiteral("full path to the service xml-file"), QStringLiteral("service xml-file"),
|
|
QStringLiteral("/home")});
|
|
|
|
addOption({QStringList() << QStringLiteral("a") << QStringLiteral("action"),
|
|
QStringLiteral("the action to execute"), QStringLiteral("DATABASE|DATABASE_SERVER|IDL|DDS_TOPICS"),
|
|
QStringLiteral("/0")});
|
|
|
|
addOption({QStringList() << QStringLiteral("o") << QStringLiteral("outdir"),
|
|
QStringLiteral("the output directory where to put the generated files"),
|
|
QStringLiteral("output directory"), QStringLiteral("/home")});
|
|
|
|
addOption({QStringList() << QStringLiteral("i") << QStringLiteral("idlinfo"),
|
|
QStringLiteral("the info file with all available idl service files"),
|
|
QStringLiteral("info file for idl"), QStringLiteral("/0")});
|
|
}
|
|
|
|
bool init()
|
|
{
|
|
if (!LtsCommandLineParser::init())
|
|
return false;
|
|
|
|
if (serviceFile().isEmpty() || action().isEmpty() || outDir().isEmpty())
|
|
{
|
|
showHelp();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
QString serviceFile() const
|
|
{
|
|
return value(QStringLiteral("s"));
|
|
}
|
|
|
|
QString action() const
|
|
{
|
|
return value(QStringLiteral("a"));
|
|
}
|
|
|
|
QString outDir() const
|
|
{
|
|
return value(QStringLiteral("o"));
|
|
}
|
|
|
|
QString idlInfoFile() const
|
|
{
|
|
return value(QStringLiteral("i"));
|
|
}
|
|
};
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
app.createLogger("CodeGen", "codegen_log4cxx.props", true);
|
|
|
|
NGL::INGLLogger& m_logger = app.baseLogger();
|
|
|
|
CmdLineParser options;
|
|
if (!options.init())
|
|
return -1;
|
|
|
|
QScopedPointer<CodeGen::XmlReader> reader(new CodeGen::XmlReader);
|
|
|
|
DEBUG_LOG(m_logger) << "ServiceFile: " << options.serviceFile();
|
|
DEBUG_LOG(m_logger) << "IdlInfoFile: " << options.idlInfoFile();
|
|
if (!reader->readServiceFile(options.serviceFile(), options.idlInfoFile()))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error parsing service file '" << options.serviceFile() << ": " << reader->errorString();
|
|
return 2;
|
|
}
|
|
|
|
QDir dir(options.outDir());
|
|
DEBUG_LOG(m_logger) << "Directory: " << options.outDir();
|
|
if (!dir.exists() && !dir.mkpath(options.outDir()))
|
|
{
|
|
ERROR_LOG(m_logger) << "Directory '" << options.outDir() << "' does not exist and can not be created!";
|
|
return 3;
|
|
}
|
|
|
|
QScopedPointer<CodeGen::StructBuilder> structBuilder(new CodeGen::StructBuilder(reader.data()));
|
|
if (!structBuilder->buildStructures())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error building up structures";
|
|
return 4;
|
|
}
|
|
|
|
const QString action = options.action().toLower();
|
|
|
|
QScopedPointer<CodeGen::GeneratorGrantleeBase> generator;
|
|
if (action == QStringLiteral("dao"))
|
|
generator.reset(new CodeGen::DaoGeneratorGrantlee);
|
|
else if (action == QStringLiteral("database"))
|
|
generator.reset(new CodeGen::DatabaseGeneratorGrantlee(false));
|
|
else if (action == QStringLiteral("database_server"))
|
|
generator.reset(new CodeGen::DatabaseGeneratorGrantlee(true));
|
|
else if (action == QStringLiteral("dds_topics"))
|
|
generator.reset(new CodeGen::CppTopicGeneratorGrantlee);
|
|
else if (action == QStringLiteral("sql"))
|
|
{
|
|
CodeGen::SqlGenerator sql(reader.data(), structBuilder.data());
|
|
if (!sql.generateData(35))
|
|
return 8;
|
|
|
|
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
|
return 10;
|
|
}
|
|
|
|
if (!sql.generateData(42))
|
|
return 8;
|
|
|
|
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
|
return 10;
|
|
}
|
|
|
|
sql.generateData(0);
|
|
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Global))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
|
return 10;
|
|
}
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
ERROR_LOG(m_logger) << "Invalid action '" << options.action() << "' given!";
|
|
return 5;
|
|
}
|
|
|
|
if (!generator->init(reader.data(), structBuilder.data()))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error initializing generator!";
|
|
return 6;
|
|
}
|
|
|
|
const auto posArgs = options.positionalArguments();
|
|
for (const QString& file : posArgs)
|
|
{
|
|
|
|
if (!generator->generateData(file, dir.absolutePath()))
|
|
return 7;
|
|
}
|
|
return 0;
|
|
}
|