Line data Source code
1 : /*
2 : * Distributed under the OpenDDS License.
3 : * See: http://www.opendds.org/license.html
4 : */
5 :
6 : #ifndef OPENDDS_DCPS_DISCOVERY_H
7 : #define OPENDDS_DCPS_DISCOVERY_H
8 :
9 : #include "RcObject.h"
10 : #include "RcHandle_T.h"
11 : #include "unique_ptr.h"
12 : #include "XTypes/TypeObject.h"
13 : #include "XTypes/TypeLookupService.h"
14 : #include "DataReaderCallbacks.h"
15 : #include "DataWriterCallbacks.h"
16 : #include "TopicCallbacks.h"
17 : #include "PoolAllocator.h"
18 : #include "PoolAllocationBase.h"
19 : #include "ConditionVariable.h"
20 :
21 : #include <dds/DdsDcpsInfoUtilsC.h>
22 : #include <dds/DdsDcpsSubscriptionC.h>
23 : #ifdef OPENDDS_SECURITY
24 : # include <dds/DdsSecurityCoreC.h>
25 : #endif
26 :
27 : #ifndef ACE_LACKS_PRAGMA_ONCE
28 : # pragma once
29 : #endif
30 :
31 : ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 : class ACE_Configuration_Heap;
33 : ACE_END_VERSIONED_NAMESPACE_DECL
34 :
35 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
36 :
37 : namespace OpenDDS {
38 : namespace DCPS {
39 :
40 : class DomainParticipantImpl;
41 : class DataWriterImpl;
42 : class DataReaderImpl;
43 : class BitSubscriber;
44 :
45 : /**
46 : * This is used by get_dynamic_type on the service participant to wait for a
47 : * TypeObject request to complete.
48 : */
49 : struct OpenDDS_Dcps_Export TypeObjReqCond {
50 : typedef ACE_Thread_Mutex LockType;
51 : LockType lock;
52 : ConditionVariable<LockType> cond;
53 : bool waiting;
54 : DDS::ReturnCode_t rc;
55 :
56 0 : TypeObjReqCond()
57 0 : : cond(lock)
58 0 : , waiting(true)
59 0 : , rc(DDS::RETCODE_OK)
60 : {
61 0 : }
62 :
63 : DDS::ReturnCode_t wait();
64 : void done(DDS::ReturnCode_t retcode);
65 : };
66 :
67 : /**
68 : * @class Discovery
69 : *
70 : * @brief Discovery Strategy interface class
71 : *
72 : * This class is an abstract class that acts as an interface for both
73 : * InfoRepo-based discovery and RTPS Discovery.
74 : *
75 : */
76 : class OpenDDS_Dcps_Export Discovery : public virtual RcObject {
77 : public:
78 : /// Key type for storing discovery objects.
79 : /// Probably should just be Discovery::Key
80 : typedef OPENDDS_STRING RepoKey;
81 :
82 1 : explicit Discovery(const RepoKey& key) : key_(key) { }
83 :
84 : /// Key value for the default repository IOR.
85 : static const char* DEFAULT_REPO;
86 : static const char* DEFAULT_RTPS;
87 : static const char* DEFAULT_STATIC;
88 :
89 : // TODO: NEED TO REMOVE THIS once Service_Participant::repository_lost has been refactored
90 0 : virtual bool active() { return true; }
91 :
92 : virtual RcHandle<BitSubscriber> init_bit(DomainParticipantImpl* participant) = 0;
93 :
94 : virtual void fini_bit(DCPS::DomainParticipantImpl* participant) = 0;
95 :
96 0 : RepoKey key() const { return this->key_; }
97 :
98 : class OpenDDS_Dcps_Export Config
99 : : public PoolAllocationBase
100 : , public EnableContainerSupportedUniquePtr<Config> {
101 : public:
102 : virtual ~Config();
103 : virtual int discovery_config(ACE_Configuration_Heap& cf) = 0;
104 : };
105 :
106 : virtual bool attach_participant(
107 : DDS::DomainId_t domainId,
108 : const GUID_t& participantId) = 0;
109 :
110 : virtual OpenDDS::DCPS::GUID_t generate_participant_guid() = 0;
111 :
112 : virtual AddDomainStatus add_domain_participant(
113 : DDS::DomainId_t domain,
114 : const DDS::DomainParticipantQos& qos,
115 : XTypes::TypeLookupService_rch tls) = 0;
116 :
117 : #if defined(OPENDDS_SECURITY)
118 : virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant_secure(
119 : DDS::DomainId_t domain,
120 : const DDS::DomainParticipantQos& qos,
121 : XTypes::TypeLookupService_rch tls,
122 : const OpenDDS::DCPS::GUID_t& guid,
123 : DDS::Security::IdentityHandle id,
124 : DDS::Security::PermissionsHandle perm,
125 : DDS::Security::ParticipantCryptoHandle part_crypto) = 0;
126 : #endif
127 :
128 : virtual bool remove_domain_participant(
129 : DDS::DomainId_t domainId,
130 : const GUID_t& participantId) = 0;
131 :
132 : virtual bool ignore_domain_participant(
133 : DDS::DomainId_t domainId,
134 : const GUID_t& myParticipantId,
135 : const GUID_t& ignoreId) = 0;
136 :
137 : virtual bool update_domain_participant_qos(
138 : DDS::DomainId_t domain,
139 : const GUID_t& participantId,
140 : const DDS::DomainParticipantQos& qos) = 0;
141 :
142 :
143 : // Topic operations:
144 :
145 : virtual TopicStatus assert_topic(
146 : GUID_t_out topicId,
147 : DDS::DomainId_t domainId,
148 : const GUID_t& participantId,
149 : const char* topicName,
150 : const char* dataTypeName,
151 : const DDS::TopicQos& qos,
152 : bool hasDcpsKey,
153 : TopicCallbacks* topic_callbacks) = 0;
154 :
155 : virtual TopicStatus find_topic(
156 : DDS::DomainId_t domainId,
157 : const GUID_t& participantId,
158 : const char* topicName,
159 : CORBA::String_out dataTypeName,
160 : DDS::TopicQos_out qos,
161 : GUID_t_out topicId) = 0;
162 :
163 : virtual TopicStatus remove_topic(
164 : DDS::DomainId_t domainId,
165 : const GUID_t& participantId,
166 : const GUID_t& topicId) = 0;
167 :
168 : virtual bool ignore_topic(
169 : DDS::DomainId_t domainId,
170 : const GUID_t& myParticipantId,
171 : const GUID_t& ignoreId) = 0;
172 :
173 : virtual bool update_topic_qos(
174 : const GUID_t& topicId,
175 : DDS::DomainId_t domainId,
176 : const GUID_t& participantId,
177 : const DDS::TopicQos& qos) = 0;
178 :
179 :
180 : // Publication operations:
181 :
182 0 : virtual void pre_writer(DataWriterImpl*) {}
183 :
184 : /// add the passed in publication into discovery.
185 : /// Discovery does not participate in memory management
186 : /// for the publication pointer, so it requires that
187 : /// the publication pointer remain valid until
188 : /// remove_publication is called.
189 : virtual GUID_t add_publication(
190 : DDS::DomainId_t domainId,
191 : const GUID_t& participantId,
192 : const GUID_t& topicId,
193 : DataWriterCallbacks_rch publication,
194 : const DDS::DataWriterQos& qos,
195 : const TransportLocatorSeq& transInfo,
196 : const DDS::PublisherQos& publisherQos,
197 : const XTypes::TypeInformation& type_info) = 0;
198 :
199 : virtual bool remove_publication(
200 : DDS::DomainId_t domainId,
201 : const GUID_t& participantId,
202 : const GUID_t& publicationId) = 0;
203 :
204 : virtual bool ignore_publication(
205 : DDS::DomainId_t domainId,
206 : const GUID_t& myParticipantId,
207 : const GUID_t& ignoreId) = 0;
208 :
209 : virtual bool update_publication_qos(
210 : DDS::DomainId_t domainId,
211 : const GUID_t& partId,
212 : const GUID_t& dwId,
213 : const DDS::DataWriterQos& qos,
214 : const DDS::PublisherQos& publisherQos) = 0;
215 :
216 : virtual void update_publication_locators(
217 : DDS::DomainId_t domainId,
218 : const GUID_t& partId,
219 : const GUID_t& dwId,
220 : const TransportLocatorSeq& transInfo);
221 :
222 : // Subscription operations:
223 :
224 0 : virtual void pre_reader(DataReaderImpl*) {}
225 :
226 : /// add the passed in subscription into discovery.
227 : /// Discovery does not participate in memory management
228 : /// for the subscription pointer, so it requires that
229 : /// the subscription pointer remain valid until
230 : /// remove_subscription is called.
231 : virtual GUID_t add_subscription(
232 : DDS::DomainId_t domainId,
233 : const GUID_t& participantId,
234 : const GUID_t& topicId,
235 : DataReaderCallbacks_rch subscription,
236 : const DDS::DataReaderQos& qos,
237 : const TransportLocatorSeq& transInfo,
238 : const DDS::SubscriberQos& subscriberQos,
239 : const char* filterClassName,
240 : const char* filterExpression,
241 : const DDS::StringSeq& exprParams,
242 : const XTypes::TypeInformation& type_info) = 0;
243 :
244 : virtual bool remove_subscription(
245 : DDS::DomainId_t domainId,
246 : const GUID_t& participantId,
247 : const GUID_t& subscriptionId) = 0;
248 :
249 : virtual bool ignore_subscription(
250 : DDS::DomainId_t domainId,
251 : const GUID_t& myParticipantId,
252 : const GUID_t& ignoreId) = 0;
253 :
254 : virtual bool update_subscription_qos(
255 : DDS::DomainId_t domainId,
256 : const GUID_t& partId,
257 : const GUID_t& drId,
258 : const DDS::DataReaderQos& qos,
259 : const DDS::SubscriberQos& subscriberQos) = 0;
260 :
261 : virtual bool update_subscription_params(
262 : DDS::DomainId_t domainId,
263 : const GUID_t& participantId,
264 : const GUID_t& subscriptionId,
265 : const DDS::StringSeq& params) = 0;
266 :
267 : virtual void update_subscription_locators(
268 : DDS::DomainId_t domainId,
269 : const GUID_t& partId,
270 : const GUID_t& drId,
271 : const TransportLocatorSeq& transInfo);
272 :
273 : // Managing reader/writer associations:
274 :
275 0 : virtual bool supports_liveliness() const { return false; }
276 :
277 0 : virtual void signal_liveliness(const DDS::DomainId_t /*domain_id*/,
278 : const GUID_t& /*part_id*/,
279 0 : DDS::LivelinessQosPolicyKind /*kind*/) { }
280 :
281 0 : virtual void request_remote_complete_type_objects(
282 : DDS::DomainId_t /*domain*/, const GUID_t& /*local_participant*/,
283 : const GUID_t& /*remote_entity*/, const XTypes::TypeInformation& /*remote_type_info*/,
284 : TypeObjReqCond& cond)
285 : {
286 0 : cond.done(DDS::RETCODE_UNSUPPORTED);
287 0 : }
288 :
289 : protected:
290 : DDS::ReturnCode_t create_bit_topics(DomainParticipantImpl* participant);
291 :
292 : private:
293 : RepoKey key_;
294 : };
295 :
296 : typedef RcHandle<Discovery> Discovery_rch;
297 :
298 : } // namespace DCPS
299 : } // namespace OpenDDS
300 :
301 : OPENDDS_END_VERSIONED_NAMESPACE_DECL
302 :
303 : #endif /* OPENDDS_DCPS_DISCOVERY_H */
|