Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
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 <fastdds/rtps/common/Locator.h>
26#include <fastrtps/attributes/SubscriberAttributes.h>
27#include <fastrtps/qos/DeadlineMissedStatus.h>
28#include <fastrtps/qos/LivelinessChangedStatus.h>
29
30namespace eprosima {
31namespace fastrtps {
32
33class SubscriberImpl;
34class SampleInfo_t;
35
43class RTPS_DllAPI Subscriber
44{
45 friend class SubscriberImpl;
46
47 virtual ~Subscriber()
48 {
49 }
50
51public:
52
58 SubscriberImpl* pimpl)
59 : mp_impl(pimpl)
60 {
61 }
62
67 const rtps::GUID_t& getGuid();
68
73 {
74 const Duration_t one_day{ 24 * 3600, 0 };
75 while (!wait_for_unread_samples(one_day))
76 {
77 }
78 }
79
87 const Duration_t& timeout);
88
98 void* sample,
99 SampleInfo_t* info);
100
110 void* sample,
111 SampleInfo_t* info);
112
119 SampleInfo_t* info);
120
127 const SubscriberAttributes& att);
128
134
141 bool isInCleanState() const;
142
147 inline uint64_t getUnreadCount() const
148 {
149 return get_unread_count();
150 }
151
156 uint64_t get_unread_count() const;
157
164
171
178 rtps::LocatorList_t& locators) const;
179
180private:
181
182 SubscriberImpl* mp_impl;
183};
184
185
186
187} /* namespace pubsub */
188} /* namespace eprosima */
189
190#endif /* SUBSCRIBER_H_ */
Class SampleInfo_t with information that is provided along a sample when reading data from a Subscrib...
Definition SampleInfo.h:39
Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
Definition SubscriberAttributes.h:39
Class Subscriber, contains the public API that allows the user to control the reception of messages.
Definition Subscriber.h:44
bool updateAttributes(const SubscriberAttributes &att)
Update the Attributes of the subscriber;.
void get_liveliness_changed_status(LivelinessChangedStatus &status)
Returns the liveliness changed status.
Subscriber(SubscriberImpl *pimpl)
Constructor from a SubscriberImpl pointer.
Definition Subscriber.h:57
bool get_first_untaken_info(SampleInfo_t *info)
Returns information about the first untaken sample.
const rtps::GUID_t & getGuid()
Get the associated GUID.
bool readNextData(void *sample, SampleInfo_t *info)
Reads next unread sample from the Subscriber.
const SubscriberAttributes & getAttributes() const
Get the Attributes of the Subscriber.
uint64_t get_unread_count() const
Get the unread count.
bool isInCleanState() const
Returns there is a clean state with all Publishers.
void get_requested_deadline_missed_status(RequestedDeadlineMissedStatus &status)
Get the requested deadline missed status.
bool wait_for_unread_samples(const Duration_t &timeout)
Blocks the current thread until an unread sample is available.
uint64_t getUnreadCount() const
Get the unread count.
Definition Subscriber.h:147
void get_listening_locators(rtps::LocatorList_t &locators) const
Get the list of locators on which this subscriber is listening.
void waitForUnreadMessage()
Method to block the current thread until an unread message is available.
Definition Subscriber.h:72
bool takeNextData(void *sample, SampleInfo_t *info)
Takes next sample from the Subscriber.
DeadlineMissedStatus RequestedDeadlineMissedStatus
Definition DeadlineMissedStatus.h:30
fastdds::dds::LivelinessChangedStatus LivelinessChangedStatus
Definition LivelinessChangedStatus.h:27
eProsima namespace.
Definition LibrarySettingsAttributes.h:23