Fast RTPS  Version 2.1.0
Fast RTPS
Subscriber.h
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 
20 #ifndef SUBSCRIBER_H_
21 #define SUBSCRIBER_H_
22 
23 #include <fastdds/rtps/common/Guid.h>
24 #include <fastdds/rtps/common/Time_t.h>
25 #include <fastrtps/attributes/SubscriberAttributes.h>
26 #include <fastrtps/qos/DeadlineMissedStatus.h>
27 #include <fastrtps/qos/LivelinessChangedStatus.h>
28 
29 namespace eprosima {
30 namespace fastrtps {
31 
32 class SubscriberImpl;
33 class SampleInfo_t;
34 
42 class RTPS_DllAPI Subscriber
43 {
44  friend class SubscriberImpl;
45 
46  virtual ~Subscriber()
47  {
48  }
49 
50 public:
51 
57  SubscriberImpl* pimpl)
58  : mp_impl(pimpl)
59  {
60  }
61 
66  const rtps::GUID_t& getGuid();
67 
71  inline void waitForUnreadMessage()
72  {
73  const Duration_t one_day{ 24 * 3600, 0 };
74  while (!wait_for_unread_samples(one_day))
75  {
76  }
77  }
78 
86  const Duration_t& timeout);
87 
97  void* sample,
98  SampleInfo_t* info);
99 
109  void* sample,
110  SampleInfo_t* info);
111 
118  SampleInfo_t* info);
119 
126  const SubscriberAttributes& att);
127 
133 
140  bool isInCleanState() const;
141 
146  inline uint64_t getUnreadCount() const
147  {
148  return get_unread_count();
149  }
150 
155  uint64_t get_unread_count() const;
156 
163 
169  LivelinessChangedStatus& status);
170 
171 private:
172 
173  SubscriberImpl* mp_impl;
174 };
175 
176 
177 
178 } /* namespace pubsub */
179 } /* namespace eprosima */
180 
181 #endif /* SUBSCRIBER_H_ */
eprosima::fastrtps::Subscriber::get_liveliness_changed_status
void get_liveliness_changed_status(LivelinessChangedStatus &status)
Returns the liveliness changed status.
eprosima::fastrtps::Subscriber::updateAttributes
bool updateAttributes(const SubscriberAttributes &att)
Update the Attributes of the subscriber;.
eprosima::fastrtps::LivelinessChangedStatus
fastdds::dds::LivelinessChangedStatus LivelinessChangedStatus
Definition: LivelinessChangedStatus.h:29
eprosima::fastrtps::SampleInfo_t
Class SampleInfo_t with information that is provided along a sample when reading data from a Subscrib...
Definition: SampleInfo.h:38
eprosima::fastrtps::Subscriber::getAttributes
const SubscriberAttributes & getAttributes() const
Get the Attributes of the Subscriber.
eprosima::fastrtps::Subscriber::get_unread_count
uint64_t get_unread_count() const
Get the unread count.
eprosima::fastrtps::Subscriber::isInCleanState
bool isInCleanState() const
Returns there is a clean state with all Publishers.
eprosima::fastrtps::Subscriber::get_first_untaken_info
bool get_first_untaken_info(SampleInfo_t *info)
Returns information about the first untaken sample.
eprosima::fastrtps::Subscriber::waitForUnreadMessage
void waitForUnreadMessage()
Method to block the current thread until an unread message is available.
Definition: Subscriber.h:71
eprosima::fastrtps::Subscriber
Class Subscriber, contains the public API that allows the user to control the reception of messages.
Definition: Subscriber.h:43
eprosima::fastrtps::Subscriber::Subscriber
Subscriber(SubscriberImpl *pimpl)
Constructor from a SubscriberImpl pointer.
Definition: Subscriber.h:56
eprosima::fastrtps::Subscriber::wait_for_unread_samples
bool wait_for_unread_samples(const Duration_t &timeout)
Blocks the current thread until an unread sample is available.
eprosima::fastrtps::Subscriber::readNextData
bool readNextData(void *sample, SampleInfo_t *info)
Reads next unread sample from the Subscriber.
eprosima::fastrtps::Subscriber::takeNextData
bool takeNextData(void *sample, SampleInfo_t *info)
Takes next sample from the Subscriber.
eprosima::fastrtps::Subscriber::getGuid
const rtps::GUID_t & getGuid()
Get the associated GUID.
eprosima::fastrtps::Subscriber::get_requested_deadline_missed_status
void get_requested_deadline_missed_status(RequestedDeadlineMissedStatus &status)
Get the requested deadline missed status.
eprosima::fastrtps::Subscriber::getUnreadCount
uint64_t getUnreadCount() const
Get the unread count.
Definition: Subscriber.h:146
eprosima::fastrtps::RequestedDeadlineMissedStatus
DeadlineMissedStatus RequestedDeadlineMissedStatus
Definition: DeadlineMissedStatus.h:32
eprosima
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
eprosima::fastrtps::SubscriberAttributes
Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
Definition: SubscriberAttributes.h:41