Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* Publisher for DataSampleGeneration
|
||||
* Uses DTSs to publish data
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <DDS/DTS/generic_dts_impl.h>
|
||||
#include <DDS/Generic/generic_data_writer.h>
|
||||
|
||||
#include "pub_sub_base.h"
|
||||
|
||||
namespace DDSConnector
|
||||
{
|
||||
class DDSCONNECTOR_EXPORT Publisher : public PubSubBase
|
||||
{
|
||||
public:
|
||||
Publisher(const dds::domain::DomainParticipant &domainParticipant, const std::string &partition);
|
||||
~Publisher();
|
||||
|
||||
void enableBatchedWriter(bool bEnable);
|
||||
dds::pub::Publisher getDdsPublisher() const { return m_ddsPublisher; }
|
||||
|
||||
// Write data for each topicType (i.e. T = Lts_ExerciseParticipant)
|
||||
template <typename T>
|
||||
bool write(const T &data)
|
||||
{
|
||||
using myDWO = DDSGeneric::GenericDataWriter<T>;
|
||||
using myDTS = DTS::GenericDtsImpl< myDWO >;
|
||||
|
||||
std::string dwoType = DDS::topic_type_name<T>::value();
|
||||
DEBUG_LOG(m_logger) << "dwoType = " << dwoType;
|
||||
|
||||
myDTS *dts = static_cast<myDTS *>(m_dtsMap.value(dwoType));
|
||||
if (dts == nullptr)
|
||||
{
|
||||
dts = new myDTS(m_domainParticipant, m_ddsPublisher);
|
||||
m_dtsMap.insert(dwoType, dts);
|
||||
}
|
||||
|
||||
return dts->write(data);
|
||||
}
|
||||
|
||||
// Use default typeName, if topicName is not specified
|
||||
bool write(const dds::core::xtypes::DynamicData &data)
|
||||
{
|
||||
return write(data, data.type().name());
|
||||
}
|
||||
|
||||
bool write(const dds::core::xtypes::DynamicData &data, const std::string &topicName);
|
||||
|
||||
|
||||
protected:
|
||||
void initDDS();
|
||||
void deleteDDS();
|
||||
|
||||
protected:
|
||||
dds::pub::Publisher m_ddsPublisher;
|
||||
|
||||
// Map for static DTcs
|
||||
QMap<std::string, DTS::Base*> m_dtsMap;
|
||||
|
||||
// Map for dynamic types
|
||||
// QMap<topicName,DataWriter (defined)>
|
||||
QMap<std::string, dds::pub::AnyDataWriter*> m_dynamicTypeMap;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user