Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+144
-175
@@ -1,13 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#include "dds_connector.h"
|
||||
|
||||
#include "publisher.h"
|
||||
#include "subscriber.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <DDS/Generic/wait_set_handler.h>
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace DDSConnector
|
||||
@@ -32,252 +32,221 @@ DdsConnector::DdsConnector(int domainId,
|
||||
, m_wsHandler(nullptr)
|
||||
.getNGLLogger("Common.DDSConnector"))
|
||||
{
|
||||
initInternal();
|
||||
DEBUG_LOG(m_logger) << "DdsConnector ctor: " << m_domainId << "," << m_partitionId << ","<< m_exerciseId << "," << static_cast<int>(m_defaultPartitionType);
|
||||
initInternal();
|
||||
DEBUG_LOG(m_logger) << "DdsConnector ctor: " << m_domainId << "," << m_partitionId << "," << m_exerciseId << ","
|
||||
<< static_cast<int>(m_defaultPartitionType);
|
||||
}
|
||||
|
||||
DdsConnector::DdsConnector(int domainId,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId, int exerciseId,
|
||||
const QUrl &tcpConnectionUrl)
|
||||
: DdsConnector(domainId,
|
||||
nullptr,
|
||||
defaultPartitionType,
|
||||
partitionId,
|
||||
exerciseId,
|
||||
DDS::QosProfile::ConnectionType::Server,
|
||||
tcpConnectionUrl)
|
||||
{}
|
||||
|
||||
DdsConnector::DdsConnector(const dds::domain::DomainParticipant &domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId, int exerciseId,
|
||||
const QUrl &tcpConnectionUrl)
|
||||
: DdsConnector(domainParticipant.domain_id(),
|
||||
domainParticipant,
|
||||
defaultPartitionType,
|
||||
partitionId,
|
||||
exerciseId,
|
||||
DDS::QosProfile::ConnectionType::Server,
|
||||
tcpConnectionUrl)
|
||||
{}
|
||||
|
||||
|
||||
DdsConnector::DdsConnector(const dds::domain::DomainParticipant &domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
DDS::QosProfile::ConnectionType connectionType,
|
||||
int partitionId,
|
||||
int exerciseId
|
||||
)
|
||||
: DdsConnector(domainParticipant.domain_id(),
|
||||
domainParticipant,
|
||||
defaultPartitionType,
|
||||
partitionId,
|
||||
exerciseId,
|
||||
connectionType,
|
||||
QUrl())
|
||||
{}
|
||||
|
||||
DdsConnector::DdsConnector(int domainId,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId, int exerciseId,
|
||||
DDS::QosProfile::ConnectionType connectionType)
|
||||
: DdsConnector(domainId,
|
||||
nullptr,
|
||||
defaultPartitionType,
|
||||
partitionId,
|
||||
exerciseId,
|
||||
connectionType,
|
||||
QUrl())
|
||||
DdsConnector::DdsConnector(int domainId, IDL::PartitionType defaultPartitionType, int partitionId, int exerciseId,
|
||||
const QUrl& tcpConnectionUrl)
|
||||
: DdsConnector(domainId, nullptr, defaultPartitionType, partitionId, exerciseId,
|
||||
DDS::QosProfile::ConnectionType::Server, tcpConnectionUrl)
|
||||
{
|
||||
Q_ASSERT(connectionType != DDS::QosProfile::ConnectionType::Tcp);
|
||||
}
|
||||
|
||||
DdsConnector::DdsConnector(const dds::domain::DomainParticipant& domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType, int partitionId, int exerciseId,
|
||||
const QUrl& tcpConnectionUrl)
|
||||
: DdsConnector(domainParticipant.domain_id(), domainParticipant, defaultPartitionType, partitionId, exerciseId,
|
||||
DDS::QosProfile::ConnectionType::Server, tcpConnectionUrl)
|
||||
{
|
||||
}
|
||||
|
||||
DdsConnector::DdsConnector(const dds::domain::DomainParticipant& domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType, DDS::QosProfile::ConnectionType connectionType,
|
||||
int partitionId, int exerciseId)
|
||||
: DdsConnector(domainParticipant.domain_id(), domainParticipant, defaultPartitionType, partitionId, exerciseId,
|
||||
connectionType, QUrl())
|
||||
{
|
||||
}
|
||||
|
||||
DdsConnector::DdsConnector(int domainId, IDL::PartitionType defaultPartitionType, int partitionId, int exerciseId,
|
||||
DDS::QosProfile::ConnectionType connectionType)
|
||||
: DdsConnector(domainId, nullptr, defaultPartitionType, partitionId, exerciseId, connectionType, QUrl())
|
||||
{
|
||||
Q_ASSERT(connectionType != DDS::QosProfile::ConnectionType::Tcp);
|
||||
}
|
||||
|
||||
DdsConnector::~DdsConnector()
|
||||
{
|
||||
delete m_subscriber;
|
||||
delete m_publisher;
|
||||
delete m_wsHandler;
|
||||
delete m_subscriber;
|
||||
delete m_publisher;
|
||||
delete m_wsHandler;
|
||||
}
|
||||
|
||||
bool DdsConnector::init(const QStringList &qosFileList)
|
||||
bool DdsConnector::init(const QStringList& qosFileList)
|
||||
{
|
||||
return DDS::QosProfile::setDefault(qosFileList);
|
||||
return DDS::QosProfile::setDefault(qosFileList);
|
||||
}
|
||||
|
||||
QUrl DdsConnector::getTcpConnectionUrl() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << this << " gettcpConnectionUrl: " << m_tcpConnectionUrl.toString();
|
||||
return m_tcpConnectionUrl;
|
||||
DEBUG_LOG(m_logger) << this << " gettcpConnectionUrl: " << m_tcpConnectionUrl.toString();
|
||||
return m_tcpConnectionUrl;
|
||||
}
|
||||
|
||||
dds::pub::Publisher DdsConnector::getDdsPublisher() const
|
||||
{
|
||||
return m_publisher ? m_publisher->getDdsPublisher() : nullptr;
|
||||
return m_publisher ? m_publisher->getDdsPublisher() : nullptr;
|
||||
}
|
||||
|
||||
dds::sub::Subscriber DdsConnector::getDdsSubscriber() const
|
||||
{
|
||||
return m_subscriber ? m_subscriber->getDdsSubscriber() : nullptr;
|
||||
return m_subscriber ? m_subscriber->getDdsSubscriber() : nullptr;
|
||||
}
|
||||
|
||||
DDSGeneric::SubscriberListener *DdsConnector::getSubscriberListener()
|
||||
DDSGeneric::SubscriberListener* DdsConnector::getSubscriberListener()
|
||||
{
|
||||
return m_subscriber ? m_subscriber->getSubscriberListener() : nullptr;
|
||||
return m_subscriber ? m_subscriber->getSubscriberListener() : nullptr;
|
||||
}
|
||||
|
||||
void DdsConnector::initPublisherSubscriber()
|
||||
{
|
||||
initSubscriber();
|
||||
initPublisher();
|
||||
initSubscriber();
|
||||
initPublisher();
|
||||
}
|
||||
|
||||
void DdsConnector::initPublisher()
|
||||
{
|
||||
if (m_publisher)
|
||||
return;
|
||||
initDomainParticipant();
|
||||
|
||||
setPublisher(new DDSConnector::Publisher(m_domainParticipant, getDefaultPartition()));
|
||||
if (m_publisher)
|
||||
return;
|
||||
initDomainParticipant();
|
||||
|
||||
setPublisher(new DDSConnector::Publisher(m_domainParticipant, getDefaultPartition()));
|
||||
}
|
||||
|
||||
void DdsConnector::initSubscriber()
|
||||
{
|
||||
if (m_subscriber)
|
||||
return;
|
||||
initDomainParticipant();
|
||||
|
||||
setSubscriber(new DDSConnector::Subscriber(m_domainParticipant, getDefaultPartition()));
|
||||
if (m_subscriber)
|
||||
return;
|
||||
initDomainParticipant();
|
||||
|
||||
setSubscriber(new DDSConnector::Subscriber(m_domainParticipant, getDefaultPartition()));
|
||||
}
|
||||
|
||||
void DdsConnector::initDomainParticipant()
|
||||
{
|
||||
if (m_domainParticipant == nullptr)
|
||||
setDomainParticipant(dds::domain::DomainParticipant(m_domainId,
|
||||
DDS::QosProfile::domainParticipantDefault(m_connectionType, m_tcpConnectionUrl)));
|
||||
if (m_domainParticipant == nullptr)
|
||||
setDomainParticipant(dds::domain::DomainParticipant(
|
||||
m_domainId, DDS::QosProfile::domainParticipantDefault(m_connectionType, m_tcpConnectionUrl)));
|
||||
}
|
||||
|
||||
|
||||
std::string DdsConnector::getDefaultPartition() const
|
||||
{
|
||||
return getPartitionString(m_defaultPartitionType, m_partitionId);
|
||||
return getPartitionString(m_defaultPartitionType, m_partitionId);
|
||||
}
|
||||
|
||||
std::string DdsConnector::getPartitionString(IDL::PartitionType pt, int partitionId)
|
||||
{
|
||||
switch (pt)
|
||||
{
|
||||
case IDL::PartitionType::Any:
|
||||
return "*";
|
||||
case IDL::PartitionType::Global:
|
||||
return IDL::exercisePartition(0);
|
||||
case IDL::PartitionType::Exercise:
|
||||
case IDL::PartitionType::AllExercises:
|
||||
return IDL::exercisePartition(partitionId);
|
||||
case IDL::PartitionType::Replay:
|
||||
return IDL::replayPartition(partitionId);
|
||||
}
|
||||
switch (pt)
|
||||
{
|
||||
case IDL::PartitionType::Any:
|
||||
return "*";
|
||||
case IDL::PartitionType::Global:
|
||||
return IDL::exercisePartition(0);
|
||||
case IDL::PartitionType::Exercise:
|
||||
case IDL::PartitionType::AllExercises:
|
||||
return IDL::exercisePartition(partitionId);
|
||||
case IDL::PartitionType::Replay:
|
||||
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);
|
||||
return std::string();
|
||||
NGL::INGLLogger& m_logger = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Common.DDSConnector");
|
||||
ERROR_LOG(m_logger) << "Invalid partition type: " << static_cast<int>(pt);
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void DdsConnector::setDomainParticipant(const dds::domain::DomainParticipant &participant)
|
||||
void DdsConnector::setDomainParticipant(const dds::domain::DomainParticipant& participant)
|
||||
{
|
||||
m_domainParticipant = participant;
|
||||
if (m_domainParticipant == nullptr)
|
||||
return;
|
||||
m_domainParticipant = participant;
|
||||
if (m_domainParticipant == nullptr)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dds::domain::qos::DomainParticipantQos dpQos(m_domainParticipant.qos());
|
||||
DDS::QosProfile::print(dpQos, m_logger);
|
||||
rti::core::policy::EntityName entityName;
|
||||
entityName.name(qAppName().toStdString() + (" - DP ") + std::to_string(m_domainId));
|
||||
dpQos << entityName;
|
||||
m_domainParticipant.qos(dpQos);
|
||||
m_domainParticipant->default_datareader_qos(DDS::QosProfile::dataReaderDefault(m_connectionType));
|
||||
m_domainParticipant.enable();
|
||||
}
|
||||
catch (const dds::core::Exception &ex)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not enable DomainParticipant: " << ex.what();
|
||||
exit(1);
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
dds::domain::qos::DomainParticipantQos dpQos(m_domainParticipant.qos());
|
||||
DDS::QosProfile::print(dpQos, m_logger);
|
||||
rti::core::policy::EntityName entityName;
|
||||
entityName.name(qAppName().toStdString() + (" - DP ") + std::to_string(m_domainId));
|
||||
dpQos << entityName;
|
||||
m_domainParticipant.qos(dpQos);
|
||||
m_domainParticipant->default_datareader_qos(DDS::QosProfile::dataReaderDefault(m_connectionType));
|
||||
m_domainParticipant.enable();
|
||||
}
|
||||
catch (const dds::core::Exception& ex)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not enable DomainParticipant: " << ex.what();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void DdsConnector::setPublisher(Publisher *publisher)
|
||||
void DdsConnector::setPublisher(Publisher* publisher)
|
||||
{
|
||||
if (m_publisher && publisher != m_publisher)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Trying to set publisher but there is already a publisher set - overwriting!";
|
||||
delete m_publisher;
|
||||
}
|
||||
m_publisher = publisher;
|
||||
if (m_publisher)
|
||||
DDS::QosProfile::print(m_publisher->getDdsPublisher().default_datawriter_qos(), m_logger);
|
||||
if (m_publisher && publisher != m_publisher)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Trying to set publisher but there is already a publisher set - overwriting!";
|
||||
delete m_publisher;
|
||||
}
|
||||
m_publisher = publisher;
|
||||
if (m_publisher)
|
||||
DDS::QosProfile::print(m_publisher->getDdsPublisher().default_datawriter_qos(), m_logger);
|
||||
}
|
||||
|
||||
void DdsConnector::enableBatchedWriter(bool bEnable)
|
||||
{
|
||||
if (m_publisher)
|
||||
m_publisher->enableBatchedWriter(bEnable);
|
||||
if (m_publisher)
|
||||
m_publisher->enableBatchedWriter(bEnable);
|
||||
}
|
||||
|
||||
|
||||
void DdsConnector::setSubscriber(Subscriber *subscriber)
|
||||
void DdsConnector::setSubscriber(Subscriber* subscriber)
|
||||
{
|
||||
if (m_subscriber && subscriber != m_subscriber)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Trying to set subscriber but there is already a subscriber set - overwriting!";
|
||||
delete m_subscriber;
|
||||
}
|
||||
m_subscriber = subscriber;
|
||||
if (m_subscriber)
|
||||
DDS::QosProfile::print(m_subscriber->getDdsSubscriber().default_datareader_qos(), m_logger);
|
||||
if (m_subscriber && subscriber != m_subscriber)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Trying to set subscriber but there is already a subscriber set - overwriting!";
|
||||
delete m_subscriber;
|
||||
}
|
||||
m_subscriber = subscriber;
|
||||
if (m_subscriber)
|
||||
DDS::QosProfile::print(m_subscriber->getDdsSubscriber().default_datareader_qos(), m_logger);
|
||||
}
|
||||
|
||||
void DdsConnector::initInternal()
|
||||
{
|
||||
if (m_tcpConnectionUrl.isValid())
|
||||
{
|
||||
m_connectionType = DDS::QosProfile::ConnectionType::Tcp;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tcpConnectionUrl.clear();
|
||||
if (m_connectionType == DDS::QosProfile::ConnectionType::Tcp)
|
||||
m_connectionType = DDS::QosProfile::ConnectionType::ShmUdp;
|
||||
}
|
||||
if (m_tcpConnectionUrl.isValid())
|
||||
{
|
||||
m_connectionType = DDS::QosProfile::ConnectionType::Tcp;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tcpConnectionUrl.clear();
|
||||
if (m_connectionType == DDS::QosProfile::ConnectionType::Tcp)
|
||||
m_connectionType = DDS::QosProfile::ConnectionType::ShmUdp;
|
||||
}
|
||||
|
||||
if (m_defaultPartitionType == IDL::PartitionType::Any ||
|
||||
m_defaultPartitionType == IDL::PartitionType::AllExercises)
|
||||
m_partitionId = -1;
|
||||
if (m_defaultPartitionType == IDL::PartitionType::Exercise && m_partitionId < 0)
|
||||
WARNING_LOG(m_logger) << "Want to subscribe to an exercise, but no exercise Id is given!";
|
||||
if (m_defaultPartitionType == IDL::PartitionType::Global)
|
||||
{
|
||||
m_partitionId = 0;
|
||||
m_exerciseId = 0;
|
||||
}
|
||||
INFO_LOG(m_logger) << "DDSConnector(" << m_domainId << ") for partition: " << m_partitionId
|
||||
<< " with partition type " << static_cast<int>(m_defaultPartitionType);
|
||||
if (m_defaultPartitionType == IDL::PartitionType::Any || m_defaultPartitionType == IDL::PartitionType::AllExercises)
|
||||
m_partitionId = -1;
|
||||
if (m_defaultPartitionType == IDL::PartitionType::Exercise && m_partitionId < 0)
|
||||
WARNING_LOG(m_logger) << "Want to subscribe to an exercise, but no exercise Id is given!";
|
||||
if (m_defaultPartitionType == IDL::PartitionType::Global)
|
||||
{
|
||||
m_partitionId = 0;
|
||||
m_exerciseId = 0;
|
||||
}
|
||||
INFO_LOG(m_logger) << "DDSConnector(" << m_domainId << ") for partition: " << m_partitionId
|
||||
<< " with partition type " << static_cast<int>(m_defaultPartitionType);
|
||||
|
||||
|
||||
dds::domain::qos::DomainParticipantFactoryQos domainParticipantFactoryQos = dds::domain::DomainParticipant::participant_factory_qos();
|
||||
|
||||
domainParticipantFactoryQos << dds::core::policy::EntityFactory::ManuallyEnable();
|
||||
dds::domain::DomainParticipant::participant_factory_qos(domainParticipantFactoryQos);
|
||||
dds::domain::qos::DomainParticipantFactoryQos domainParticipantFactoryQos =
|
||||
dds::domain::DomainParticipant::participant_factory_qos();
|
||||
|
||||
domainParticipantFactoryQos << dds::core::policy::EntityFactory::ManuallyEnable();
|
||||
dds::domain::DomainParticipant::participant_factory_qos(domainParticipantFactoryQos);
|
||||
}
|
||||
|
||||
|
||||
void DdsConnector::createWaitSetHandler()
|
||||
{
|
||||
if (!m_wsHandler)
|
||||
m_wsHandler = new DDSGeneric::WaitSetHandler;
|
||||
if (!m_wsHandler)
|
||||
m_wsHandler = new DDSGeneric::WaitSetHandler;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace DDSConnector
|
||||
Executable → Regular
+146
-157
@@ -2,33 +2,36 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
#include <Lts/Common/ProjectConfig/project_defines.h>
|
||||
#include <QUrl>
|
||||
#include <QtCore/QStringList>
|
||||
#include <dds/pub/CoherentSet.hpp>
|
||||
#include <dds/pub/Publisher.hpp>
|
||||
#include <dds/sub/Subscriber.hpp>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <Lts/Common/ProjectConfig/project_defines.h>
|
||||
#include <ddsconnector_export.h>
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
#include <QUrl>
|
||||
|
||||
class QObject;
|
||||
|
||||
namespace DDS
|
||||
{
|
||||
namespace QosProfile
|
||||
{
|
||||
enum class ConnectionType;
|
||||
}
|
||||
}
|
||||
} // namespace DDS
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DDSGeneric
|
||||
{
|
||||
class WaitSetHandler;
|
||||
class SubscriberListener;
|
||||
}
|
||||
} // namespace DDSGeneric
|
||||
|
||||
namespace DDSConnector
|
||||
{
|
||||
class Publisher;
|
||||
@@ -36,181 +39,167 @@ class Subscriber;
|
||||
|
||||
class DDSCONNECTOR_EXPORT DdsConnector
|
||||
{
|
||||
DdsConnector(int domainId,
|
||||
const dds::domain::DomainParticipant &domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId,
|
||||
int exerciseId,
|
||||
DDS::QosProfile::ConnectionType connectionType,
|
||||
const QUrl &tcpConnectionUrl);
|
||||
public:
|
||||
DdsConnector(const DdsConnector &) = delete;
|
||||
DdsConnector &operator=(const DdsConnector &) = delete;
|
||||
DdsConnector(int domainId, const dds::domain::DomainParticipant& domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType, int partitionId, int exerciseId,
|
||||
DDS::QosProfile::ConnectionType connectionType, const QUrl& tcpConnectionUrl);
|
||||
|
||||
|
||||
public:
|
||||
DdsConnector(const DdsConnector&) = delete;
|
||||
DdsConnector& operator=(const DdsConnector&) = delete;
|
||||
|
||||
DdsConnector(int domainId,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId = 0,
|
||||
int exerciseId = 0,
|
||||
const QUrl &tcpConnectionUrl = QUrl());
|
||||
|
||||
DdsConnector(int domainId, IDL::PartitionType defaultPartitionType, int partitionId = 0, int exerciseId = 0,
|
||||
const QUrl& tcpConnectionUrl = QUrl());
|
||||
|
||||
DdsConnector(const dds::domain::DomainParticipant &domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId = 0,
|
||||
int exerciseId = 0,
|
||||
const QUrl &tcpConnectionUrl = QUrl());
|
||||
DdsConnector(const dds::domain::DomainParticipant& domainParticipant, IDL::PartitionType defaultPartitionType,
|
||||
int partitionId = 0, int exerciseId = 0, const QUrl& tcpConnectionUrl = QUrl());
|
||||
|
||||
DdsConnector(const dds::domain::DomainParticipant &domainParticipant,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
DDS::QosProfile::ConnectionType connectionType,
|
||||
int partitionId = 0,
|
||||
int exerciseId = 0);
|
||||
DdsConnector(const dds::domain::DomainParticipant& domainParticipant, IDL::PartitionType defaultPartitionType,
|
||||
DDS::QosProfile::ConnectionType connectionType, int partitionId = 0, int exerciseId = 0);
|
||||
|
||||
DdsConnector(int domainId,
|
||||
IDL::PartitionType defaultPartitionType,
|
||||
int partitionId,
|
||||
int exerciseId,
|
||||
DDS::QosProfile::ConnectionType connectionType);
|
||||
DdsConnector(int domainId, IDL::PartitionType defaultPartitionType, int partitionId, int exerciseId,
|
||||
DDS::QosProfile::ConnectionType connectionType);
|
||||
|
||||
virtual ~DdsConnector();
|
||||
virtual ~DdsConnector();
|
||||
|
||||
|
||||
virtual bool init(const QStringList& qosFileList = QStringList());
|
||||
|
||||
virtual bool init(const QStringList &qosFileList = QStringList());
|
||||
dds::domain::DomainParticipant getDomainParticipant() const
|
||||
{
|
||||
return m_domainParticipant;
|
||||
}
|
||||
|
||||
dds::domain::DomainParticipant getDomainParticipant() const { return m_domainParticipant; }
|
||||
void setDomainParticipant(const dds::domain::DomainParticipant &participant);
|
||||
void setDomainParticipant(const dds::domain::DomainParticipant& participant);
|
||||
|
||||
Publisher *getPublisher() { return m_publisher; }
|
||||
dds::pub::Publisher getDdsPublisher() const;
|
||||
void setPublisher(Publisher *publisher);
|
||||
void enableBatchedWriter(bool bEnable);
|
||||
Publisher* getPublisher()
|
||||
{
|
||||
return m_publisher;
|
||||
}
|
||||
|
||||
Subscriber *getSubscriber() { return m_subscriber; }
|
||||
dds::sub::Subscriber getDdsSubscriber() const;
|
||||
void setSubscriber(Subscriber *subscriber);
|
||||
DDSGeneric::SubscriberListener *getSubscriberListener();
|
||||
dds::pub::Publisher getDdsPublisher() const;
|
||||
void setPublisher(Publisher* publisher);
|
||||
void enableBatchedWriter(bool bEnable);
|
||||
|
||||
const DDSGeneric::WaitSetHandler *getWaitSetHandler() const { return m_wsHandler; }
|
||||
Subscriber* getSubscriber()
|
||||
{
|
||||
return m_subscriber;
|
||||
}
|
||||
|
||||
int getDomainId() const { return m_domainId; }
|
||||
IDL::PartitionType getPartitionType() const { return m_defaultPartitionType; }
|
||||
int getPartitionId() const { return m_partitionId; }
|
||||
int getExerciseId() const { return m_exerciseId; }
|
||||
std::string getDefaultPartition() const;
|
||||
QUrl getTcpConnectionUrl() const;
|
||||
static std::string getPartitionString(IDL::PartitionType pt, int partitionId = -1);
|
||||
dds::sub::Subscriber getDdsSubscriber() const;
|
||||
void setSubscriber(Subscriber* subscriber);
|
||||
DDSGeneric::SubscriberListener* getSubscriberListener();
|
||||
|
||||
|
||||
const DDSGeneric::WaitSetHandler* getWaitSetHandler() const
|
||||
{
|
||||
return m_wsHandler;
|
||||
}
|
||||
|
||||
void initPublisherSubscriber();
|
||||
void initPublisher();
|
||||
void initSubscriber();
|
||||
void initDomainParticipant();
|
||||
int getDomainId() const
|
||||
{
|
||||
return m_domainId;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *createDTS(const std::string &topicName = DDS::Helper::getShortTopicName(DDS::topic_type_name<typename T::TopicType>::value()))
|
||||
{
|
||||
if (getDomainParticipant() == nullptr ||
|
||||
getDdsPublisher() == nullptr)
|
||||
return nullptr;
|
||||
T *dts = new T(getDomainParticipant(),
|
||||
getDdsPublisher(),
|
||||
topicName);
|
||||
return dts;
|
||||
}
|
||||
IDL::PartitionType getPartitionType() const
|
||||
{
|
||||
return m_defaultPartitionType;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *createDTC(const std::string &topicName = DDS::Helper::getShortTopicName(DDS::topic_type_name<typename T::TopicType>::value()))
|
||||
{
|
||||
if (getDomainParticipant() == nullptr ||
|
||||
getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
T *dtc = new T(getDomainParticipant(),
|
||||
getDdsSubscriber(),
|
||||
getSubscriberListener(),
|
||||
topicName);
|
||||
return dtc;
|
||||
}
|
||||
int getPartitionId() const
|
||||
{
|
||||
return m_partitionId;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *createDTC(const dds::topic::Filter &filter,
|
||||
const std::string &topicName = DDS::Helper::getShortTopicName(DDS::topic_type_name<typename T::TopicType>::value()))
|
||||
{
|
||||
if (getDomainParticipant() == nullptr ||
|
||||
getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
T *dtc = new T(getDomainParticipant(),
|
||||
getDdsSubscriber(),
|
||||
getSubscriberListener(),
|
||||
filter,
|
||||
topicName);
|
||||
return dtc;
|
||||
}
|
||||
int getExerciseId() const
|
||||
{
|
||||
return m_exerciseId;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *createFTS()
|
||||
{
|
||||
if (getDomainParticipant() == nullptr ||
|
||||
getDdsPublisher() == nullptr ||
|
||||
getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
createWaitSetHandler();
|
||||
T *fts = new T(getDomainParticipant(),
|
||||
getDdsPublisher(),
|
||||
getDdsSubscriber(),
|
||||
m_wsHandler);
|
||||
return fts;
|
||||
}
|
||||
std::string getDefaultPartition() const;
|
||||
QUrl getTcpConnectionUrl() const;
|
||||
static std::string getPartitionString(IDL::PartitionType pt, int partitionId = -1);
|
||||
|
||||
template<typename T>
|
||||
T *createFTC(QObject *objToInform)
|
||||
{
|
||||
if (getDomainParticipant() == nullptr ||
|
||||
getDdsPublisher() == nullptr ||
|
||||
getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
T *ftc = new T(getDomainParticipant(),
|
||||
getDdsPublisher(),
|
||||
getDdsSubscriber(),
|
||||
objToInform,
|
||||
IDL::toStdString(m_defaultPartitionType),
|
||||
m_partitionId);
|
||||
return ftc;
|
||||
}
|
||||
void initPublisherSubscriber();
|
||||
void initPublisher();
|
||||
void initSubscriber();
|
||||
void initDomainParticipant();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void initInternal();
|
||||
void createWaitSetHandler();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_domainId;
|
||||
IDL::PartitionType m_defaultPartitionType;
|
||||
int m_partitionId;
|
||||
int m_exerciseId;
|
||||
template <typename T>
|
||||
T* createDTS(const std::string& topicName =
|
||||
DDS::Helper::getShortTopicName(DDS::topic_type_name<typename T::TopicType>::value()))
|
||||
{
|
||||
if (getDomainParticipant() == nullptr || getDdsPublisher() == nullptr)
|
||||
return nullptr;
|
||||
T* dts = new T(getDomainParticipant(), getDdsPublisher(), topicName);
|
||||
return dts;
|
||||
}
|
||||
|
||||
QUrl m_tcpConnectionUrl;
|
||||
DDS::QosProfile::ConnectionType m_connectionType;
|
||||
dds::domain::DomainParticipant m_domainParticipant;
|
||||
DDSConnector::Publisher *m_publisher;
|
||||
DDSConnector::Subscriber *m_subscriber;
|
||||
DDSGeneric::WaitSetHandler *m_wsHandler;
|
||||
template <typename T>
|
||||
T* createDTC(const std::string& topicName =
|
||||
DDS::Helper::getShortTopicName(DDS::topic_type_name<typename T::TopicType>::value()))
|
||||
{
|
||||
if (getDomainParticipant() == nullptr || getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
T* dtc = new T(getDomainParticipant(), getDdsSubscriber(), getSubscriberListener(), topicName);
|
||||
return dtc;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* createDTC(const dds::topic::Filter& filter, const std::string& topicName = DDS::Helper::getShortTopicName(
|
||||
DDS::topic_type_name<typename T::TopicType>::value()))
|
||||
{
|
||||
if (getDomainParticipant() == nullptr || getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
T* dtc = new T(getDomainParticipant(), getDdsSubscriber(), getSubscriberListener(), filter, topicName);
|
||||
return dtc;
|
||||
}
|
||||
|
||||
template <typename T> T* createFTS()
|
||||
{
|
||||
if (getDomainParticipant() == nullptr || getDdsPublisher() == nullptr || getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
createWaitSetHandler();
|
||||
T* fts = new T(getDomainParticipant(), getDdsPublisher(), getDdsSubscriber(), m_wsHandler);
|
||||
return fts;
|
||||
}
|
||||
|
||||
template <typename T> T* createFTC(QObject* objToInform)
|
||||
{
|
||||
if (getDomainParticipant() == nullptr || getDdsPublisher() == nullptr || getDdsSubscriber() == nullptr)
|
||||
return nullptr;
|
||||
T* ftc = new T(getDomainParticipant(), getDdsPublisher(), getDdsSubscriber(), objToInform,
|
||||
IDL::toStdString(m_defaultPartitionType), m_partitionId);
|
||||
return ftc;
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void initInternal();
|
||||
void createWaitSetHandler();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
int m_domainId;
|
||||
IDL::PartitionType m_defaultPartitionType;
|
||||
int m_partitionId;
|
||||
int m_exerciseId;
|
||||
|
||||
QUrl m_tcpConnectionUrl;
|
||||
DDS::QosProfile::ConnectionType m_connectionType;
|
||||
dds::domain::DomainParticipant m_domainParticipant;
|
||||
DDSConnector::Publisher* m_publisher;
|
||||
DDSConnector::Subscriber* m_subscriber;
|
||||
DDSGeneric::WaitSetHandler* m_wsHandler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CoherentSet
|
||||
{
|
||||
public:
|
||||
explicit CoherentSet(const std::shared_ptr<DdsConnector> &connector)
|
||||
: m_coherentSet(connector->getDdsPublisher())
|
||||
{}
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
dds::pub::CoherentSet m_coherentSet;
|
||||
public:
|
||||
explicit CoherentSet(const std::shared_ptr<DdsConnector>& connector) : m_coherentSet(connector->getDdsPublisher())
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
dds::pub::CoherentSet m_coherentSet;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace DDSConnector
|
||||
Executable → Regular
+23
-18
@@ -2,11 +2,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <dds/domain/DomainParticipant.hpp>
|
||||
#include <ddsconnector_export.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <dds/domain/DomainParticipant.hpp>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
@@ -17,23 +16,29 @@ namespace DDSConnector
|
||||
{
|
||||
class DDSCONNECTOR_EXPORT PubSubBase
|
||||
{
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
PubSubBase(const dds::domain::DomainParticipant &domainParticipant,
|
||||
const std::string &partition,
|
||||
const char *loggerName);
|
||||
public:
|
||||
virtual ~PubSubBase() = default;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
PubSubBase(const dds::domain::DomainParticipant& domainParticipant, const std::string& partition,
|
||||
const char* loggerName);
|
||||
|
||||
void setDomainParticipant(const dds::domain::DomainParticipant &domainParticipant) { m_domainParticipant = domainParticipant; }
|
||||
const dds::domain::DomainParticipant &getDomainParticipant() const { return m_domainParticipant; }
|
||||
public:
|
||||
virtual ~PubSubBase() = default;
|
||||
|
||||
protected:
|
||||
template<typename P>
|
||||
void updatePartitionQoS(P &pubSub);
|
||||
void setDomainParticipant(const dds::domain::DomainParticipant& domainParticipant)
|
||||
{
|
||||
m_domainParticipant = domainParticipant;
|
||||
}
|
||||
|
||||
protected:
|
||||
dds::domain::DomainParticipant m_domainParticipant;
|
||||
std::vector<std::string> m_partitions;
|
||||
const dds::domain::DomainParticipant& getDomainParticipant() const
|
||||
{
|
||||
return m_domainParticipant;
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename P> void updatePartitionQoS(P& pubSub);
|
||||
|
||||
protected:
|
||||
dds::domain::DomainParticipant m_domainParticipant;
|
||||
std::vector<std::string> m_partitions;
|
||||
};
|
||||
}
|
||||
} // namespace DDSConnector
|
||||
Reference in new issue
Block a user