OpenDDS  Snapshot(2023/04/28-20:55)
DCPS_IR_Publication.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_PUBLICATION_H
9 #define DCPS_IR_PUBLICATION_H
10 
11 #include "inforepo_export.h"
12 #include /**/ "UpdateDataTypes.h"
13 #include /**/ "dds/DdsDcpsInfrastructureC.h"
14 #include /**/ "dds/DdsDcpsPublicationC.h"
15 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoC.h"
16 #include /**/ "dds/DCPS/InfoRepoDiscovery/DataWriterRemoteC.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
28 class DCPS_IR_Topic;
30 
33 
34 /**
35  * @class DCPS_IR_Publication
36  *
37  * @brief Representative of a Publication
38  *
39  *
40  */
42 : public OpenDDS::DCPS::EnableContainerSupportedUniquePtr<DCPS_IR_Publication> {
43 public:
45  DCPS_IR_Participant* participant,
46  DCPS_IR_Topic* topic,
47  OpenDDS::DCPS::DataWriterRemote_ptr writer,
48  const DDS::DataWriterQos& qos,
50  ACE_CDR::ULong transportContext,
51  const DDS::PublisherQos& publisherQos,
52  const DDS::OctetSeq & serializedTypeInfo);
53 
55 
56  /// Associate with the subscription
57  /// Adds the subscription to the list of associated
58  /// subscriptions and notifies datawriter if successfully added
59  /// This method can mark the participant dead
60  /// Returns 0 if added, 1 if already exists, -1 other failure
61  int add_associated_subscription(DCPS_IR_Subscription* sub, bool active);
62 
63  /// Remove the associated subscription
64  /// Removes the subscription from the list of associated
65  /// subscriptions if return successful
66  /// sendNotify indicates whether to tell the datawriter about
67  /// removing the subscription
68  /// The notify_lost parameter is passed to the remove_associations()
69  /// The notify_both_side parameter indicates if it needs call sub to remove
70  /// association as well.
71  /// See the comments of remove_associations() in DataWriterRemote.idl
72  /// or DataReaderRemote.idl.
73  /// This method can mark the participant dead
74  /// Returns 0 if successful
75  int remove_associated_subscription(DCPS_IR_Subscription* sub,
76  CORBA::Boolean sendNotify,
77  CORBA::Boolean notify_lost,
78  bool notify_both_side = false);
79 
80  /// Removes all the associated subscriptions
81  /// This method can mark the participant dead
82  /// The notify_lost flag true indicates this remove_associations is called
83  /// when the InfoRepo detects this publication is lost because of the failure
84  /// of invocation on this publication.
85  /// Returns 0 if successful
86  int remove_associations(CORBA::Boolean notify_lost);
87 
88  /// Remove any subscriptions whose participant has the id
89  void disassociate_participant(OpenDDS::DCPS::GUID_t id,
90  bool reassociate = false);
91 
92  /// Remove any subscriptions whose topic has the id
93  void disassociate_topic(OpenDDS::DCPS::GUID_t id);
94 
95  /// Remove any subscriptions with the id
96  void disassociate_subscription(OpenDDS::DCPS::GUID_t id,
97  bool reassociate = false);
98 
99  /// Notify the writer of incompatible qos status
100  /// and reset the status' count_since_last_send to 0
101  void update_incompatible_qos();
102 
103  /// Check that none of the ids given are ones that
104  /// this publication should ignore.
105  /// returns 1 if one of these ids is an ignored id
106  CORBA::Boolean is_subscription_ignored(OpenDDS::DCPS::GUID_t partId,
107  OpenDDS::DCPS::GUID_t topicId,
108  OpenDDS::DCPS::GUID_t subId);
109 
110  /// Return pointer to the DataWriter qos
111  /// Publication retains ownership
112  DDS::DataWriterQos* get_datawriter_qos();
113 
114  /// Return pointer to the Publisher qos
115  /// Publication retains ownership
116  DDS::PublisherQos* get_publisher_qos();
117 
118  /// Update the DataWriter or Publisher qos and also publish the qos changes
119  /// to datawriter BIT.
120  bool set_qos(const DDS::DataWriterQos & qos,
121  const DDS::PublisherQos & publisherQos,
122  Update::SpecificQos& specificQos);
123 
124  /// Update DataWriterQos only.
125  void set_qos(const DDS::DataWriterQos& qos);
126 
127  /// Update PublisherQos only.
128  void set_qos(const DDS::PublisherQos& qos);
129 
130  OpenDDS::DCPS::TransportLocatorSeq get_transportLocatorSeq() const;
131  ACE_CDR::ULong get_transportContext() const { return transportContext_; }
132 
133  /// Return pointer to the incompatible qos status
134  /// Publication retains ownership
135  OpenDDS::DCPS::IncompatibleQosStatus* get_incompatibleQosStatus();
136 
137  OpenDDS::DCPS::GUID_t get_id();
138  OpenDDS::DCPS::GUID_t get_topic_id();
139  OpenDDS::DCPS::GUID_t get_participant_id();
140 
141  DCPS_IR_Topic* get_topic();
142  DCPS_IR_Topic_Description* get_topic_description();
143 
145  void set_handle(DDS::InstanceHandle_t handle);
146 
147  CORBA::Boolean is_bit();
148  void set_bit_status(CORBA::Boolean isBIT);
149 
150  // Expose the datawriter.
151  OpenDDS::DCPS::DataWriterRemote_ptr writer();
152 
153  void reevaluate_defunct_associations();
154 
155  // Verify the existing associations. This may result removal of
156  // associations. The existing associations have to be removed before
157  // adding new association and may need some delay. Otherwise, if
158  // two DataReaders uses same Datalink and add an association happens
159  // before remove an association then the new association will fail to
160  // connect.
161  void reevaluate_existing_associations();
162 
163  // Re-evaluate the association between this publication and the provided
164  // subscription. If they are already associated and not compatible then
165  // they will be dis-associated. If they are not already associated then
166  // the new association will be added.
167  bool reevaluate_association(DCPS_IR_Subscription* subscription);
168 
169  void update_expr_params(OpenDDS::DCPS::GUID_t readerId,
170  const DDS::StringSeq& params);
171 
172  std::string dump_to_string(const std::string& prefix, int depth) const;
173 
174  const DDS::OctetSeq& get_serialized_type_info() const;
175 
176 private:
177 
183 
184  /// the corresponding DataWriterRemote object
185  OpenDDS::DCPS::DataWriterRemote_var writer_;
193 
195 };
196 
198 
199 #endif /* DCPS_IR_PUBLICATION_H */
DDS::OctetSeq serializedTypeInfo_
ACE_CDR::ULong get_transportContext() const
sequence< TransportLocator > TransportLocatorSeq
#define OpenDDS_InfoRepoLib_Export
OpenDDS::DCPS::GUID_t id_
ACE_Unbounded_Set< DCPS_IR_Subscription * > DCPS_IR_Subscription_Set
ACE_CDR::Boolean Boolean
ACE_CDR::ULong transportContext_
OpenDDS::DCPS::TransportLocatorSeq info_
Representative of a Topic.
Definition: DCPS_IR_Topic.h:43
DCPS_IR_Participant * participant_
Representative of the Domain Participant.
DCPS_IR_Subscription_Set defunct_
OpenDDS::DCPS::IncompatibleQosStatus incompatibleQosStatus_
sequence< octet > OctetSeq
Definition: DdsDcpsCore.idl:64
ACE_UINT32 ULong
ACE_HANDLE get_handle(void)
HANDLE_TYPE_NATIVE InstanceHandle_t
Definition: DdsDcpsCore.idl:51
OpenDDS::DCPS::DataWriterRemote_var writer_
the corresponding DataWriterRemote object
DDS::DataWriterQos qos_
DDS::PublisherQos publisherQos_
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Representative of a Subscription.
DDS::InstanceHandle_t handle_
DCPS_IR_Subscription_Set associations_
Representative of a Topic Description.
Representative of a Publication.
sequence< string > StringSeq
Definition: DdsDcpsCore.idl:50