OpenDDS  Snapshot(2023/04/28-20:55)
InfoRepoDiscovery.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 OPENDDS_DCPS_INFOREPODISCOVERY_INFOREPODISCOVERY_H
9 #define OPENDDS_DCPS_INFOREPODISCOVERY_INFOREPODISCOVERY_H
10 
11 #include "DataReaderRemoteC.h"
13 #include "InfoC.h"
14 
15 #include <dds/DdsDcpsInfoUtilsC.h>
16 #include <dds/DCPS/Atomic.h>
17 #include <dds/DCPS/Discovery.h>
18 #include <dds/DCPS/GuidUtils.h>
22 
23 #include <ace/Task.h>
24 #include <ace/Thread_Mutex.h>
25 
26 #include <string>
27 
28 #if !defined (ACE_LACKS_PRAGMA_ONCE)
29 #pragma once
30 #endif /* ACE_LACKS_PRAGMA_ONCE */
31 
33 
34 namespace OpenDDS {
35 namespace DCPS {
36 
37 /**
38  * @class InfoRepoDiscovery
39  *
40  * @brief Discovery Strategy class that implements InfoRepo discovery
41  *
42  * This class implements the Discovery interface for InfoRepo-based
43  * discovery.
44  *
45  */
47 public:
48  InfoRepoDiscovery(const RepoKey& key, const std::string& ior);
49  InfoRepoDiscovery(const RepoKey& key, const DCPSInfo_var& info);
50 
51  virtual ~InfoRepoDiscovery();
52 
53  std::string get_stringified_dcps_info_ior();
54  DCPSInfo_var get_dcps_info();
55 
56  virtual bool active();
57 
58  int bit_transport_port() const { return bit_transport_port_; }
59  void bit_transport_port(int port) {
60  bit_transport_port_ = port;
61  use_local_bit_config_ = true;
62  }
63 
64  std::string bit_transport_ip() const { return bit_transport_ip_; }
65  void bit_transport_ip(const std::string& ip) {
66  bit_transport_ip_ = ip;
67  use_local_bit_config_ = true;
68  }
69 
70  /// User provides an ORB for OpenDDS to use.
71  /// @note The user is responsible for running the ORB.
72  /// @Returns true if the operation succeeds
73  bool set_ORB(CORBA::ORB_ptr orb);
74 
75  virtual RcHandle<BitSubscriber> init_bit(DomainParticipantImpl* participant);
76 
77  virtual void fini_bit(DCPS::DomainParticipantImpl* participant);
78 
79  virtual bool attach_participant(
80  DDS::DomainId_t domainId,
81  const OpenDDS::DCPS::GUID_t& participantId);
82 
83  virtual OpenDDS::DCPS::GUID_t generate_participant_guid();
84 
85  virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant(
86  DDS::DomainId_t domain,
87  const DDS::DomainParticipantQos& qos,
89 
90 #if defined(OPENDDS_SECURITY)
91  virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant_secure(
92  DDS::DomainId_t domain,
93  const DDS::DomainParticipantQos& qos,
95  const OpenDDS::DCPS::GUID_t& guid,
99 #endif
100 
101  virtual bool remove_domain_participant(
102  DDS::DomainId_t domainId,
103  const OpenDDS::DCPS::GUID_t& participantId);
104 
105  virtual bool ignore_domain_participant(
106  DDS::DomainId_t domainId,
107  const OpenDDS::DCPS::GUID_t& myParticipantId,
108  const OpenDDS::DCPS::GUID_t& ignoreId);
109 
110  virtual bool update_domain_participant_qos(
111  DDS::DomainId_t domain,
112  const OpenDDS::DCPS::GUID_t& participantId,
113  const DDS::DomainParticipantQos& qos);
114 
115 
116  // Topic operations:
117 
118  virtual OpenDDS::DCPS::TopicStatus assert_topic(
119  OpenDDS::DCPS::GUID_t_out topicId,
120  DDS::DomainId_t domainId,
121  const OpenDDS::DCPS::GUID_t& participantId,
122  const char* topicName,
123  const char* dataTypeName,
124  const DDS::TopicQos& qos,
125  bool hasDcpsKey,
126  TopicCallbacks* topic_callbacks);
127 
128  virtual OpenDDS::DCPS::TopicStatus find_topic(
129  DDS::DomainId_t domainId,
130  const OpenDDS::DCPS::GUID_t& participantId,
131  const char* topicName,
132  CORBA::String_out dataTypeName,
133  DDS::TopicQos_out qos,
134  OpenDDS::DCPS::GUID_t_out topicId);
135 
136  virtual OpenDDS::DCPS::TopicStatus remove_topic(
137  DDS::DomainId_t domainId,
138  const OpenDDS::DCPS::GUID_t& participantId,
139  const OpenDDS::DCPS::GUID_t& topicId);
140 
141  virtual bool ignore_topic(
142  DDS::DomainId_t domainId,
143  const OpenDDS::DCPS::GUID_t& myParticipantId,
144  const OpenDDS::DCPS::GUID_t& ignoreId);
145 
146  virtual bool update_topic_qos(
147  const OpenDDS::DCPS::GUID_t& topicId,
148  DDS::DomainId_t domainId,
149  const OpenDDS::DCPS::GUID_t& participantId,
150  const DDS::TopicQos& qos);
151 
152 
153  // Publication operations:
154 
155  virtual OpenDDS::DCPS::GUID_t add_publication(
156  DDS::DomainId_t domainId,
157  const OpenDDS::DCPS::GUID_t& participantId,
158  const OpenDDS::DCPS::GUID_t& topicId,
160  const DDS::DataWriterQos& qos,
161  const OpenDDS::DCPS::TransportLocatorSeq& transInfo,
162  const DDS::PublisherQos& publisherQos,
163  const XTypes::TypeInformation& type_info);
164 
165  virtual bool remove_publication(
166  DDS::DomainId_t domainId,
167  const OpenDDS::DCPS::GUID_t& participantId,
168  const OpenDDS::DCPS::GUID_t& publicationId);
169 
170  virtual bool ignore_publication(
171  DDS::DomainId_t domainId,
172  const OpenDDS::DCPS::GUID_t& myParticipantId,
173  const OpenDDS::DCPS::GUID_t& ignoreId);
174 
175  virtual bool update_publication_qos(
176  DDS::DomainId_t domainId,
177  const OpenDDS::DCPS::GUID_t& partId,
178  const OpenDDS::DCPS::GUID_t& dwId,
179  const DDS::DataWriterQos& qos,
180  const DDS::PublisherQos& publisherQos);
181 
182 
183  // Subscription operations:
184 
185  virtual OpenDDS::DCPS::GUID_t add_subscription(
186  DDS::DomainId_t domainId,
187  const OpenDDS::DCPS::GUID_t& participantId,
188  const OpenDDS::DCPS::GUID_t& topicId,
190  const DDS::DataReaderQos& qos,
191  const OpenDDS::DCPS::TransportLocatorSeq& transInfo,
192  const DDS::SubscriberQos& subscriberQos,
193  const char* filterClassName,
194  const char* filterExpression,
195  const DDS::StringSeq& exprParams,
196  const XTypes::TypeInformation& type_info);
197 
198  virtual bool remove_subscription(
199  DDS::DomainId_t domainId,
200  const OpenDDS::DCPS::GUID_t& participantId,
201  const OpenDDS::DCPS::GUID_t& subscriptionId);
202 
203  virtual bool ignore_subscription(
204  DDS::DomainId_t domainId,
205  const OpenDDS::DCPS::GUID_t& myParticipantId,
206  const OpenDDS::DCPS::GUID_t& ignoreId);
207 
208  virtual bool update_subscription_qos(
209  DDS::DomainId_t domainId,
210  const OpenDDS::DCPS::GUID_t& partId,
211  const OpenDDS::DCPS::GUID_t& drId,
212  const DDS::DataReaderQos& qos,
213  const DDS::SubscriberQos& subscriberQos);
214 
215  virtual bool update_subscription_params(
216  DDS::DomainId_t domainId,
217  const OpenDDS::DCPS::GUID_t& participantId,
218  const OpenDDS::DCPS::GUID_t& subscriptionId,
219  const DDS::StringSeq& params);
220 
221 private:
222  TransportConfig_rch bit_config();
223 
224  void removeDataReaderRemote(const GUID_t& subscriptionId);
225 
226  void removeDataWriterRemote(const GUID_t& publicationId);
227 
228  std::string ior_;
229  DCPSInfo_var info_;
230 
231  /// The builtin topic transport address.
232  std::string bit_transport_ip_;
233 
234  /// The builtin topic transport port number.
236 
239 
242 
245  int svc();
246  void shutdown();
247 
250  private:
251  OrbRunner(const OrbRunner&);
252  OrbRunner& operator=(const OrbRunner&);
253  };
254 
257 
258  typedef OPENDDS_MAP_CMP(GUID_t, DataReaderRemote_var, DCPS::GUID_tKeyLessThan) DataReaderMap;
259 
260  DataReaderMap dataReaderMap_;
261 
262  typedef OPENDDS_MAP_CMP(GUID_t, DataWriterRemote_var, DCPS::GUID_tKeyLessThan) DataWriterMap;
263 
264  DataWriterMap dataWriterMap_;
265 
267 
268 public:
269  class Config : public Discovery::Config {
270  public:
271  int discovery_config(ACE_Configuration_Heap& cf);
272  };
273 
275  public:
277  };
278 };
279 
281 
283 
284 // Support loading this library using the ACE Service Configurator:
285 // this is used by TransportRegistry (from Service_Participant).
286 
288  : public ACE_Service_Object {
289 public:
290  virtual int init(int argc, ACE_TCHAR* argv[]);
291 };
292 
293 ACE_STATIC_SVC_DECLARE_EXPORT(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
294 ACE_FACTORY_DECLARE(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
295 
296 } // namespace DCPS
297 } // namespace OpenDDS
298 
300 
301 #endif /* OPENDDS_DCPS_INFOREPODISCOVERY_H */
Implements the OpenDDS::DCPS::DomainParticipant interfaces.
ACE_STATIC_SVC_DECLARE_EXPORT(TAO_Transport_Current, TAO_Transport_Current_Loader) ACE_FACTORY_DECLARE(TAO_Transport_Current
int bit_transport_port_
The builtin topic transport port number.
sequence< octet > key
#define OpenDDS_InfoRepoDiscovery_Export
static ACE_Thread_Mutex mtx_orb_runner_
sequence< TransportLocator > TransportLocatorSeq
std::string bit_transport_ip_
The builtin topic transport address.
Discovery Strategy class that implements InfoRepo discovery.
DOMAINID_TYPE_NATIVE DomainId_t
RcHandle< InfoRepoDiscovery > InfoRepoDiscovery_rch
char ACE_TCHAR
typedef OPENDDS_MAP_CMP(GUID_t, WriterCoherentSample, GUID_tKeyLessThan) GroupCoherentSamples
int init(void)
std::string bit_transport_ip() const
#define ACE_FACTORY_DECLARE(CLS, SERVICE_CLASS)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Discovery Strategy interface class.
Definition: Discovery.h:76
int shutdown(ACE_HANDLE handle, int how)
Defines the interface for Discovery callbacks into the Topic.
OPENDDS_STRING RepoKey
Definition: Discovery.h:80
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
static InfoRepoDiscovery::StaticInitializer initialize_inforepodisco
void bit_transport_ip(const std::string &ip)
sequence< string > StringSeq
Definition: DdsDcpsCore.idl:50