173 lines
3.9 KiB
C++
173 lines
3.9 KiB
C++
#pragma once
|
|
|
|
/**
|
|
* @file generic_data_reader.h
|
|
* @brief Generic Data Reader wrapper for DDS
|
|
*
|
|
* Provides GenericDataReader template class that wraps RTI DataReader
|
|
* when BUILD_RTI=ON, or provides stub implementation when BUILD_RTI=OFF.
|
|
*/
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#ifdef BUILD_RTI
|
|
// RTI DDS is available - include full implementation from Lts
|
|
// MUST be included BEFORE namespace DDSGeneric to avoid namespace pollution
|
|
#include <Lts/DDS/Generic/dynamic_data_reader.h>
|
|
#include <Lts/DDS/Generic/generic_data_reader.h>
|
|
|
|
namespace DDSGeneric
|
|
{
|
|
// Full implementation is in Lts/DDS/Generic/generic_data_reader.h
|
|
// This file just provides the include path redirection
|
|
} // namespace DDSGeneric
|
|
|
|
#else
|
|
// BUILD_RTI=OFF: Provide minimal stub definitions for RTI types
|
|
|
|
namespace dds {
|
|
namespace sub {
|
|
namespace detail {
|
|
|
|
// Dummy delegate class to serve as default template parameter
|
|
template<typename Q>
|
|
class DataReaderImpl {
|
|
// Empty stub implementation
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
// Forward declaration stub for DataReader
|
|
// Must match RTI 7.7 signature for compatibility
|
|
template<typename T, template <typename Q> class DELEGATE = detail::DataReaderImpl>
|
|
class DataReader {
|
|
public:
|
|
// Minimal stub interface - add methods as needed by the codebase
|
|
T read() { return T{}; }
|
|
void take() {}
|
|
};
|
|
|
|
} // namespace sub
|
|
} // namespace dds
|
|
|
|
namespace DDSGeneric
|
|
{
|
|
|
|
// GenericDataReader stub template (only when BUILD_RTI=OFF)
|
|
template<typename T>
|
|
class GenericDataReader {
|
|
public:
|
|
using TopicType = T;
|
|
using TopicTypeRead = T;
|
|
using DataReader = void*;
|
|
using DataTopic = void*;
|
|
using DataReaderQos = void*;
|
|
using SubscriberCallback = std::function<void(const TopicTypeRead&, int)>;
|
|
using SubscriberCallbackWithSampleInfo = std::function<void(const TopicTypeRead&, const void*)>;
|
|
|
|
GenericDataReader()
|
|
: m_dataReader(nullptr), m_ddsTopic(nullptr), m_bHaveSubscriberCallback(false)
|
|
{
|
|
}
|
|
|
|
virtual ~GenericDataReader()
|
|
{
|
|
m_ddsTopic = nullptr;
|
|
m_dataReader = nullptr;
|
|
}
|
|
|
|
DataReader getDataReader() const
|
|
{
|
|
return m_dataReader;
|
|
}
|
|
|
|
bool create(const void* domainParticipant, const void* ddsSubscriber,
|
|
const std::string& topicName = std::string(),
|
|
bool bCreateDataReader = true)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool hasSamples() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void* readAlive(bool& bSeenNewSamples)
|
|
{
|
|
bSeenNewSamples = false;
|
|
return nullptr;
|
|
}
|
|
|
|
void* takeAlive(bool& bSeenNewSamples)
|
|
{
|
|
bSeenNewSamples = false;
|
|
return nullptr;
|
|
}
|
|
|
|
void* takeDisposed()
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
template <typename C> bool read(C callbackFunc)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void setHaveSubscriberCallback(bool bHave)
|
|
{
|
|
m_bHaveSubscriberCallback = bHave;
|
|
}
|
|
|
|
std::string topicName() const
|
|
{
|
|
return std::string();
|
|
}
|
|
|
|
DataReader dataReader() const
|
|
{
|
|
return m_dataReader;
|
|
}
|
|
|
|
virtual void recreateReader()
|
|
{
|
|
}
|
|
|
|
protected:
|
|
DataReader m_dataReader;
|
|
DataReaderQos m_dataReaderQos;
|
|
DataTopic m_ddsTopic;
|
|
bool m_bHaveSubscriberCallback;
|
|
};
|
|
|
|
template<typename T>
|
|
class GenericDataReaderContentFilter {
|
|
public:
|
|
using DataType = T;
|
|
// Minimal stub - extend as needed
|
|
};
|
|
|
|
// DynamicDataReader stub for BUILD_RTI=OFF
|
|
class DynamicDataReader {
|
|
public:
|
|
using TopicType = void*;
|
|
using DataReader = void*;
|
|
using DataTopic = void*;
|
|
|
|
DynamicDataReader() {}
|
|
~DynamicDataReader() {}
|
|
|
|
bool create(const void* domainParticipant, const void* ddsSubscriber,
|
|
const std::string& specialTopicName, const void* structType)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool hasSamples() const { return false; }
|
|
};
|
|
|
|
} // namespace DDSGeneric
|
|
|
|
#endif // BUILD_RTI
|