131 lines
6.2 KiB
C++
131 lines
6.2 KiB
C++
|
|
|
|
#pragma once
|
|
|
|
// Include Qt headers FIRST to prevent namespace pollution when RTI DDS headers include Qt
|
|
#include <QtCore/QString>
|
|
#include <QtCore/QUrl>
|
|
#include <QtCore/QFlag>
|
|
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
|
|
#include <dds/sub/LoanedSamples.hpp>
|
|
|
|
namespace NGLLogger
|
|
{
|
|
class INGLLogger;
|
|
}
|
|
|
|
namespace DTC
|
|
{
|
|
class SubscriberListener;
|
|
|
|
template <typename DRO_OBJECT, typename SC> class GenericDtcSC
|
|
{
|
|
public:
|
|
using DataReaderObject = DRO_OBJECT;
|
|
using SubscriberCallback = SC;
|
|
using TopicType = typename DRO_OBJECT::TopicType;
|
|
|
|
GenericDtcSC() = default;
|
|
virtual ~GenericDtcSC() = default;
|
|
|
|
virtual bool setSubscriberCallback(const SubscriberCallback& subscriberCallback) = 0;
|
|
virtual dds::sub::LoanedSamples<TopicType> readAlive() const = 0;
|
|
virtual bool readAlive(TopicType& data) = 0;
|
|
virtual dds::sub::LoanedSamples<TopicType> takeAlive() const = 0;
|
|
virtual bool takeAlive(TopicType& data) = 0;
|
|
virtual dds::sub::LoanedSamples<TopicType> takeDisposed() const = 0;
|
|
virtual bool takeDisposed(TopicType& data) = 0;
|
|
virtual bool hasSamples() const = 0;
|
|
virtual DataReaderObject* dataReader() const = 0;
|
|
virtual bool waitForHistoricalData(int timeoutMSec) = 0;
|
|
};
|
|
|
|
template <typename DRO_OBJECT>
|
|
class GenericDtc
|
|
: public GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, DataModification)>>
|
|
{
|
|
public:
|
|
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, DataModification)>>;
|
|
using TopicType = typename BaseClass::TopicType;
|
|
|
|
// Explicitly expose base class methods for accessibility through smart pointers
|
|
using BaseClass::readAlive;
|
|
using BaseClass::takeAlive;
|
|
using BaseClass::takeDisposed;
|
|
using BaseClass::SubscriberCallback;
|
|
bool setSubscriberCallback(const typename BaseClass::SubscriberCallback& callback) override { return BaseClass::setSubscriberCallback(callback); }
|
|
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
|
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
|
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
|
bool hasSamples() const { return BaseClass::hasSamples(); }
|
|
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
|
|
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
};
|
|
|
|
template <typename DRO_OBJECT>
|
|
class GenericDtcSampleInfo
|
|
: public GenericDtcSC<DRO_OBJECT,
|
|
std::function<void(const typename DRO_OBJECT::TopicType&, const dds::sub::SampleInfo&)>>
|
|
{
|
|
public:
|
|
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const dds::sub::SampleInfo&)>>;
|
|
using TopicType = typename BaseClass::TopicType;
|
|
|
|
// Explicitly expose base class methods for accessibility through smart pointers
|
|
using BaseClass::readAlive;
|
|
using BaseClass::takeAlive;
|
|
using BaseClass::takeDisposed;
|
|
void setSubscriberCallback(std::function<void(const TopicType&, const dds::sub::SampleInfo&)> callback) { BaseClass::setSubscriberCallback(callback); }
|
|
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
|
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
|
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
|
bool hasSamples() const { return BaseClass::hasSamples(); }
|
|
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
|
|
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
};
|
|
|
|
template <typename DRO_OBJECT>
|
|
class Ddtc
|
|
: public GenericDtcSC<
|
|
DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&, DataModification)>>
|
|
{
|
|
public:
|
|
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&, DataModification)>>;
|
|
using TopicType = typename BaseClass::TopicType;
|
|
|
|
// Explicitly expose base class methods for accessibility through smart pointers
|
|
using BaseClass::readAlive;
|
|
using BaseClass::takeAlive;
|
|
using BaseClass::takeDisposed;
|
|
void setSubscriberCallback(std::function<void(const TopicType&, const std::string&, DataModification)> callback) { BaseClass::setSubscriberCallback(callback); }
|
|
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
|
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
|
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
|
bool hasSamples() const { return BaseClass::hasSamples(); }
|
|
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
|
|
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
};
|
|
|
|
template <typename DRO_OBJECT>
|
|
class DdtcSampleInfo
|
|
: public GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&,
|
|
const dds::sub::SampleInfo&)>>
|
|
{
|
|
public:
|
|
using BaseClass = GenericDtcSC<DRO_OBJECT, std::function<void(const typename DRO_OBJECT::TopicType&, const std::string&, const dds::sub::SampleInfo&)>>;
|
|
using TopicType = typename BaseClass::TopicType;
|
|
|
|
// Explicitly expose base class methods for accessibility through smart pointers
|
|
using BaseClass::readAlive;
|
|
using BaseClass::takeAlive;
|
|
using BaseClass::takeDisposed;
|
|
void setSubscriberCallback(std::function<void(const TopicType&, const std::string&, const dds::sub::SampleInfo&)> callback) { BaseClass::setSubscriberCallback(callback); }
|
|
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
|
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
|
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
|
bool hasSamples() const { return BaseClass::hasSamples(); }
|
|
std::shared_ptr<DRO_OBJECT> dataReader() { return BaseClass::dataReader(); }
|
|
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
};
|
|
} // namespace DTC
|