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 namespace OpenDDS {
00031 namespace DCPS {
00032 
00033 class FailoverListener;
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::AddDomainStatus add_domain_participant(
00086     DDS::DomainId_t domain,
00087     const DDS::DomainParticipantQos& qos);
00088 
00089   virtual bool remove_domain_participant(
00090     DDS::DomainId_t domainId,
00091     const OpenDDS::DCPS::RepoId& participantId);
00092 
00093   virtual bool ignore_domain_participant(
00094     DDS::DomainId_t domainId,
00095     const OpenDDS::DCPS::RepoId& myParticipantId,
00096     const OpenDDS::DCPS::RepoId& ignoreId);
00097 
00098   virtual bool update_domain_participant_qos(
00099     DDS::DomainId_t domain,
00100     const OpenDDS::DCPS::RepoId& participantId,
00101     const DDS::DomainParticipantQos& qos);
00102 
00103 
00104   // Topic operations:
00105 
00106   virtual OpenDDS::DCPS::TopicStatus assert_topic(
00107     OpenDDS::DCPS::RepoId_out topicId,
00108     DDS::DomainId_t domainId,
00109     const OpenDDS::DCPS::RepoId& participantId,
00110     const char* topicName,
00111     const char* dataTypeName,
00112     const DDS::TopicQos& qos,
00113     bool hasDcpsKey);
00114 
00115   virtual OpenDDS::DCPS::TopicStatus find_topic(
00116     DDS::DomainId_t domainId,
00117     const char* topicName,
00118     CORBA::String_out dataTypeName,
00119     DDS::TopicQos_out qos,
00120     OpenDDS::DCPS::RepoId_out topicId);
00121 
00122   virtual OpenDDS::DCPS::TopicStatus remove_topic(
00123     DDS::DomainId_t domainId,
00124     const OpenDDS::DCPS::RepoId& participantId,
00125     const OpenDDS::DCPS::RepoId& topicId);
00126 
00127   virtual bool ignore_topic(
00128     DDS::DomainId_t domainId,
00129     const OpenDDS::DCPS::RepoId& myParticipantId,
00130     const OpenDDS::DCPS::RepoId& ignoreId);
00131 
00132   virtual bool update_topic_qos(
00133     const OpenDDS::DCPS::RepoId& topicId,
00134     DDS::DomainId_t domainId,
00135     const OpenDDS::DCPS::RepoId& participantId,
00136     const DDS::TopicQos& qos);
00137 
00138 
00139   // Publication operations:
00140 
00141   virtual OpenDDS::DCPS::RepoId add_publication(
00142     DDS::DomainId_t domainId,
00143     const OpenDDS::DCPS::RepoId& participantId,
00144     const OpenDDS::DCPS::RepoId& topicId,
00145     OpenDDS::DCPS::DataWriterCallbacks* publication,
00146     const DDS::DataWriterQos& qos,
00147     const OpenDDS::DCPS::TransportLocatorSeq& transInfo,
00148     const DDS::PublisherQos& publisherQos);
00149 
00150   virtual bool remove_publication(
00151     DDS::DomainId_t domainId,
00152     const OpenDDS::DCPS::RepoId& participantId,
00153     const OpenDDS::DCPS::RepoId& publicationId);
00154 
00155   virtual bool ignore_publication(
00156     DDS::DomainId_t domainId,
00157     const OpenDDS::DCPS::RepoId& myParticipantId,
00158     const OpenDDS::DCPS::RepoId& ignoreId);
00159 
00160   virtual bool update_publication_qos(
00161     DDS::DomainId_t domainId,
00162     const OpenDDS::DCPS::RepoId& partId,
00163     const OpenDDS::DCPS::RepoId& dwId,
00164     const DDS::DataWriterQos& qos,
00165     const DDS::PublisherQos& publisherQos);
00166 
00167 
00168   // Subscription operations:
00169 
00170   virtual OpenDDS::DCPS::RepoId add_subscription(
00171     DDS::DomainId_t domainId,
00172     const OpenDDS::DCPS::RepoId& participantId,
00173     const OpenDDS::DCPS::RepoId& topicId,
00174     OpenDDS::DCPS::DataReaderCallbacks* subscription,
00175     const DDS::DataReaderQos& qos,
00176     const OpenDDS::DCPS::TransportLocatorSeq& transInfo,
00177     const DDS::SubscriberQos& subscriberQos,
00178     const char* filterClassName,
00179     const char* filterExpression,
00180     const DDS::StringSeq& exprParams);
00181 
00182   virtual bool remove_subscription(
00183     DDS::DomainId_t domainId,
00184     const OpenDDS::DCPS::RepoId& participantId,
00185     const OpenDDS::DCPS::RepoId& subscriptionId);
00186 
00187   virtual bool ignore_subscription(
00188     DDS::DomainId_t domainId,
00189     const OpenDDS::DCPS::RepoId& myParticipantId,
00190     const OpenDDS::DCPS::RepoId& ignoreId);
00191 
00192   virtual bool update_subscription_qos(
00193     DDS::DomainId_t domainId,
00194     const OpenDDS::DCPS::RepoId& partId,
00195     const OpenDDS::DCPS::RepoId& drId,
00196     const DDS::DataReaderQos& qos,
00197     const DDS::SubscriberQos& subscriberQos);
00198 
00199   virtual bool update_subscription_params(
00200     DDS::DomainId_t domainId,
00201     const OpenDDS::DCPS::RepoId& participantId,
00202     const OpenDDS::DCPS::RepoId& subscriptionId,
00203     const DDS::StringSeq& params);
00204 
00205 
00206   // Managing reader/writer associations:
00207 
00208   virtual void association_complete(
00209     DDS::DomainId_t domainId,
00210     const OpenDDS::DCPS::RepoId& participantId,
00211     const OpenDDS::DCPS::RepoId& localId,
00212     const OpenDDS::DCPS::RepoId& remoteId);
00213 
00214 private:
00215   TransportConfig_rch bit_config();
00216 
00217   void removeDataReaderRemote(const RepoId& subscriptionId);
00218 
00219   void removeDataWriterRemote(const RepoId& publicationId);
00220 
00221   std::string    ior_;
00222   DCPSInfo_var   info_;
00223 
00224   /// The builtin topic transport address.
00225   std::string bit_transport_ip_;
00226 
00227   /// The builtin topic transport port number.
00228   int bit_transport_port_;
00229 
00230   bool use_local_bit_config_;
00231   TransportConfig_rch bit_config_;
00232 
00233   /// Listener to initiate failover with.
00234   FailoverListener*    failoverListener_;
00235 
00236   CORBA::ORB_var orb_;
00237   bool orb_from_user_;
00238 
00239   struct OrbRunner : ACE_Task_Base {
00240     OrbRunner() {}
00241     int svc();
00242     void shutdown();
00243 
00244     CORBA::ORB_var orb_;
00245     ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> use_count_;
00246   private:
00247     OrbRunner(const OrbRunner&);
00248     OrbRunner& operator=(const OrbRunner&);
00249   };
00250 
00251   static OrbRunner* orb_runner_;
00252   static ACE_Thread_Mutex mtx_orb_runner_;
00253 
00254   typedef OPENDDS_MAP_CMP(RepoId, DataReaderRemote_var, DCPS::GUID_tKeyLessThan) DataReaderMap;
00255 
00256   DataReaderMap dataReaderMap_;
00257 
00258   typedef OPENDDS_MAP_CMP(RepoId, DataWriterRemote_var, DCPS::GUID_tKeyLessThan) DataWriterMap;
00259 
00260   DataWriterMap dataWriterMap_;
00261 
00262   mutable ACE_Thread_Mutex lock_;
00263 
00264 public:
00265   class Config : public Discovery::Config {
00266   public:
00267     int discovery_config(ACE_Configuration_Heap& cf);
00268   };
00269 
00270   class OpenDDS_InfoRepoDiscovery_Export StaticInitializer {
00271   public:
00272     StaticInitializer();
00273   };
00274 };
00275 
00276 typedef RcHandle<InfoRepoDiscovery> InfoRepoDiscovery_rch;
00277 
00278 static InfoRepoDiscovery::StaticInitializer initialize_inforepodisco;
00279 
00280 // Support loading this library using the ACE Service Configurator:
00281 // this is used by TransportRegistry (from Service_Participant).
00282 
00283 class OpenDDS_InfoRepoDiscovery_Export IRDiscoveryLoader
00284   : public ACE_Service_Object {
00285 public:
00286   virtual int init(int argc, ACE_TCHAR* argv[]);
00287 };
00288 
00289 ACE_STATIC_SVC_DECLARE_EXPORT(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
00290 ACE_FACTORY_DECLARE(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
00291 
00292 } // namespace DCPS
00293 } // namespace OpenDDS
00294 
00295 #endif /* OPENDDS_DCPS_INFOREPODISCOVERY_H  */

Generated on Fri Feb 12 20:05:23 2016 for OpenDDS by  doxygen 1.4.7