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

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