Publisher.h 863 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef PUBLISHER_H_
  2. #define PUBLISHER_H_
  3. #include "idl/TopicsTypeSupportImpl.h"
  4. #include <dds/DCPS/Service_Participant.h>
  5. #include <string>
  6. class Publisher {
  7. public:
  8. Publisher(int argc, char* argv[],const char * strtopic);
  9. ~Publisher();
  10. void sendMessage(const std::string& message, const char * strdata, int nlen );
  11. private:
  12. void createParticipant(int argc, char* argv[]);
  13. void createPublisher();
  14. void registerTopic();
  15. void createDataWriter();
  16. private:
  17. DDS::DomainParticipantFactory_var m_participantFactory;
  18. DDS::DomainParticipant_var m_participant;
  19. DDS::Publisher_var m_publisher;
  20. TopicSample::MessageTypeSupport_var m_topicSupport;
  21. DDS::Topic_var m_messageTopic;
  22. TopicSample::MessageDataWriter_var m_dataWriter;
  23. DDS::InstanceHandle_t m_topicHandler;
  24. int m_counter = 1;
  25. char mstrtopic[255];
  26. };
  27. #endif // !PUBLISHER_H_