00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #ifndef OPENDDS_DCPS_TRANSPORTINST_H 00009 #define OPENDDS_DCPS_TRANSPORTINST_H 00010 00011 #include <ace/config.h> 00012 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00013 #pragma once 00014 #endif 00015 00016 #include "dds/DCPS/dcps_export.h" 00017 #include "dds/DCPS/RcObject.h" 00018 #include "dds/DCPS/PoolAllocator.h" 00019 #include "TransportDefs.h" 00020 #include "TransportImpl_rch.h" 00021 #include "TransportImpl.h" 00022 #include "ace/Synch_Traits.h" 00023 00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00025 class ACE_Configuration_Heap; 00026 class ACE_Configuration_Section_Key; 00027 ACE_END_VERSIONED_NAMESPACE_DECL 00028 00029 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 namespace OpenDDS { 00032 namespace DCPS { 00033 00034 /** 00035 * @class TransportInst 00036 * 00037 * @brief Base class to hold configuration settings for TransportImpls. 00038 * 00039 * Each transport implementation will need to define a concrete 00040 * subclass of the TransportInst class. The base 00041 * class (TransportInst) contains configuration settings that 00042 * are common to all (or most) concrete transport implementations. 00043 * The concrete transport implementation defines any configuration 00044 * settings that it requires within its concrete subclass of this 00045 * TransportInst base class. 00046 * 00047 * The TransportInst object is supplied to the 00048 * TransportImpl::configure() method. 00049 */ 00050 class OpenDDS_Dcps_Export TransportInst : public RcObject { 00051 public: 00052 00053 const OPENDDS_STRING& name() const { return name_; } 00054 00055 /// Overwrite the default configurations with the configuration from the 00056 /// given section in the ACE_Configuration_Heap object. 00057 virtual int load(ACE_Configuration_Heap& cf, 00058 ACE_Configuration_Section_Key& sect); 00059 00060 /// Diagnostic aid. 00061 void dump() const; 00062 virtual OPENDDS_STRING dump_to_str() const; 00063 00064 /// Format name of transport configuration parameter for use in 00065 /// conjunction with dump(std::ostream& os). 00066 static OPENDDS_STRING formatNameForDump(const char* name); 00067 00068 const OPENDDS_STRING transport_type_; 00069 00070 /// Number of pre-created link (list) objects per pool for the 00071 /// "send queue" of each DataLink. 00072 size_t queue_messages_per_pool_; 00073 00074 /// Initial number of pre-allocated pools of link (list) objects 00075 /// for the "send queue" of each DataLink. 00076 size_t queue_initial_pools_; 00077 00078 /// Max size (in bytes) of a packet (packet header + sample(s)) 00079 ACE_UINT32 max_packet_size_; 00080 00081 /// Max number of samples that should ever be in a single packet. 00082 size_t max_samples_per_packet_; 00083 00084 /// Optimum size (in bytes) of a packet (packet header + sample(s)). 00085 ACE_UINT32 optimum_packet_size_; 00086 00087 /// Flag for whether a new thread is needed for connection to 00088 /// send without backpressure. 00089 bool thread_per_connection_; 00090 00091 /// Delay in milliseconds that the datalink should be released after all 00092 /// associations are removed. The default value is 10 seconds. 00093 long datalink_release_delay_; 00094 00095 /// The number of chunks used to size allocators for transport control 00096 /// samples. The default value is 32. 00097 size_t datalink_control_chunks_; 00098 00099 /// Does the transport as configured support RELIABLE_RELIABILITY_QOS? 00100 virtual bool is_reliable() const = 0; 00101 00102 /// Does the transport require a CDR-encapsulated data payload? 00103 virtual bool requires_cdr() const { return false; } 00104 00105 /// Populate a transport locator sequence. Return the number of "locators." 00106 virtual size_t populate_locator(OpenDDS::DCPS::TransportLocator& trans_info) const = 0; 00107 00108 protected: 00109 00110 TransportInst(const char* type, 00111 const OPENDDS_STRING& name); 00112 00113 virtual ~TransportInst(); 00114 00115 void set_port_in_addr_string(OPENDDS_STRING& addr_str, u_short port_number); 00116 00117 private: 00118 00119 /// Adjust the configuration values which gives warning on adjusted 00120 /// value. 00121 void adjust_config_value(); 00122 00123 friend class TransportRegistry; 00124 void shutdown(); 00125 00126 friend class TransportClient; 00127 TransportImpl* impl(); 00128 virtual TransportImpl_rch new_impl() = 0; 00129 00130 const OPENDDS_STRING name_; 00131 00132 TransportImpl_rch impl_; 00133 ACE_SYNCH_MUTEX lock_; 00134 }; 00135 00136 } // namespace DCPS 00137 } // namespace OpenDDS 00138 00139 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00140 00141 #if defined(__ACE_INLINE__) 00142 #include "TransportInst.inl" 00143 #endif /* __ACE_INLINE__ */ 00144 00145 #endif