TransportRegistry.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_DCPS_TRANSPORTREGISTRY_H
00009 #define OPENDDS_DCPS_TRANSPORTREGISTRY_H
00010 
00011 #include "dds/DCPS/dcps_export.h"
00012 #include "TransportDefs.h"
00013 #include "TransportImpl_rch.h"
00014 #include "TransportReactorTask_rch.h"
00015 #include "TransportType.h"
00016 #include "TransportType_rch.h"
00017 #include "TransportInst_rch.h"
00018 #include "TransportConfig_rch.h"
00019 #include "TransportConfig.h"
00020 #include "dds/DCPS/PoolAllocator.h"
00021 #include "ace/Synch_Traits.h"
00022 
00023 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00024 class ACE_Configuration_Heap;
00025 ACE_END_VERSIONED_NAMESPACE_DECL
00026 
00027 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 namespace DDS {
00030   class Entity;
00031   typedef Entity* Entity_ptr;
00032 }
00033 
00034 #define TheTransportRegistry OpenDDS::DCPS::TransportRegistry::instance()
00035 
00036 namespace OpenDDS {
00037 namespace DCPS {
00038 
00039 /**
00040  * The TransportRegistry is a singleton object which provides a mechanism to
00041  * the application code to configure OpenDDS's use of the transport layer.
00042  */
00043 class OpenDDS_Dcps_Export TransportRegistry {
00044 public:
00045 
00046   /// Return a singleton instance of this class.
00047   static TransportRegistry* instance();
00048 
00049   /// Close the singleton instance of this class.
00050   static void close();
00051 
00052   /// This will shutdown all TransportImpl objects.
00053   ///
00054   /// Client Application calls this method to tear down the transport
00055   /// framework.
00056   void release();
00057 
00058   TransportInst_rch create_inst(const OPENDDS_STRING& name,
00059                                 const OPENDDS_STRING& transport_type);
00060   TransportInst_rch get_inst(const OPENDDS_STRING& name) const;
00061   void remove_inst(const TransportInst_rch& inst);
00062 
00063   static const char DEFAULT_CONFIG_NAME[];
00064   static const char DEFAULT_INST_PREFIX[];
00065 
00066   TransportConfig_rch create_config(const OPENDDS_STRING& name);
00067   TransportConfig_rch get_config(const OPENDDS_STRING& name) const;
00068   void remove_config(const TransportConfig_rch& cfg);
00069 
00070   TransportConfig_rch global_config() const;
00071   void global_config(const TransportConfig_rch& cfg);
00072 
00073   void domain_default_config(DDS::DomainId_t domain,
00074                              const TransportConfig_rch& cfg);
00075   TransportConfig_rch domain_default_config(DDS::DomainId_t domain) const;
00076 
00077   void bind_config(const OPENDDS_STRING& name, DDS::Entity_ptr entity);
00078   void bind_config(const TransportConfig_rch& cfg, DDS::Entity_ptr entity);
00079 
00080   /// SPI (Service Provider Interface) for specific transport types:
00081   /// This function is called as the concrete transport library is loaded.
00082   /// The concrete transport library creates a concrete transport type object
00083   /// and registers it with TransportRegistry singleton.
00084   void register_type(const TransportType_rch& type);
00085 
00086   /// For internal use by OpenDDS DCPS layer:
00087   /// Transfer the configuration in ACE_Configuration_Heap object to
00088   /// the TransportRegistry.  This is called by the Service_Participant
00089   /// at initialization time. This function iterates each section in
00090   /// the configuration file, and creates TransportInst and
00091   /// TransportConfig objects and adds them to the registry.
00092   int load_transport_configuration(const OPENDDS_STRING& file_name,
00093                                    ACE_Configuration_Heap& cf);
00094 
00095   /// For internal use by OpenDDS DCPS layer:
00096   /// If the default config is empty when it's about to be used, allow the
00097   /// TransportRegistry to attempt to load a fallback option.
00098   TransportConfig_rch fix_empty_default();
00099 
00100   /// For internal use by OpenDDS DCPS layer:
00101   /// Dynamically load the library for the supplied transport type.
00102   void load_transport_lib(const OPENDDS_STRING& transport_type);
00103 
00104   bool released() const;
00105 
00106 private:
00107   friend class ACE_Singleton<TransportRegistry, ACE_Recursive_Thread_Mutex>;
00108 
00109   TransportRegistry();
00110   ~TransportRegistry();
00111 
00112   typedef OPENDDS_MAP(OPENDDS_STRING, TransportType_rch) TypeMap;
00113   typedef OPENDDS_MAP(OPENDDS_STRING, TransportConfig_rch) ConfigMap;
00114   typedef OPENDDS_MAP(OPENDDS_STRING, TransportInst_rch) InstMap;
00115   typedef OPENDDS_MAP(OPENDDS_STRING, OPENDDS_STRING) LibDirectiveMap;
00116   typedef OPENDDS_MAP(DDS::DomainId_t, TransportConfig_rch) DomainConfigMap;
00117 
00118   typedef ACE_SYNCH_MUTEX LockType;
00119   typedef ACE_Guard<LockType> GuardType;
00120 
00121   TypeMap type_map_;
00122   ConfigMap config_map_;
00123   InstMap inst_map_;
00124   LibDirectiveMap lib_directive_map_;
00125   DomainConfigMap domain_default_config_map_;
00126 
00127   TransportConfig_rch global_config_;
00128   bool released_;
00129 
00130   mutable LockType lock_;
00131 };
00132 
00133 } // namespace DCPS
00134 } // namespace OpenDDS
00135 
00136 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00137 
00138 #if defined (__ACE_INLINE__)
00139 #include "TransportRegistry.inl"
00140 #endif /* __ACE_INLINE__ */
00141 
00142 #endif  /* OPENDDS_DCPS_TRANSPORTREGISTRY_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1