OpenDDS  Snapshot(2023/04/28-20:55)
DCPS_IR_Subscription.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef DCPS_IR_SUBSCRIPTION_H
9 #define DCPS_IR_SUBSCRIPTION_H
10 
11 #include "inforepo_export.h"
12 #include /**/ "UpdateDataTypes.h"
13 #include /**/ "dds/DdsDcpsInfrastructureC.h"
14 #include /**/ "dds/DdsDcpsSubscriptionC.h"
15 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoC.h"
16 #include /**/ "dds/DCPS/InfoRepoDiscovery/DataReaderRemoteC.h"
17 #include /**/ "ace/Unbounded_Set.h"
18 #include "dds/DCPS/unique_ptr.h"
19 
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 
25 
26 // forward declarations
29 
32 class DCPS_IR_Topic;
33 
34 /**
35  * @class DCPS_IR_Subscription
36  *
37  * @brief Representative of a Subscription
38  *
39  *
40  */
42 : public OpenDDS::DCPS::EnableContainerSupportedUniquePtr<DCPS_IR_Subscription> {
43 public:
45  DCPS_IR_Participant* participant,
46  DCPS_IR_Topic* topic,
47  OpenDDS::DCPS::DataReaderRemote_ptr reader,
48  const DDS::DataReaderQos& qos,
50  ACE_CDR::ULong transportContext,
51  const DDS::SubscriberQos& subscriberQos,
52  const char* filterClassName,
53  const char* filterExpression,
54  const DDS::StringSeq& exprParams,
55  const DDS::OctetSeq & serializedTypeInfo);
56 
58 
59  /// Associate with the publication
60  /// Adds the publication to the list of associated
61  /// publications and notifies datareader if successfully added
62  /// This method can mark the participant dead
63  /// Returns 0 if added, 1 if already exists, -1 other failure
64  int add_associated_publication(DCPS_IR_Publication* pub, bool active);
65 
66  /// Remove the associated publication
67  /// Removes the publication from the list of associated
68  /// publications if return successful
69  /// sendNotify indicates whether to tell the datareader about
70  /// removing the publication
71  /// The notify_lost flag true indicates this remove_associations is called
72  /// when the InfoRepo detects this subscription is lost because of the failure
73  /// of invocation on this subscription.
74  /// The notify_both_side parameter indicates if it needs call pub to remove
75  /// association as well.
76  /// This method can mark the participant dead
77  /// Returns 0 if successful
78  int remove_associated_publication(DCPS_IR_Publication* pub,
79  CORBA::Boolean sendNotify,
80  CORBA::Boolean notify_lost,
81  bool notify_both_side = false);
82 
83  /// Removes all the associated publications
84  /// This method can mark the participant dead
85  /// The notify_lost flag true indicates this remove_associations is called
86  /// when the InfoRepo detects this subscription is lost because of the failure
87  /// of invocation on this subscription.
88  /// Returns 0 if successful
89  int remove_associations(CORBA::Boolean notify_lost);
90 
91  /// Remove any publications whose participant has the id
92  void disassociate_participant(OpenDDS::DCPS::GUID_t id,
93  bool reassociate = false);
94 
95  /// Remove any publications whose topic has the id
96  void disassociate_topic(OpenDDS::DCPS::GUID_t id);
97 
98  /// Remove any publications with id
99  void disassociate_publication(OpenDDS::DCPS::GUID_t id,
100  bool reassociate = false);
101 
102  /// Notify the reader of incompatible qos status
103  /// and reset the status' count_since_last_send to 0
104  void update_incompatible_qos();
105 
106  /// Check that none of the ids given are ones that
107  /// this subscription should ignore.
108  /// returns 1 if one of these ids is an ignored id
109  CORBA::Boolean is_publication_ignored(OpenDDS::DCPS::GUID_t partId,
110  OpenDDS::DCPS::GUID_t topicId,
111  OpenDDS::DCPS::GUID_t pubId);
112 
113  /// Return pointer to the DataReader qos
114  /// Subscription retains ownership
115  const DDS::DataReaderQos* get_datareader_qos();
116 
117  /// Return pointer to the Subscriber qos
118  /// Subscription retains ownership
119  const DDS::SubscriberQos* get_subscriber_qos();
120 
121  /// Update the DataReader or Subscriber qos and also publish the qos
122  /// changes to datereader BIT.
123  bool set_qos(const DDS::DataReaderQos & qos,
124  const DDS::SubscriberQos & subscriberQos,
125  Update::SpecificQos& specificQos);
126 
127  /// Update DataReaderQos only.
128  void set_qos(const DDS::DataReaderQos& qos);
129 
130  /// Update SubscriberQos only.
131  void set_qos(const DDS::SubscriberQos& qos);
132 
133  void reevaluate_defunct_associations();
134 
135  // Verify the existing associations. This may result removal of
136  // associations. The existing associations have to be removed before
137  // adding new association and may need some delay. Otherwise, if
138  // two DataWriters uses same Datalink and add an association happens
139  // before remove an association then the new association will fail to
140  // connect.
141  void reevaluate_existing_associations();
142 
143  // Re-evaluate the association between this subscription and the provided
144  // publication. If they are already associated and not compatible then
145  // they will be dis-associated. If they are not already associated then
146  // the new association will be added.
147  bool reevaluate_association(DCPS_IR_Publication* publication);
148 
149  OpenDDS::DCPS::TransportLocatorSeq get_transportLocatorSeq() const;
150  ACE_CDR::ULong get_transportContext() const { return transportContext_; }
151 
152  /// Return pointer to the incompatible qos status
153  /// Subscription retains ownership
154  OpenDDS::DCPS::IncompatibleQosStatus* get_incompatibleQosStatus();
155 
156  OpenDDS::DCPS::GUID_t get_id();
157  OpenDDS::DCPS::GUID_t get_topic_id();
158  OpenDDS::DCPS::GUID_t get_participant_id();
159 
160  DCPS_IR_Topic_Description* get_topic_description();
161 
162  DCPS_IR_Topic* get_topic();
163 
165  void set_handle(DDS::InstanceHandle_t handle);
166 
167  CORBA::Boolean is_bit();
168  void set_bit_status(CORBA::Boolean isBIT);
169 
170  // Expose the datareader.
171  OpenDDS::DCPS::DataReaderRemote_ptr reader();
172 
173  std::string get_filter_class_name() const;
174  std::string get_filter_expression() const;
175  DDS::StringSeq get_expr_params() const;
176 
177  /// Calls associated Publications
178  void update_expr_params(const DDS::StringSeq& params);
179 
180  std::string dump_to_string(const std::string& prefix, int depth) const;
181 
182 
183  const DDS::OctetSeq& get_serialized_type_info() const;
184 
185 private:
191 
192  /// the corresponding DataReaderRemote object
193  OpenDDS::DCPS::DataReaderRemote_var reader_;
198  std::string filterClassName_;
199  std::string filterExpression_;
204 
206 };
207 
209 
210 #endif /* DCPS_IR_SUBSCRIPTION_H */
DCPS_IR_Publication_Set associations_
DDS::SubscriberQos subscriberQos_
DDS::OctetSeq serializedTypeInfo_
sequence< TransportLocator > TransportLocatorSeq
DDS::DataReaderQos qos_
#define OpenDDS_InfoRepoLib_Export
DDS::InstanceHandle_t handle_
DCPS_IR_Publication_Set defunct_
OpenDDS::DCPS::IncompatibleQosStatus incompatibleQosStatus_
ACE_CDR::Boolean Boolean
OpenDDS::DCPS::GUID_t id_
Representative of a Topic.
Definition: DCPS_IR_Topic.h:43
Representative of the Domain Participant.
sequence< octet > OctetSeq
Definition: DdsDcpsCore.idl:64
ACE_UINT32 ULong
ACE_HANDLE get_handle(void)
OpenDDS::DCPS::TransportLocatorSeq info_
HANDLE_TYPE_NATIVE InstanceHandle_t
Definition: DdsDcpsCore.idl:51
ACE_Unbounded_Set< DCPS_IR_Publication * > DCPS_IR_Publication_Set
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Representative of a Subscription.
ACE_CDR::ULong get_transportContext() const
OpenDDS::DCPS::DataReaderRemote_var reader_
the corresponding DataReaderRemote object
Representative of a Topic Description.
ACE_CDR::ULong transportContext_
Representative of a Publication.
sequence< string > StringSeq
Definition: DdsDcpsCore.idl:50
DCPS_IR_Participant * participant_