#ifndef FAST_DDS_GENERATED__IPublisher_HPP #define FAST_DDS_GENERATED__IPublisher_HPP #include <string> #include "testPubSubTypes.hpp" // 定义 PubSubType 模板类 template <typename T> class PubSubType { // 可以在这里添加一些通用的成员函数或数据成员 }; // 定义基础模板结构体,用于生成新的类型名称 template <typename T, typename = void> struct MakePubSubType; // 默认实现,可以抛出编译错误或提供默认类型 template <typename T> struct MakePubSubType<T, void> { using Type = void; static_assert(std::is_void<Type>::value, "No appropriate MessageSubType found for MessageT"); }; // 特化 MakePubSubType 以关联 HelloSecurity 和 HelloSecurityPubSubType template <> struct MakePubSubType<HelloSecurity> { using Type = HelloSecurityPubSubType; }; template <> struct MakePubSubType<OneMessage> { using Type = OneMessagePubSubType; }; // 抽象接口类,使用模板参数 template<typename T> class IPublisher { public: virtual ~IPublisher() {} virtual bool publish(const T& msg) = 0; std::string topicName_; std::string getTopic() const { return topicName_; } virtual void stop() = 0; }; #endif