TransportDefs.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_TRANSPORTDEFS_H
00009 #define OPENDDS_DCPS_TRANSPORTDEFS_H
00010 
00011 #include "dds/DCPS/Definitions.h"
00012 #include "dds/DCPS/Cached_Allocator_With_Overflow_T.h"
00013 #include "dds/DCPS/debug.h"
00014 #include "ace/Basic_Types.h"
00015 #include "ace/CDR_Base.h"
00016 #include "ace/Synch_Traits.h"
00017 #include "TransportDebug.h"
00018 
00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00020 class ACE_Message_Block;
00021 class ACE_Data_Block;
00022 ACE_END_VERSIONED_NAMESPACE_DECL
00023 
00024 /**
00025  * Guard the allocations for the underlying memory management of the
00026  * receive processing with the following:
00027  *
00028  * Notice that even we have only one thread for receiving per transport, the underly message blocks
00029  * would interact with the threads from EndHistoricSamplesMissedSweeper which are different from the
00030  * receiving threads. Therefore, we cannot use ACE_SYNCH_NULL_MUTEX here.
00031  */
00032 #define RECEIVE_SYNCH ACE_SYNCH_MUTEX
00033 
00034 /// Macro to get the individual configuration value
00035 ///  from ACE_Configuration_Heap and cast to the specific
00036 ///  type from integer.
00037 #define GET_CONFIG_VALUE(CF, SECT, KEY, VALUE, TYPE)                             \
00038   {                                                                              \
00039     ACE_TString stringvalue;                                                     \
00040     if (CF.get_string_value (SECT, KEY, stringvalue) == -1)                      \
00041     {                                                                            \
00042       if (OpenDDS::DCPS::Transport_debug_level > 0)                            \
00043       {                                                                          \
00044         ACE_DEBUG ((LM_NOTICE,                                                   \
00045                     ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ")\
00046                     ACE_TEXT ("file - using code default.\n"),                   \
00047                     KEY));                                                       \
00048       }                                                                          \
00049     }                                                                            \
00050     else  if (stringvalue == ACE_TEXT(""))                                       \
00051     {                                                                            \
00052       if (OpenDDS::DCPS::Transport_debug_level > 0)                            \
00053       {                                                                          \
00054         ACE_DEBUG ((LM_WARNING,                                                  \
00055                     ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ")   \
00056                     ACE_TEXT ("file, but is missing value - using code default.\n"), \
00057                     KEY));                                                       \
00058       }                                                                          \
00059     }                                                                            \
00060     else                                                                         \
00061     {                                                                            \
00062       VALUE = static_cast<TYPE>(ACE_OS::atoi (stringvalue.c_str ()));            \
00063     }                                                                            \
00064   }
00065 
00066 /// Macro to get the individual configuration value
00067 ///  from ACE_Configuration_Heap as string type.
00068 #define GET_CONFIG_STRING_VALUE(CF, SECT, KEY, VALUE)                            \
00069   {                                                                              \
00070     ACE_TString stringvalue;                                                     \
00071     if (CF.get_string_value (SECT, KEY, stringvalue) == -1)                      \
00072     {                                                                            \
00073       if (OpenDDS::DCPS::Transport_debug_level > 0)                              \
00074       {                                                                          \
00075         ACE_DEBUG ((LM_NOTICE,                                                   \
00076                     ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ") \
00077                     ACE_TEXT ("file - using code default.\n"),                   \
00078                     KEY));                                                       \
00079       }                                                                          \
00080     }                                                                            \
00081     else if (stringvalue == ACE_TEXT(""))                                       \
00082     {                                                                            \
00083       if (OpenDDS::DCPS::Transport_debug_level > 0)                            \
00084       {                                                                          \
00085         ACE_DEBUG ((LM_WARNING,                                                  \
00086                     ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ")   \
00087                     ACE_TEXT ("file, but is missing value - using code default.\n"), \
00088                     KEY));                                                       \
00089       }                                                                          \
00090     }                                                                            \
00091     else                                                                         \
00092     {                                                                            \
00093       VALUE = ACE_TEXT_ALWAYS_CHAR(stringvalue.c_str());                         \
00094     }                                                                            \
00095   }
00096 
00097 #define GET_CONFIG_TSTRING_VALUE(CF, SECT, KEY, VALUE)                           \
00098   {                                                                              \
00099     ACE_TString stringvalue;                                                     \
00100     if (CF.get_string_value (SECT, KEY, stringvalue) == -1)                      \
00101     {                                                                            \
00102       if (OpenDDS::DCPS::Transport_debug_level > 0)                              \
00103       {                                                                          \
00104         ACE_DEBUG ((LM_NOTICE,                                                   \
00105                     ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ") \
00106                     ACE_TEXT ("file - using code default.\n"),                   \
00107                     KEY));                                                       \
00108       }                                                                          \
00109     }                                                                            \
00110     else if (stringvalue == ACE_TEXT(""))                                        \
00111     {                                                                            \
00112       if (OpenDDS::DCPS::Transport_debug_level > 0)                              \
00113       {                                                                          \
00114         ACE_DEBUG ((LM_WARNING,                                                  \
00115                     ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ")   \
00116                     ACE_TEXT ("file, but is missing value - using code default.\n"), \
00117                     KEY));                                                       \
00118       }                                                                          \
00119     }                                                                            \
00120     else                                                                         \
00121     {                                                                            \
00122       VALUE = stringvalue;                                                       \
00123     }                                                                            \
00124   }
00125 
00126 #define GET_CONFIG_DOUBLE_VALUE(CF, SECT, KEY, VALUE)                            \
00127   {                                                                              \
00128     ACE_TString stringvalue;                                                     \
00129     if (CF.get_string_value (SECT, KEY, stringvalue) == -1)                      \
00130     {                                                                            \
00131       if (OpenDDS::DCPS::Transport_debug_level > 0)                            \
00132       {                                                                          \
00133         ACE_DEBUG ((LM_NOTICE,                                                   \
00134                     ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ") \
00135                     ACE_TEXT ("file - using code default.\n"),                   \
00136                     KEY));                                                       \
00137       }                                                                          \
00138     }                                                                            \
00139     else  if (stringvalue == ACE_TEXT(""))                                       \
00140     {                                                                            \
00141       if (OpenDDS::DCPS::Transport_debug_level > 0)                            \
00142       {                                                                          \
00143         ACE_DEBUG ((LM_WARNING,                                                  \
00144                     ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ")   \
00145                     ACE_TEXT ("file, but is missing value - using code default.\n"), \
00146                     KEY));                                                       \
00147       }                                                                          \
00148     }                                                                            \
00149     else                                                                         \
00150     {                                                                            \
00151       VALUE = ACE_OS::strtod (stringvalue.c_str (), 0);                          \
00152     }                                                                            \
00153   }
00154 
00155 /// Macro to get the individual configuration value
00156 ///  from ACE_Configuration_Heap as ACE_Time_Value
00157 ///  using milliseconds.
00158 #define GET_CONFIG_TIME_VALUE(CF, SECT, KEY, VALUE)                              \
00159   {                                                                              \
00160     long tv = -1;                                                                \
00161     GET_CONFIG_VALUE(CF, SECT, KEY, tv, long);                                   \
00162     if (tv != -1) VALUE.msec(tv);                                                \
00163   }
00164 
00165 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00166 
00167 namespace OpenDDS {
00168 namespace DCPS {
00169 
00170 // The transport and configuration section name used in the config file format
00171 static const ACE_TCHAR TRANSPORT_SECTION_NAME[] = ACE_TEXT("transport");
00172 static const ACE_TCHAR CONFIG_SECTION_NAME[] = ACE_TEXT("config");
00173 
00174 /// Identifier type for DataLink objects.
00175 typedef ACE_UINT64  DataLinkIdType;
00176 
00177 /// Return code type for send_control() operations.
00178 enum SendControlStatus {
00179   SEND_CONTROL_ERROR,
00180   SEND_CONTROL_OK
00181 };
00182 
00183 /// Return code type for attach_transport() operations.
00184 enum AttachStatus {
00185   ATTACH_BAD_TRANSPORT,
00186   ATTACH_ERROR,
00187   ATTACH_INCOMPATIBLE_QOS,
00188   ATTACH_OK
00189 };
00190 
00191 // TBD - Resolve this
00192 #if 0
00193 // TBD SOON - The MAX_SEND_BLOCKS may conflict with the
00194 //            max_samples_per_packet_ configuration!
00195 //MJM: The constant should just be used as part of a conditional at the
00196 //MJM: points where it is used.
00197 #endif
00198 
00199 /// Controls the maximum size of the iovec array used for a send packet.
00200 #if defined (ACE_IOV_MAX) && (ACE_IOV_MAX != 0)
00201 enum { MAX_SEND_BLOCKS = ACE_IOV_MAX };
00202 #else
00203 enum { MAX_SEND_BLOCKS = 50 };
00204 #endif
00205 
00206 // Allocators are locked since we can not restrict the thread on
00207 // which a release will occur.
00208 
00209 /// Allocators used for transport receiving logic.
00210 enum { RECEIVE_DATA_BUFFER_SIZE = 65536 };
00211 
00212 typedef Cached_Allocator_With_Overflow<ACE_Message_Block, RECEIVE_SYNCH>
00213   TransportMessageBlockAllocator;
00214 
00215 typedef Cached_Allocator_With_Overflow<ACE_Data_Block,    RECEIVE_SYNCH>
00216   TransportDataBlockAllocator;
00217 
00218 typedef Cached_Allocator_With_Overflow<char[RECEIVE_DATA_BUFFER_SIZE],
00219                                        RECEIVE_SYNCH>
00220   TransportDataAllocator;
00221 
00222 /// Default TransportInst settings
00223 enum {
00224   DEFAULT_CONFIG_QUEUE_MESSAGES_PER_POOL = 10,
00225   DEFAULT_CONFIG_QUEUE_INITIAL_POOLS     = 5,
00226   DEFAULT_CONFIG_MAX_PACKET_SIZE         = 2147481599,
00227   DEFAULT_CONFIG_MAX_SAMPLES_PER_PACKET  = 10,
00228   DEFAULT_CONFIG_OPTIMUM_PACKET_SIZE     = 4096
00229 };
00230 
00231 /// used by DataLink::remove_sample(), TransportSendStrategy, *RemoveVisitor
00232 enum RemoveResult {
00233   REMOVE_ERROR, REMOVE_NOT_FOUND, REMOVE_FOUND, REMOVE_RELEASED
00234 };
00235 
00236 typedef ACE_CDR::Long Priority;
00237 
00238 } // namespace DCPS
00239 } // namespace OpenDDS
00240 
00241 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00242 
00243 #endif  /* OPENDDS_DCPS_TRANSPORTDEFS_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1