InfoRepoDiscovery.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DDS_DCPS_INFOREPODISCOVERY_H
00009 #define OPENDDS_DDS_DCPS_INFOREPODISCOVERY_H
00010 
00011 #include "dds/DCPS/Discovery.h"
00012 #include "dds/DdsDcpsInfoUtilsC.h"
00013 #include "dds/DCPS/GuidUtils.h"
00014 #include "dds/DCPS/InfoRepoDiscovery/DataReaderRemoteC.h"
00015 #include "dds/DCPS/InfoRepoDiscovery/InfoC.h"
00016 #include "dds/DCPS/transport/framework/TransportConfig_rch.h"
00017 
00018 #include "ace/Task.h"
00019 
00020 #include "InfoRepoDiscovery_Export.h"
00021 
00022 #include "ace/Thread_Mutex.h"
00023 
00024 #include <string>
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 #pragma once
00028 #endif /* ACE_LACKS_PRAGMA_ONCE */
00029 
00030 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 namespace OpenDDS {
00033 namespace DCPS {
00034 
00035 /**
00036  * @class InfoRepoDiscovery
00037  *
00038  * @brief Discovery Strategy class that implements InfoRepo discovery
00039  *
00040  * This class implements the Discovery interface for InfoRepo-based
00041  * discovery.
00042  *
00043  */
00044 class OpenDDS_InfoRepoDiscovery_Export InfoRepoDiscovery : public Discovery {
00045 public:
00046   InfoRepoDiscovery(const RepoKey& key, const std::string& ior);
00047   InfoRepoDiscovery(const RepoKey& key, const DCPSInfo_var& info);
00048 
00049   virtual ~InfoRepoDiscovery();
00050 
00051   std::string get_stringified_dcps_info_ior();
00052   DCPSInfo_var get_dcps_info();
00053 
00054   virtual bool active();
00055 
00056   int bit_transport_port() const { return bit_transport_port_; }
00057   void bit_transport_port(int port) {
00058     bit_transport_port_ = port;
00059     use_local_bit_config_ = true;
00060   }
00061 
00062   std::string bit_transport_ip() const { return bit_transport_ip_; }
00063   void bit_transport_ip(const std::string& ip) {
00064     bit_transport_ip_ = ip;
00065     use_local_bit_config_ = true;
00066   }
00067 
00068   /// User provides an ORB for OpenDDS to use.
00069   /// @note The user is responsible for running the ORB.
00070   /// @Returns true if the operation succeeds
00071   bool set_ORB(CORBA::ORB_ptr orb);
00072 
00073   virtual DDS::Subscriber_ptr init_bit(DomainParticipantImpl* participant);
00074 
00075   virtual void fini_bit(DCPS::DomainParticipantImpl* participant);
00076 
00077   virtual RepoId bit_key_to_repo_id(DomainParticipantImpl* participant,
00078                                     const char* bit_topic_name,
00079                                     const DDS::BuiltinTopicKey_t& key) const;
00080 
00081   virtual bool attach_participant(
00082     DDS::DomainId_t domainId,
00083     const OpenDDS::DCPS::RepoId& participantId);
00084 
00085   virtual OpenDDS::DCPS::RepoId generate_participant_guid();
00086 
00087   virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant(
00088     DDS::DomainId_t domain,
00089     const DDS::DomainParticipantQos& qos);
00090 
00091 #if defined(OPENDDS_SECURITY)
00092   virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant_secure(
00093     DDS::DomainId_t domain,
00094     const DDS::DomainParticipantQos& qos,
00095     const OpenDDS::DCPS::RepoId& guid,
00096     DDS::Security::IdentityHandle id,
00097     DDS::Security::PermissionsHandle perm,
00098     DDS::Security::ParticipantCryptoHandle part_crypto);
00099 #endif
00100 
00101   virtual bool remove_domain_participant(
00102     DDS::DomainId_t domainId,
00103     const OpenDDS::DCPS::RepoId& participantId);
00104 
00105   virtual bool ignore_domain_participant(
00106     DDS::DomainId_t domainId,
00107     const OpenDDS::DCPS::RepoId& myParticipantId,
00108     const OpenDDS::DCPS::RepoId& ignoreId);
00109 
00110   virtual bool update_domain_participant_qos(
00111     DDS::DomainId_t domain,
00112     const OpenDDS::DCPS::RepoId& participantId,
00113     const DDS::DomainParticipantQos& qos);
00114 
00115 
00116   // Topic operations:
00117 
00118   virtual OpenDDS::DCPS::TopicStatus assert_topic(
00119     OpenDDS::DCPS::RepoId_out topicId,
00120     DDS::DomainId_t domainId,
00121     const OpenDDS::DCPS::RepoId& participantId,
00122     const char* topicName,
00123     const char* dataTypeName,
00124     const DDS::TopicQos& qos,
00125     bool hasDcpsKey);
00126 
00127   virtual OpenDDS::DCPS::TopicStatus find_topic(
00128     DDS::DomainId_t domainId,
00129     const char* topicName,
00130     CORBA::String_out dataTypeName,
00131     DDS::TopicQos_out qos,
00132     OpenDDS::DCPS::RepoId_out topicId);
00133 
00134   virtual OpenDDS::DCPS::TopicStatus remove_topic(
00135     DDS::DomainId_t domainId,
00136     const OpenDDS::DCPS::RepoId& participantId,
00137     const OpenDDS::DCPS::RepoId& topicId);
00138 
00139   virtual bool ignore_topic(
00140     DDS::DomainId_t domainId,
00141     const OpenDDS::DCPS::RepoId& myParticipantId,
00142     const OpenDDS::DCPS::RepoId& ignoreId);
00143 
00144   virtual bool update_topic_qos(
00145     const OpenDDS::DCPS::RepoId& topicId,
00146     DDS::DomainId_t domainId,
00147     const OpenDDS::DCPS::RepoId& participantId,
00148     const DDS::TopicQos& qos);
00149 
00150 
00151   // Publication operations:
00152 
00153   virtual OpenDDS::DCPS::RepoId add_publication(
00154     DDS::DomainId_t domainId,
00155     const OpenDDS::DCPS::RepoId& participantId,
00156     const OpenDDS::DCPS::RepoId& topicId,
00157     OpenDDS::DCPS::DataWriterCallbacks* publication,
00158     const DDS::DataWriterQos& qos,
00159     const OpenDDS::DCPS::TransportLocatorSeq& transInfo,
00160     const DDS::PublisherQos& publisherQos);
00161 
00162   virtual bool remove_publication(
00163     DDS::DomainId_t domainId,
00164     const OpenDDS::DCPS::RepoId& participantId,
00165     const OpenDDS::DCPS::RepoId& publicationId);
00166 
00167   virtual bool ignore_publication(
00168     DDS::DomainId_t domainId,
00169     const OpenDDS::DCPS::RepoId& myParticipantId,
00170     const OpenDDS::DCPS::RepoId& ignoreId);
00171 
00172   virtual bool update_publication_qos(
00173     DDS::DomainId_t domainId,
00174     const OpenDDS::DCPS::RepoId& partId,
00175     const OpenDDS::DCPS::RepoId& dwId,
00176     const DDS::DataWriterQos& qos,
00177     const DDS::PublisherQos& publisherQos);
00178 
00179 
00180   // Subscription operations:
00181 
00182   virtual OpenDDS::DCPS::RepoId add_subscription(
00183     DDS::DomainId_t domainId,
00184     const OpenDDS::DCPS::RepoId& participantId,
00185     const OpenDDS::DCPS::RepoId& topicId,
00186     OpenDDS::DCPS::DataReaderCallbacks* subscription,
00187     const DDS::DataReaderQos& qos,
00188     const OpenDDS::DCPS::TransportLocatorSeq& transInfo,
00189     const DDS::SubscriberQos& subscriberQos,
00190     const char* filterClassName,
00191     const char* filterExpression,
00192     const DDS::StringSeq& exprParams);
00193 
00194   virtual bool remove_subscription(
00195     DDS::DomainId_t domainId,
00196     const OpenDDS::DCPS::RepoId& participantId,
00197     const OpenDDS::DCPS::RepoId& subscriptionId);
00198 
00199   virtual bool ignore_subscription(
00200     DDS::DomainId_t domainId,
00201     const OpenDDS::DCPS::RepoId& myParticipantId,
00202     const OpenDDS::DCPS::RepoId& ignoreId);
00203 
00204   virtual bool update_subscription_qos(
00205     DDS::DomainId_t domainId,
00206     const OpenDDS::DCPS::RepoId& partId,
00207     const OpenDDS::DCPS::RepoId& drId,
00208     const DDS::DataReaderQos& qos,
00209     const DDS::SubscriberQos& subscriberQos);
00210 
00211   virtual bool update_subscription_params(
00212     DDS::DomainId_t domainId,
00213     const OpenDDS::DCPS::RepoId& participantId,
00214     const OpenDDS::DCPS::RepoId& subscriptionId,
00215     const DDS::StringSeq& params);
00216 
00217 
00218   // Managing reader/writer associations:
00219 
00220   virtual void association_complete(
00221     DDS::DomainId_t domainId,
00222     const OpenDDS::DCPS::RepoId& participantId,
00223     const OpenDDS::DCPS::RepoId& localId,
00224     const OpenDDS::DCPS::RepoId& remoteId);
00225 
00226 private:
00227   TransportConfig_rch bit_config();
00228 
00229   void removeDataReaderRemote(const RepoId& subscriptionId);
00230 
00231   void removeDataWriterRemote(const RepoId& publicationId);
00232 
00233   std::string    ior_;
00234   DCPSInfo_var   info_;
00235 
00236   /// The builtin topic transport address.
00237   std::string bit_transport_ip_;
00238 
00239   /// The builtin topic transport port number.
00240   int bit_transport_port_;
00241 
00242   bool use_local_bit_config_;
00243   TransportConfig_rch bit_config_;
00244 
00245   CORBA::ORB_var orb_;
00246   bool orb_from_user_;
00247 
00248   struct OrbRunner : ACE_Task_Base {
00249     OrbRunner() {}
00250     int svc();
00251     void shutdown();
00252 
00253     CORBA::ORB_var orb_;
00254     ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> use_count_;
00255   private:
00256     OrbRunner(const OrbRunner&);
00257     OrbRunner& operator=(const OrbRunner&);
00258   };
00259 
00260   static OrbRunner* orb_runner_;
00261   static ACE_Thread_Mutex mtx_orb_runner_;
00262 
00263   typedef OPENDDS_MAP_CMP(RepoId, DataReaderRemote_var, DCPS::GUID_tKeyLessThan) DataReaderMap;
00264 
00265   DataReaderMap dataReaderMap_;
00266 
00267   typedef OPENDDS_MAP_CMP(RepoId, DataWriterRemote_var, DCPS::GUID_tKeyLessThan) DataWriterMap;
00268 
00269   DataWriterMap dataWriterMap_;
00270 
00271   mutable ACE_Thread_Mutex lock_;
00272 
00273 public:
00274   class Config : public Discovery::Config {
00275   public:
00276     int discovery_config(ACE_Configuration_Heap& cf);
00277   };
00278 
00279   class OpenDDS_InfoRepoDiscovery_Export StaticInitializer {
00280   public:
00281     StaticInitializer();
00282   };
00283 };
00284 
00285 typedef RcHandle<InfoRepoDiscovery> InfoRepoDiscovery_rch;
00286 
00287 static InfoRepoDiscovery::StaticInitializer initialize_inforepodisco;
00288 
00289 // Support loading this library using the ACE Service Configurator:
00290 // this is used by TransportRegistry (from Service_Participant).
00291 
00292 class OpenDDS_InfoRepoDiscovery_Export IRDiscoveryLoader
00293   : public ACE_Service_Object {
00294 public:
00295   virtual int init(int argc, ACE_TCHAR* argv[]);
00296 };
00297 
00298 ACE_STATIC_SVC_DECLARE_EXPORT(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
00299 ACE_FACTORY_DECLARE(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
00300 
00301 } // namespace DCPS
00302 } // namespace OpenDDS
00303 
00304 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00305 
00306 #endif /* OPENDDS_DCPS_INFOREPODISCOVERY_H  */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1