123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef _TOPICSAMPLE_TOPICS_SUBSCRIBER_H_
- #define _TOPICSAMPLE_TOPICS_SUBSCRIBER_H_
- #include <fastrtps/fastrtps_fwd.h>
- #include <fastrtps/subscriber/SubscriberListener.h>
- #include <fastrtps/subscriber/SampleInfo.h>
- #include "TopicsPubSubTypes.h"
- #include <QDateTime>
- typedef std::function<void(const char * ,const unsigned int , const unsigned int , QDateTime * ,const char *)> ModuleFun;
- class TopicsSubscriber
- {
- public:
- TopicsSubscriber();
- virtual ~TopicsSubscriber();
- bool init(const char * strtopic,const char * strpubip = 0,const unsigned short nPort = 5100,int ntype = 0);
- void run();
- void setReceivedTopicFunction(ModuleFun xFun);
- private:
- eprosima::fastrtps::Participant *mp_participant;
- eprosima::fastrtps::Subscriber *mp_subscriber;
- char mstrtopic[256];
- class SubListener : public eprosima::fastrtps::SubscriberListener
- {
- public:
- SubListener() : n_matched(0),n_msg(0){};
- ~SubListener(){};
- void onSubscriptionMatched(eprosima::fastrtps::Subscriber* sub,eprosima::fastrtps::rtps::MatchingInfo& info);
- void onNewDataMessage(eprosima::fastrtps::Subscriber* sub);
- eprosima::fastrtps::SampleInfo_t m_info;
- int n_matched;
- int n_msg;
- void setReceivedTopicFunction(ModuleFun xFun);
- private:
- bool mbSetFun = false;
- ModuleFun mFun;
- } m_listener;
- TopicSample::MessagePubSubType myType;
- };
- #endif
|