TopicsPublisher.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /*!
  15. * @file TopicsPublisher.h
  16. * This header file contains the declaration of the publisher functions.
  17. *
  18. * This file was generated by the tool fastcdrgen.
  19. */
  20. #ifndef _TOPICSAMPLE_TOPICS_PUBLISHER_H_
  21. #define _TOPICSAMPLE_TOPICS_PUBLISHER_H_
  22. #include <fastrtps/fastrtps_fwd.h>
  23. #include <fastrtps/publisher/PublisherListener.h>
  24. #include "TopicsPubSubTypes.h"
  25. class TopicsPublisher
  26. {
  27. public:
  28. TopicsPublisher();
  29. virtual ~TopicsPublisher();
  30. bool init(const char * strtopic,const unsigned short nListenPort);
  31. void run();
  32. void senddata(const char *str, int nsize);
  33. private:
  34. eprosima::fastrtps::Participant *mp_participant;
  35. eprosima::fastrtps::Publisher *mp_publisher;
  36. char mstrtopic[256];
  37. unsigned short mnListenPort;
  38. class PubListener : public eprosima::fastrtps::PublisherListener
  39. {
  40. public:
  41. PubListener() : n_matched(0){};
  42. ~PubListener(){};
  43. void onPublicationMatched(eprosima::fastrtps::Publisher* pub,eprosima::fastrtps::rtps::MatchingInfo& info);
  44. int n_matched;
  45. } m_listener;
  46. TopicSample::MessagePubSubType myType;
  47. };
  48. #endif // _TOPICSAMPLE_TOPICS_PUBLISHER_H_