Grantlee Templates: Fix namespace resolution for RTI DTC generation

- Changed {{ namespace }}::{{ dt.type }} to ::{{ namespace }}::{{ dt.type }}
  in svc_dtc.h.grantlee, svc_dtc_impl.cpp.grantlee, svc_dtc_impl.h.grantlee
- Ensures absolute namespace resolution for Core::* types
- Fixes MOC/compilation errors for CurrentRunningState, LockedEntity, etc.

- Updated CMakeLists.txt for RTI 7.7.0 detection with DDS_PATH
- Fixed RTI include paths (ndds/hpp and ndds directories)
- Updated Lts/DDS module files for Qt6/RTI 7.7 compatibility

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
torstenandCopilot committed 2026-08-31 12:51:26 +02:00
1 parent 497baa804b
commit ad07345480
14 files changed
+183 -62

No files matched your search

@@ -18,6 +18,9 @@
#include <{{ include_prefix }}/{{ namespace_abbr }}_export.h>
#include <{{ include_prefix }}/{{ namespace_abbr }}.hpp>
// Bring Core namespace types into scope for Interface namespace
using namespace {{ namespace }};
namespace DDSConnector
{
class DdsConnector;
@@ -68,16 +71,16 @@ public:
//
// Data Topic '{{ dt.name }}'
// {% if dt.key.name %}
virtual QMap<{{ dt.key.cppType }}, {{ namespace }}::{{ dt.type }}> {{ dt.nameFlc }}s() = 0;
virtual bool {{ dt.nameFlc }}s(const std::function<void(const {{ namespace }}::{{ dt.type }} &data)> &cb) = 0;
virtual QMap<{{ dt.key.cppType }}, ::{{ namespace }}::{{ dt.type }}> {{ dt.nameFlc }}s() = 0;
virtual bool {{ dt.nameFlc }}s(const std::function<void(const ::{{ namespace }}::{{ dt.type }} &data)> &cb) = 0;
// when the cb returns true, the loop is stopped (useful when searching for a specific topic)
virtual bool {{ dt.nameFlc }}s(const std::function<bool(const {{ namespace }}::{{ dt.type }} &data)> &cb) = 0;
virtual {{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc }}) = 0;
virtual bool {{ dt.nameFlc }}s(const std::function<bool(const ::{{ namespace }}::{{ dt.type }} &data)> &cb) = 0;
virtual ::{{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc }}) = 0;
{% else %}
virtual {{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}() = 0;
virtual ::{{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}() = 0;
{% endif %}
Q_SIGNALS:
void {{ dt.nameFlc }}Changed(const {{ namespace }}::{{ dt.type }} &data, DataModification modType);
void {{ dt.nameFlc }}Changed(const ::{{ namespace }}::{{ dt.type }} &data, DataModification modType);
{% endfor %}
@@ -218,7 +218,7 @@ template <>
return val.{{ dt.key.name }}();
}
QMap<{{ dt.key.cppType }},{{ namespace }}::{{ dt.type }}> DtcImpl::{{ dt.nameFlc }}s()
QMap<{{ dt.key.cppType }},::{{ namespace }}::{{ dt.type }}> DtcImpl::{{ dt.nameFlc }}s()
{
if (!is{{ dt.name }}Enabled())
{
@@ -229,7 +229,7 @@ QMap<{{ dt.key.cppType }},{{ namespace }}::{{ dt.type }}> DtcImpl::{{ dt.nameFlc
return m_{{ dt.nameFlc }}Cont;
}
bool DtcImpl::{{ dt.nameFlc }}s(const std::function<void(const {{ namespace }}::{{ dt.type }} &data)> &cb)
bool DtcImpl::{{ dt.nameFlc }}s(const std::function<void(const ::{{ namespace }}::{{ dt.type }} &data)> &cb)
{
if (!is{{ dt.name }}Enabled())
{
@@ -240,7 +240,7 @@ bool DtcImpl::{{ dt.nameFlc }}s(const std::function<void(const {{ namespace }}::
return iterateAll(m_dtc{{ dt.name }}, m_{{ dt.nameFlc }}Cont, cb);
}
bool DtcImpl::{{ dt.nameFlc }}s(const std::function<bool(const {{ namespace }}::{{ dt.type }} &data)> &cb)
bool DtcImpl::{{ dt.nameFlc }}s(const std::function<bool(const ::{{ namespace }}::{{ dt.type }} &data)> &cb)
{
if (!is{{ dt.name }}Enabled())
{
@@ -251,7 +251,7 @@ bool DtcImpl::{{ dt.nameFlc }}s(const std::function<bool(const {{ namespace }}::
return iterateUntil(m_dtc{{ dt.name }}, m_{{ dt.nameFlc }}Cont, cb);
}
{{ namespace }}::{{ dt.type }} DtcImpl::{{ dt.nameFlc }}({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc }})
::{{ namespace }}::{{ dt.type }} DtcImpl::{{ dt.nameFlc }}({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc }})
{
if (!is{{ dt.name }}Enabled())
{
@@ -262,7 +262,7 @@ bool DtcImpl::{{ dt.nameFlc }}s(const std::function<bool(const {{ namespace }}::
return getOne(m_dtc{{ dt.name }}, m_{{ dt.nameFlc }}Cont, {{ dt.key.nameFlc }});
}
void DtcImpl::{{ dt.nameFlc }}ChangedInternal(const {{ namespace }}::{{ dt.type }} &data, DataModification modType)
void DtcImpl::{{ dt.nameFlc }}ChangedInternal(const ::{{ namespace }}::{{ dt.type }} &data, DataModification modType)
{
switch (modType)
{
@@ -278,11 +278,11 @@ void DtcImpl::{{ dt.nameFlc }}ChangedInternal(const {{ namespace }}::{{ dt.type
}
{% else %}
{{ namespace }}::{{ dt.type }} DtcImpl::{{ dt.nameFlc }}()
::{{ namespace }}::{{ dt.type }} DtcImpl::{{ dt.nameFlc }}()
{
return m_{{ dt.nameFlc }};
}
void DtcImpl::{{ dt.nameFlc }}ChangedInternal(const {{ namespace }}::{{ dt.type }} &data, DataModification modType)
void DtcImpl::{{ dt.nameFlc }}ChangedInternal(const ::{{ namespace }}::{{ dt.type }} &data, DataModification modType)
{
switch (modType)
{
@@ -291,7 +291,7 @@ void DtcImpl::{{ dt.nameFlc }}ChangedInternal(const {{ namespace }}::{{ dt.type
m_{{ dt.nameFlc }} = data;
break;
case DataModification::eRemoved:
m_{{ dt.nameFlc }} = {{ namespace }}::{{ dt.type }}();
m_{{ dt.nameFlc }} = ::{{ namespace }}::{{ dt.type }}();
break;
}
emit {{ dt.nameFlc }}Changed(data, modType);
@@ -52,12 +52,12 @@ public:
bool is{{ dt.name }}Enabled() const override final { return m_dtc{{ dt.name }} != nullptr; }
bool waitForHistoricalData{{ dt.name }}(int timeoutMSec = -1) override final;
{% if dt.key.name %}
QMap<{{ dt.key.cppType }}, {{ namespace }}::{{ dt.type }}> {{ dt.nameFlc }}s() override final;
bool {{ dt.nameFlc }}s(const std::function<void(const {{ namespace }}::{{ dt.type }} &data)> &cb) override final;
bool {{ dt.nameFlc }}s(const std::function<bool(const {{ namespace }}::{{ dt.type }} &data)> &cb) override final;
{{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc }}) override final;
QMap<{{ dt.key.cppType }}, ::{{ namespace }}::{{ dt.type }}> {{ dt.nameFlc }}s() override final;
bool {{ dt.nameFlc }}s(const std::function<void(const ::{{ namespace }}::{{ dt.type }} &data)> &cb) override final;
bool {{ dt.nameFlc }}s(const std::function<bool(const ::{{ namespace }}::{{ dt.type }} &data)> &cb) override final;
::{{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}({{ dt.key.cppTypeCr }} {{ dt.key.nameFlc }}) override final;
{% else %}
{{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}() override final;
::{{ namespace }}::{{ dt.type }} {{ dt.nameFlc }}() override final;
{% endif %} {% endif %} {% endfor %}
private:
@@ -85,10 +85,10 @@ protected:
{% for dt in dataTopics.member %}
{% if dt.dtcImpl %}
void {{ dt.nameFlc }}ChangedInternal(const {{ namespace }}::{{ dt.type }} &data, DataModification modType);
void {{ dt.nameFlc }}ChangedInternal(const ::{{ namespace }}::{{ dt.type }} &data, DataModification modType);
std::unique_ptr<DTC::{{ dt.name }}> m_dtc{{ dt.name }}; {% if dt.key.name %}
QMap<{{ dt.key.cppType }}, {{ namespace }}::{{ dt.type }}> m_{{ dt.nameFlc }}Cont; {% else %}
{{ namespace }}::{{ dt.type }} m_{{ dt.nameFlc }};
QMap<{{ dt.key.cppType }}, ::{{ namespace }}::{{ dt.type }}> m_{{ dt.nameFlc }}Cont; {% else %}
::{{ namespace }}::{{ dt.type }} m_{{ dt.nameFlc }};
{% endif %} {% endif %} {% endfor %}
LOGGER_T m_logger;
@@ -5,6 +5,7 @@
#
IF(BUILD_RTI)
ADD_SUBDIRECTORY(QosProfile)
ADD_SUBDIRECTORY(DDSConnector)
ENDIF()
@@ -18,9 +19,6 @@ ADD_SUBDIRECTORY(Generic)
ADD_SUBDIRECTORY(Routing)
ADD_SUBDIRECTORY(Core)
IF(BUILD_RTI)
ADD_SUBDIRECTORY(QosProfile)
ENDIF()
# During stepwise migration, add placeholder CTest entries before the
# real DdsUnitTests subdir so the test-suite shows migration status even
@@ -5,7 +5,7 @@
#include <string>
#include <vector>
#include "ddscore_export.h"
#include "core_export.h"
#ifndef tr_lts
#define tr_lts(ctx, t) (t)
@@ -4,7 +4,7 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
#include "ddscore_export.h"
#include "core_export.h"
namespace Core
{
@@ -2,6 +2,7 @@
#include "pacemaker.h"
#if BUILD_RTI
#include <DDS/DDSConnector/dds_connector.h>
#include <DDS/DTS/generic_dts.h>
#include <DDS/DTS/generic_dts_impl.h>
@@ -14,7 +15,7 @@ namespace Core
{
Pacemaker::Pacemaker(DDSConnector::DdsConnector *ddsConnector)
: QObject(nullptr)
.getNGLLogger("Core.Pacemaker"))
, m_logger(NGL::INGLLoggerBootstrap::getNGLLogger("Core.Pacemaker"))
{
init(ddsConnector);
}
@@ -108,4 +109,57 @@ void Pacemaker::startTimer()
m_paceThread->start();
}
#else // BUILD_RTI
Pacemaker::Pacemaker(void* ddsConnector)
: QObject(nullptr)
{
Q_UNUSED(ddsConnector)
}
Pacemaker::~Pacemaker()
{
}
void Pacemaker::setNewState(Core::RunningState newState, const QString& errorString)
{
Q_UNUSED(newState)
Q_UNUSED(errorString)
}
void Pacemaker::setNewStateInternal(Core::RunningState newState, const QString& errorString)
{
Q_UNUSED(newState)
Q_UNUSED(errorString)
}
void Pacemaker::addPort(unsigned short number, Core::PortType portType, const QString& properties)
{
Q_UNUSED(number)
Q_UNUSED(portType)
Q_UNUSED(properties)
}
void Pacemaker::addPortInternal(unsigned short number, Core::PortType portType, const QString& properties)
{
Q_UNUSED(number)
Q_UNUSED(portType)
Q_UNUSED(properties)
}
void Pacemaker::publishState()
{
}
void Pacemaker::init(void* ddsConnector)
{
Q_UNUSED(ddsConnector)
}
void Pacemaker::startTimer()
{
}
#endif // BUILD_RTI
} // namespace Core
@@ -4,12 +4,18 @@
#include "svccoreclient_export.h"
#if BUILD_RTI
#include <DDS/Core/core_dts_types.h>
#endif
#include <QtCore/QObject>
#include <QtCore/QThread>
// Forward declarations for moc compatibility (moc doesn't see BUILD_RTI guards)
namespace Core { enum class RunningState; enum class PortType; }
namespace DTS { class CurrentRunningStateImpl; }
#if BUILD_RTI
#include <dds/core/core_dts_types.h>
#include <dds/core/types/CurrentRunningState.h>
#endif
namespace DDSConnector
{
class DdsConnector;
@@ -52,26 +58,24 @@ class CORE_CLIENT_EXPORT Pacemaker final : public QObject
#endif
private:
NGL::INGLLogger& m_logger;
#if BUILD_RTI
NGL::INGLLogger& m_logger;
void init(DDSConnector::DdsConnector* ddsConnector);
void setNewStateInternal(Core::RunningState newState, const QString& errorString = QString());
void addPortInternal(unsigned short number, Core::PortType portType,
const QString& properties = QStringLiteral(""));
#endif
private:
NGL::INGLLogger& m_logger;
static constexpr const int m_publishTimerDelay = 3000;
#if BUILD_RTI
CurrentRunningState m_state;
DTS::CurrentRunningStateImpl* m_dtsCurrentRunningState = nullptr;
#else
void* m_reserved1 = nullptr;
void* m_reserved2 = nullptr;
void* m_reserved3 = nullptr;
void* m_reserved4 = nullptr;
void* m_reserved5 = nullptr;
#endif
static constexpr const int m_publishTimerDelay = 3000;
QTimer* m_publishTimer = nullptr;
QThread* m_paceThread = nullptr;
#if BUILD_RTI
DTS::CurrentRunningStateImpl* m_dtsCurrentRunningState;
#endif
};
} // namespace Core
@@ -1,10 +1,14 @@
#pragma once
#include <Core/core_dtc.h>
#include <QtCore/QSet>
#include <QtCore/QString>
#if BUILD_RTI
#include <Core/core_dtc.h>
#else
// Forward declarations for moc compatibility when BUILD_RTI=OFF
namespace DDS { namespace Core { namespace Interface { class Dtc; } } }
#endif
namespace DDSConnector
{
@@ -44,10 +48,17 @@ class CORE_CLIENT_EXPORT TopicLockMaster : public QObject
{
Q_OBJECT
public:
#if BUILD_RTI
explicit TopicLockMaster(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
~TopicLockMaster();
bool init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
#else
explicit TopicLockMaster(void* /*ddsConnector*/) {}
~TopicLockMaster() = default;
bool init(void* /*ddsConnector*/) { return false; }
#endif
template<typename E>
bool isLocked(const E &data, int exerciseId)
@@ -58,7 +69,9 @@ public:
private:
QSet<key> m_lockedEntitys;
std::shared_ptr<Core::Interface::Dtc> m_coreDtc;
#if BUILD_RTI
std::shared_ptr<DDS::Core::Interface::Dtc> m_coreDtc;
#endif
};
}
@@ -8,7 +8,7 @@
#include "subscriber.h"
#include <DDS/Generic/wait_set_handler.h>
#include <DDS/QosProfile/DDS_DefaultQos.h>
#include <Lts/DDS/QosProfile/DDS_DefaultQos.h>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QtCore/QCoreApplication>
@@ -32,7 +32,7 @@ DdsConnector::DdsConnector(int domainId,
, m_publisher(nullptr)
, m_subscriber(nullptr)
, m_wsHandler(nullptr)
.getNGLLogger("Common.DDSConnector"))
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Common.DDSConnector"))
{
initInternal();
DEBUG_LOG(m_logger) << "DdsConnector ctor: " << m_domainId << "," << m_partitionId << "," << m_exerciseId << ","
@@ -153,8 +153,8 @@ std::string DdsConnector::getPartitionString(IDL::PartitionType pt, int partitio
return IDL::replayPartition(partitionId);
}
NGL::INGLLogger& m_logger = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Common.DDSConnector");
ERROR_LOG(m_logger) << "Invalid partition type: " << static_cast<int>(pt);
NGL::INGLLogger& logger = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Common.DDSConnector");
ERROR_LOG(logger) << "Invalid partition type: " << static_cast<int>(pt);
return std::string();
}
@@ -129,6 +129,13 @@ class DDSCONNECTOR_EXPORT DdsConnector
void initSubscriber();
void initDomainParticipant();
private:
#if BUILD_RTI
void initInternal();
void createWaitSetHandler();
#endif
public:
template <typename T>
T* createDTS(const std::string& topicName =
DDS::Helper::getShortTopicName(DDS::topic_type_name<typename T::TopicType>::value()))
@@ -5,7 +5,7 @@
#include <dds/pub/AnyDataWriter.hpp>
#include <rti/core/xtypes/DynamicDataImpl.hpp>
#include <DDS/QosProfile/DDS_DefaultQos.h>
#include <Lts/DDS/QosProfile/DDS_DefaultQos.h>
#include <NGLLogger/INGLLogger.h>
namespace DDSConnector
@@ -4,7 +4,7 @@
#include "subscriber.h"
#include "pub_sub_base_p.h"
#include <DDS/QosProfile/DDS_DefaultQos.h>
#include <Lts/DDS/QosProfile/DDS_DefaultQos.h>
#include <NGLLogger/INGLLogger.h>
namespace DDSConnector