OpenDDS  Snapshot(2023/04/28-20:55)
DCPS_IR_Participant.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_PARTICIPANT_H
9 #define DCPS_IR_PARTICIPANT_H
10 
11 #include "inforepo_export.h"
12 #include /**/ "dds/DdsDcpsInfrastructureC.h"
13 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoS.h"
14 
16 #include "dds/DCPS/GuidUtils.h"
17 #include "dds/DCPS/RcObject.h"
18 
19 #include /**/ "ace/Map_Manager.h"
20 
21 #include /**/ "DCPS_IR_Subscription.h"
22 #include /**/ "DCPS_IR_Publication.h"
23 #include /**/ "DCPS_IR_Topic.h"
24 
25 #include <map>
26 
27 #if !defined (ACE_LACKS_PRAGMA_ONCE)
28 #pragma once
29 #endif /* ACE_LACKS_PRAGMA_ONCE */
30 
32 
33 // forward declarations
34 class DCPS_IR_Domain;
36 
37 namespace Update {
38 
39 class Manager;
40 
41 } // namespace Update
42 
43 typedef std::map<OpenDDS::DCPS::GUID_t,
46 typedef std::map<OpenDDS::DCPS::GUID_t,
49 typedef std::map<OpenDDS::DCPS::GUID_t,
52 
54 
55 /**
56  * @class DCPS_IR_Participant
57  *
58  * @brief Representative of the Domain Participant
59  *
60  *
61  */
64 {
65 public:
66  /// Special owner to enforce no callbacks.
67  enum { OWNER_NONE};
68 
71  DCPS_IR_Domain* domain,
73  Update::Manager* um,
74  bool isBit);
75 
76  virtual ~DCPS_IR_Participant();
77 
78  /// Take local ownership of this participant and publish an update.
79  void takeOwnership();
80 
81  /// Process an incoming update that changes ownership.
82  void changeOwner(long sender, long owner);
83 
84  /// Value of the owner for this participant.
85  long owner() const;
86 
87  /// Indication of whether the current repository is the owner of this participant.
88  bool isOwner() const;
89 
90  ///@{
91  /// Flag to discriminate the built-in topic publishing participant within a domain.
92  bool& isBitPublisher();
93  bool isBitPublisher() const;
94  ///@}
95 
96  /// Add a publication
97  /// This takes ownership of the memory pointed to by pub
98  /// Returns 0 if added, 1 if already exists, -1 other failure
99  int add_publication(OpenDDS::DCPS::unique_ptr<DCPS_IR_Publication> pub);
100 
101  /// Return the publication object.
102  int find_publication_reference(OpenDDS::DCPS::GUID_t pubId,
103  DCPS_IR_Publication*& pub);
104 
105  /// Removes the publication with the id
106  /// Deletes the publication object if returns successful
107  /// Returns 0 if successful
108  int remove_publication(OpenDDS::DCPS::GUID_t pubId);
109 
110  /// Add a subscription
111  /// This takes ownership of the memory pointed to by aub
112  /// Returns 0 if added, 1 if already exists, -1 other failure
113  int add_subscription(OpenDDS::DCPS::unique_ptr<DCPS_IR_Subscription> sub);
114 
115  /// Return the subscription object.
116  int find_subscription_reference(OpenDDS::DCPS::GUID_t subId,
117  DCPS_IR_Subscription*& sub);
118 
119  /// Removes the subscription with the id
120  /// Deletes the subscription object if returns successful
121  /// Returns 0 if successful
122  int remove_subscription(OpenDDS::DCPS::GUID_t subId);
123 
124  /// Add a topic
125  /// Returns 0 if added, 1 if already exists, -1 other failure
126  int add_topic_reference(DCPS_IR_Topic* topic);
127 
128  /// Remove a topic reference
129  /// Does not change or take ownership of topic
130  /// Returns 0 if successful
131  int remove_topic_reference(OpenDDS::DCPS::GUID_t topicId,
132  DCPS_IR_Topic*& topic);
133 
134  /// Find topic reference with id
135  /// Does NOT give ownership of memory
136  /// Returns 0 if successful
137  int find_topic_reference(OpenDDS::DCPS::GUID_t topicId,
138  DCPS_IR_Topic*& topic);
139 
140  /// Removes all topics, publications and
141  // subscriptions for this participant
142  void remove_all_dependents(CORBA::Boolean notify_lost);
143 
144  // called by publications and subscriptions when the writer
145  // or reader throws an exception during a remote invocation
146  //
147  /// Changes aliveStatus to false then adds itself to the
148  /// domain's list of dead participants for removal
149  void mark_dead();
150 
151  OpenDDS::DCPS::GUID_t get_id();
152 
153  CORBA::Boolean is_alive();
154  void set_alive(CORBA::Boolean alive);
155 
156  /// Ignore the participant with the id
157  void ignore_participant(OpenDDS::DCPS::GUID_t id);
158  /// Ignore the topic with the id
159  void ignore_topic(OpenDDS::DCPS::GUID_t id);
160  /// Ignore the publication with the id
161  void ignore_publication(OpenDDS::DCPS::GUID_t id);
162  /// Ignore the subscription with the id
163  void ignore_subscription(OpenDDS::DCPS::GUID_t id);
164 
165  /// Return pointer to the participant qos
166  /// Participant retains ownership
167  const DDS::DomainParticipantQos* get_qos();
168 
169  /// Update qos and also propagate the qos change to related BITs
170  /// that has the qos copy.
171  /// Return false if the provided QoS makes the DataWriter and DataReader
172  /// QoS incompatible. Currently supported changeable QoS in DomainParticipantQos
173  /// do not affect.
174  bool set_qos(const DDS::DomainParticipantQos & qos);
175 
176  ///@{
177  /// Test if an entity is ignored by this participant.
178  CORBA::Boolean is_participant_ignored(OpenDDS::DCPS::GUID_t id);
179  CORBA::Boolean is_topic_ignored(OpenDDS::DCPS::GUID_t id);
180  CORBA::Boolean is_publication_ignored(OpenDDS::DCPS::GUID_t id);
181  CORBA::Boolean is_subscription_ignored(OpenDDS::DCPS::GUID_t id);
182  ///@}
183 
185  void set_handle(DDS::InstanceHandle_t handle);
186 
187  DCPS_IR_Domain* get_domain_reference() const;
188 
189  ///@{
190  /// Next Entity Id value in sequence.
191  OpenDDS::DCPS::GUID_t get_next_topic_id(bool builtin);
192  OpenDDS::DCPS::GUID_t get_next_publication_id(bool builtin);
193  OpenDDS::DCPS::GUID_t get_next_subscription_id(bool builtin);
194  ///@}
195 
196  ///@{
197  /// Ensure no conflicts with sequence values from persistent storage.
198  void last_topic_key(long key);
199  void last_publication_key(long key);
200  void last_subscription_key(long key);
201  ///@}
202 
203  /// Expose a readable reference to the publication map.
204  const DCPS_IR_Publication_Map& publications() const;
205 
206  /// Expose a readable reference to the subscription map.
207  const DCPS_IR_Subscription_Map& subscriptions() const;
208 
209  /// Expose a readable reference to the topic map.
210  const DCPS_IR_Topic_Map& topics() const;
211 
212  std::string dump_to_string(const std::string& prefix, int depth) const;
213 
214 private:
220 
222  long owner_;
223 
224  /// Lock portions ownership processing.
226 
227  ///@{
228  /// Entity GUID Id generators.
232  ///@}
233 
234  ///@{
235  /// Entities in the Participant
236  DCPS_IR_Subscription_Map subscriptions_;
237  DCPS_IR_Publication_Map publications_;
238  DCPS_IR_Topic_Map topicRefs_;
239  ///@}
240 
241  ///@{
242  /// Lists of Ignored Entities
247  ///@}
248 
249  /**
250  * The participant is the only entity that has and deals with
251  * dependencies (topics, actors). In handling dependencies it
252  * encompasses a bigger role. Therefore it needs to update
253  * other entities (specifically the Update::Manager) the
254  * changes it makes.
255  */
257 
258  /// Flag indicating this participant publishes built-in topics.
260 };
261 
263 
264 #endif /* DCPS_IR_PARTICIPANT_H */
TAO_DDS_RepoId_Set ignoredPublications_
#define ACE_SYNCH_MUTEX
Update::Manager * um_
OpenDDS::DCPS::RepoIdGenerator publicationIdGenerator_
DDS::DomainParticipantQos qos_
sequence< octet > key
#define OpenDDS_InfoRepoLib_Export
OpenDDS::DCPS::GUID_t id_
CORBA::Boolean aliveStatus_
std::map< OpenDDS::DCPS::GUID_t, OpenDDS::DCPS::container_supported_unique_ptr< DCPS_IR_Publication >, OpenDDS::DCPS::GUID_tKeyLessThan > DCPS_IR_Publication_Map
DCPS_IR_Topic_Map topicRefs_
DCPS_IR_Subscription_Map subscriptions_
const TAO_DDS_DCPSFederationId & federationId_
TAO_DDS_RepoId_Set ignoredSubscriptions_
ACE_CDR::Boolean Boolean
ACE_SYNCH_MUTEX ownerLock_
Lock portions ownership processing.
DCPS_IR_Publication_Map publications_
TAO_DDS_RepoId_Set ignoredParticipants_
Representative of a Topic.
Definition: DCPS_IR_Topic.h:43
Representative of the Domain Participant.
Create RepoId values for use within DDS.
DDS::InstanceHandle_t handle_
bool isBitPublisher_
Flag indicating this participant publishes built-in topics.
ACE_HANDLE get_handle(void)
HANDLE_TYPE_NATIVE InstanceHandle_t
Definition: DdsDcpsCore.idl:51
std::map< OpenDDS::DCPS::GUID_t, DCPS_IR_Topic *, OpenDDS::DCPS::GUID_tKeyLessThan > DCPS_IR_Topic_Map
TAO_DDS_RepoId_Set ignoredTopics_
OpenDDS::DCPS::RepoIdGenerator topicIdGenerator_
DCPS_IR_Domain * domain_
std::map< OpenDDS::DCPS::GUID_t, OpenDDS::DCPS::container_supported_unique_ptr< DCPS_IR_Subscription >, OpenDDS::DCPS::GUID_tKeyLessThan > DCPS_IR_Subscription_Map
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Representative of a Subscription.
Representation of a Domain in the system.
ACE_Unbounded_Set< OpenDDS::DCPS::GUID_t > TAO_DDS_RepoId_Set
OpenDDS::DCPS::RepoIdGenerator subscriptionIdGenerator_
Representative of a Publication.