SubscriberListener.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 SubscriberListener.h
  16. */
  17. #ifndef SUBLISTENER_H_
  18. #define SUBLISTENER_H_
  19. #include <fastrtps/fastrtps_dll.h>
  20. #include <fastrtps/qos/DeadlineMissedStatus.h>
  21. #include <fastrtps/qos/LivelinessChangedStatus.h>
  22. namespace eprosima {
  23. namespace fastrtps {
  24. namespace rtps {
  25. class MatchingInfo;
  26. } /* namespace rtps */
  27. class Subscriber;
  28. /**
  29. * Class SubscriberListener, it should be used by the end user to implement specific callbacks to certain actions.
  30. * @ingroup FASTRTPS_MODULE
  31. * @snippet fastrtps_example.cpp ex_SubscriberListener
  32. */
  33. class RTPS_DllAPI SubscriberListener
  34. {
  35. public:
  36. SubscriberListener(){}
  37. virtual ~SubscriberListener(){}
  38. /**
  39. * Virtual function to be implemented by the user containing the actions to be performed when a new Data Message is received.
  40. * @param sub Subscriber
  41. */
  42. virtual void onNewDataMessage(Subscriber* sub)
  43. {
  44. (void)sub;
  45. }
  46. /**
  47. * Virtual method to be called when the subscriber is matched with a new Writer (or unmatched); i.e., when a writer publishing in the same topic is discovered.
  48. * @param sub Subscriber
  49. * @param info Matching information
  50. */
  51. virtual void onSubscriptionMatched(
  52. Subscriber* sub,
  53. rtps::MatchingInfo& info)
  54. {
  55. (void)sub;
  56. (void)info;
  57. }
  58. /**
  59. * Virtual method to be called when a topic misses the deadline period
  60. * @param sub Subscriber
  61. * @param status The requested deadline missed status
  62. */
  63. virtual void on_requested_deadline_missed(
  64. Subscriber* sub,
  65. const RequestedDeadlineMissedStatus& status)
  66. {
  67. (void)sub;
  68. (void)status;
  69. }
  70. /**
  71. * @brief Method called when the liveliness status associated to a subscriber changes
  72. * @param sub The subscriber
  73. * @param status The liveliness changed status
  74. */
  75. virtual void on_liveliness_changed(
  76. Subscriber* sub,
  77. const LivelinessChangedStatus& status)
  78. {
  79. (void)sub;
  80. (void)status;
  81. }
  82. };
  83. } /* namespace fastrtps */
  84. } /* namespace eprosima */
  85. #endif /* LISTENER_H_ */