#ifndef __UT_ROBOT_SDK_CHANNEL_FACTORY_HPP__ #define __UT_ROBOT_SDK_CHANNEL_FACTORY_HPP__ #include namespace unitree { namespace robot { template using Channel = unitree::common::DdsTopicChannel; template using ChannelPtr = unitree::common::DdsTopicChannelPtr; class ChannelFactory { public: static ChannelFactory* Instance() { static ChannelFactory inst; return &inst; } void Init(int32_t domainId, const std::string& networkInterface = ""); void Init(const std::string& configFileName = ""); void Init(const common::JsonMap& jsonMap); void Release(); template ChannelPtr CreateSendChannel(const std::string& name) { ChannelPtr channelPtr = mDdsFactoryPtr->CreateTopicChannel(name); mDdsFactoryPtr->SetWriter(channelPtr); return channelPtr; } template ChannelPtr CreateRecvChannel(const std::string& name, std::function callback, int32_t queuelen = 0) { ChannelPtr channelPtr = mDdsFactoryPtr->CreateTopicChannel(name); mDdsFactoryPtr->SetReader(channelPtr, callback, queuelen); return channelPtr; } public: ~ChannelFactory(); private: ChannelFactory(); private: bool mInited; common::DdsFactoryModelPtr mDdsFactoryPtr; common::Mutex mMutex; }; } } #endif//__UT_ROBOT_SDK_CHANNEL_FACTORY_HPP__