LCOV - code coverage report
Current view: top level - DCPS - Definitions.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 12 16.7 %
Date: 2023-04-30 01:32:43 Functions: 1 12 8.3 %

          Line data    Source code
       1             : /*
       2             :  * Distributed under the OpenDDS License.
       3             :  * See: http://www.opendds.org/license.html
       4             :  */
       5             : 
       6             : #ifndef OPENDDS_DCPS_DEFINITIONS_H
       7             : #define OPENDDS_DCPS_DEFINITIONS_H
       8             : 
       9             : #include <dds/Versioned_Namespace.h>
      10             : 
      11             : #include <ace/Message_Block.h>
      12             : #include <ace/Global_Macros.h>
      13             : #include <ace/Null_Mutex.h>
      14             : 
      15             : #include <functional>
      16             : #include <utility>
      17             : 
      18             : #ifndef ACE_LACKS_PRAGMA_ONCE
      19             : #  pragma once
      20             : #endif
      21             : 
      22             : // More strict check than ACE does: if we have GNU lib C++ without support for
      23             : // wchar_t (std::wstring, std::wostream, etc.) then we don't have DDS_HAS_WCHAR
      24             : #if defined ACE_HAS_WCHAR && (!defined _GLIBCPP_VERSION || defined_GLIBCPP_USE_WCHAR_T)
      25             : #  define DDS_HAS_WCHAR
      26             : #endif
      27             : 
      28             : #ifdef ACE_HAS_CPP11
      29             : #  define OPENDDS_DELETED_COPY_MOVE_CTOR_ASSIGN(CLASS) \
      30             :   CLASS(const CLASS&) = delete; \
      31             :   CLASS(CLASS&&) = delete; \
      32             :   CLASS& operator=(const CLASS&) = delete; \
      33             :   CLASS& operator=(CLASS&&) = delete;
      34             : #else
      35             : #  define OPENDDS_DELETED_COPY_MOVE_CTOR_ASSIGN(CLASS) \
      36             :   ACE_UNIMPLEMENTED_FUNC(CLASS(const CLASS&)) \
      37             :   ACE_UNIMPLEMENTED_FUNC(CLASS& operator=(const CLASS&))
      38             : #endif
      39             : 
      40             : #if defined ACE_DES_FREE_THIS
      41             : #  define OPENDDS_DES_FREE_THIS ACE_DES_FREE_THIS
      42             : #else
      43             : // The macro ACE_DES_FREE_THIS is part of ACE 6.4.2 or newer, define it within
      44             : // OpenDDS at the moment we compile against an older ACE version
      45             : #  define OPENDDS_DES_FREE_THIS(DEALLOCATOR,CLASS) \
      46             :    do { \
      47             :         this->~CLASS (); \
      48             :         DEALLOCATOR (this); \
      49             :       } \
      50             :    while (0)
      51             : #endif
      52             : 
      53             : // If features content_filtered_topic, multi_topic, and query_condition
      54             : // are all disabled, define a macro to indicate common code these
      55             : // three features depend on should not be built.
      56             : #if defined OPENDDS_NO_QUERY_CONDITION && defined OPENDDS_NO_CONTENT_FILTERED_TOPIC && defined OPENDDS_NO_MULTI_TOPIC
      57             : #  define OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE
      58             : #endif
      59             : 
      60             : #ifndef OPENDDS_HAS_DYNAMIC_DATA_ADAPTER
      61             : #  if !defined OPENDDS_SAFETY_PROFILE && !defined OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE
      62             : #    define OPENDDS_HAS_DYNAMIC_DATA_ADAPTER 1
      63             : #  else
      64             : #    define OPENDDS_HAS_DYNAMIC_DATA_ADAPTER 0
      65             : #  endif
      66             : #endif
      67             : 
      68             : #ifdef OPENDDS_SAFETY_PROFILE
      69             : #  define OPENDDS_ASSERT(C) ((void) 0)
      70             : #else
      71             : #  include <cassert>
      72             : #  define OPENDDS_ASSERT(C) assert(C)
      73             : #endif
      74             : 
      75             : #define OPENDDS_TEST_AND_CALL(TYPE, TEST, CALL) do { TYPE temp = TEST; if (temp) { temp->CALL; } } while (false);
      76             : #define OPENDDS_TEST_AND_CALL_ASSIGN(TYPE, TEST, CALL, VAL) do { TYPE temp = TEST; if (temp) { VAL = temp->CALL; } } while (false);
      77             : 
      78             : #include <tao/orbconf.h>
      79             : #if defined TAO_HAS_IDL_FEATURES && TAO_HAS_IDL_FEATURES
      80             : #  include <tao/idl_features.h>
      81             : #  define OPENDDS_HAS_EXPLICIT_INTS TAO_IDL_HAS_EXPLICIT_INTS
      82             : #else
      83             : #  define OPENDDS_HAS_EXPLICIT_INTS 0
      84             : #endif
      85             : 
      86             : #if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || defined __clang__)
      87             : #  define OPENDDS_GCC_HAS_DIAG_PUSHPOP 1
      88             : #else
      89             : #  define OPENDDS_GCC_HAS_DIAG_PUSHPOP 0
      90             : #endif
      91             : 
      92             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      93             : 
      94             : namespace OpenDDS {
      95             : namespace DCPS {
      96             : 
      97             : /// This struct holds both object reference and the corresponding servant.
      98             : template <typename T_impl, typename T, typename T_ptr, typename T_var>
      99             : struct Objref_Servant_Pair {
     100             :   Objref_Servant_Pair()
     101             :     : svt_(0)
     102             :   {}
     103             : 
     104           0 :   Objref_Servant_Pair(T_impl* svt, T_ptr obj, bool dup)
     105           0 :     : svt_(svt)
     106             :   {
     107           0 :     if (dup) {
     108           0 :       obj_ = T::_duplicate(obj);
     109             : 
     110             :     } else {
     111           0 :       obj_ = obj;
     112             :     }
     113           0 :   }
     114             : 
     115           0 :   ~Objref_Servant_Pair()
     116           0 :   {}
     117             : 
     118             :   bool operator==(const Objref_Servant_Pair & pair) const {
     119             :     return pair.svt_ == this->svt_;
     120             :   }
     121             : 
     122           0 :   bool operator<(const Objref_Servant_Pair & pair) const {
     123           0 :     return this->svt_ < pair.svt_;
     124             :   }
     125             : 
     126             :   T_impl* svt_;
     127             :   T_var obj_;
     128             : };
     129             : 
     130             : /// Use a Foo_var in a std::set or std::map with this comparison function,
     131             : /// for example std::set<Foo_var, VarLess<Foo> >
     132             : template <class T, class V = typename T::_var_type>
     133             : struct VarLess {
     134             :   typedef V first_argument_type;
     135             :   typedef V second_argument_type;
     136             :   typedef bool result_type;
     137             : 
     138          55 :   bool operator()(const V& x, const V& y) const {
     139          55 :     return x.in() < y.in();
     140             :   }
     141             : };
     142             : 
     143             : /// Size of TCHAR buffer for use with ACE::timestamp, e.g.,
     144             : ///  ACE_TCHAR buffer[AceTimestampSize];
     145             : ///  ACE::timestamp(buffer, AceTimestampSize);
     146             : const size_t AceTimestampSize = 27;
     147             : 
     148             : /// Size of TCHAR buffer for use with addr_to_string.
     149             : const size_t AddrToStringSize = 256;
     150             : 
     151             : } // namespace DCPS
     152             : } // namespace OpenDDS
     153             : 
     154             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     155             : 
     156             : #endif /* OPENDDS_DCPS_DEFINITION_H */

Generated by: LCOV version 1.16