OpenDDS  Snapshot(2023/04/28-20:55)
DCPS_IR_Topic.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_TOPIC_H
9 #define DCPS_IR_TOPIC_H
10 
11 #include "inforepo_export.h"
12 #include /**/ "dds/DdsDcpsInfrastructureC.h"
13 #include /**/ "dds/DdsDcpsTopicC.h"
14 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoC.h"
15 #include /**/ "ace/Unbounded_Set.h"
16 #include "dds/DCPS/unique_ptr.h"
17 #include <string>
18 
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 
24 
25 // forward declarations
28 
31 
32 class DCPS_IR_Domain;
36 
37 /**
38  * @class DCPS_IR_Topic
39  *
40  * @brief Representative of a Topic
41  *
42  */
45 {
46 public:
48  const DDS::TopicQos& qos,
49  DCPS_IR_Domain* domain,
50  DCPS_IR_Participant* creator,
51  DCPS_IR_Topic_Description* description,
52  bool isBIT);
53 
54  ~DCPS_IR_Topic();
55 
56  /// Delete the topic object upon last topic associated sub/pub and topic
57  /// object deletion. It's kind of reference counting.
58  /// The removing true indicates it's called upon delete_topic, otherwise
59  /// it's upon remove_publication/remove_subscription.
60  void release(bool removing);
61 
62  /// Adds the publication to the list of publications
63  /// Calls the topic description's try associate if successfully added
64  /// 'associate' switch toggles association attempt.
65  /// Returns 0 if added, 1 if already exists, -1 other failure
66  int add_publication_reference(DCPS_IR_Publication* publication
67  , bool associate = true);
68 
69  /// Removes the publication from the list of publications
70  /// Returns 0 if successful
71  int remove_publication_reference(DCPS_IR_Publication* publication);
72 
73  /// Adds the subscription to the list of subscriptions
74  /// and let description handle the association.
75  /// Returns 0 if added, 1 if already exists, -1 other failure
76  int add_subscription_reference(DCPS_IR_Subscription* subscription
77  , bool associate = true);
78 
79  /// Removes the subscription from the list of subscriptions
80  /// Returns 0 if successful
81  int remove_subscription_reference(DCPS_IR_Subscription* subscription);
82 
83  /// Called by the DCPS_IR_Topic_Description
84  /// Find any compatible publications and associate
85  /// them using the DCPS_IR_Topic_Description's
86  /// associate method.
87  /// This method does not check the subscription's incompatible
88  /// qos status.
89  void try_associate(DCPS_IR_Subscription* subscription);
90 
91  /// Called by the DCPS_IR_Topic_Description to re-evaluate the
92  /// association between the publications of this topic and the
93  /// provided subscription.
94  void reevaluate_associations(DCPS_IR_Subscription* subscription);
95 
96  OpenDDS::DCPS::GUID_t get_id() const;
97  OpenDDS::DCPS::GUID_t get_participant_id() const;
98 
99  /// Return pointer to the Topic Description
100  /// Domain retains ownership
101  DCPS_IR_Topic_Description* get_topic_description();
102 
103  /// Return pointer to the Topic qos
104  /// Topic retains ownership
105  DDS::TopicQos * get_topic_qos();
106 
107  /// Reset topic qos and also propagate the qos change to related BITs
108  /// that has the qos copy.
109  /// Return false if the provided QoS makes the DataWriter and DataReader
110  /// QoS incompatible. Currently supported changeable QoS in TopicQos do
111  /// not affect.
112  bool set_topic_qos(const DDS::TopicQos& qos);
113 
115  void set_handle(DDS::InstanceHandle_t handle);
116 
117  CORBA::Boolean is_bit();
118  void set_bit_status(CORBA::Boolean isBIT);
119 
120  /// Try to associate all the current publications.
121  /// This is used to reconnect Built in Topics after a persistent restart.
122  void reassociate_all_publications();
123 
124  std::string dump_to_string(const std::string& prefix, int depth) const;
125 
126 private:
134 
136  /// Keep track the subscriptions of this topic so the TopicQos
137  /// change can be published for those subscriptions.
139 
140  /// True means release() is called upon delete_topic, but topic object is
141  /// not deleted because there are still pub/sub associated.
142  bool removed_;
143 };
144 
146 
147 #endif /* DCPS_IR_TOPIC_H */
void release(T x)
ACE_Unbounded_Set< DCPS_IR_Subscription * > DCPS_IR_Subscription_Set
Definition: DCPS_IR_Topic.h:29
OpenDDS::DCPS::GUID_t id_
CORBA::Boolean isBIT_
DCPS_IR_Participant * participant_
DCPS_IR_Topic_Description * description_
DCPS_IR_Publication_Set publicationRefs_
#define OpenDDS_InfoRepoLib_Export
DCPS_IR_Domain * domain_
ACE_CDR::Boolean Boolean
Representative of a Topic.
Definition: DCPS_IR_Topic.h:43
DDS::TopicQos qos_
Representative of the Domain Participant.
ACE_HANDLE get_handle(void)
HANDLE_TYPE_NATIVE InstanceHandle_t
Definition: DdsDcpsCore.idl:51
DDS::InstanceHandle_t handle_
DCPS_IR_Subscription_Set subscriptionRefs_
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Representative of a Subscription.
Representation of a Domain in the system.
ACE_Unbounded_Set< DCPS_IR_Publication * > DCPS_IR_Publication_Set
Definition: DCPS_IR_Topic.h:26
Representative of a Topic Description.
Representative of a Publication.