Definitions.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_DEFINITION_H
00009 #define OPENDDS_DCPS_DEFINITION_H
00010 
00011 #include "Cached_Allocator_With_Overflow_T.h"
00012 #include "ace/Message_Block.h"
00013 #include "ace/Global_Macros.h"
00014 #include "ace/Null_Mutex.h"
00015 
00016 #include <functional>
00017 #include <utility>
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 #pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 // More strict check than ACE does: if we have GNU lib C++ without support for
00024 // wchar_t (std::wstring, std::wostream, etc.) then we don't have DDS_HAS_WCHAR
00025 #if defined (ACE_HAS_WCHAR) && \
00026     (!defined (_GLIBCPP_VERSION) || defined(_GLIBCPP_USE_WCHAR_T)) && \
00027     !defined (__ANDROID__)
00028 #define DDS_HAS_WCHAR
00029 #endif
00030 
00031 #if defined (ACE_HAS_CPP11)
00032 #define OPENDDS_DELETED_COPY_MOVE_CTOR_ASSIGN(CLASS)         \
00033   CLASS(const CLASS&) = delete;           \
00034   CLASS(CLASS&&) = delete;           \
00035   CLASS& operator=(const CLASS&) = delete; \
00036   CLASS& operator=(CLASS&&) = delete;
00037 #else
00038 #define OPENDDS_DELETED_COPY_MOVE_CTOR_ASSIGN(CLASS)         \
00039   ACE_UNIMPLEMENTED_FUNC(CLASS(const CLASS&))           \
00040   ACE_UNIMPLEMENTED_FUNC(CLASS& operator=(const CLASS&))
00041 #endif
00042 
00043 #if defined (ACE_DES_FREE_THIS)
00044 #define OPENDDS_DES_FREE_THIS ACE_DES_FREE_THIS
00045 #else
00046 // The macro ACE_DES_FREE_THIS is part of ACE 6.4.2 or newer, define it within
00047 // OpenDDS at the moment we compile against an older ACE version
00048 # define OPENDDS_DES_FREE_THIS(DEALLOCATOR,CLASS) \
00049    do { \
00050         this->~CLASS (); \
00051         DEALLOCATOR (this); \
00052       } \
00053    while (0)
00054 #endif /* ACE_DES_FREE_THIS */
00055 
00056 
00057 // If features content_filtered_topic, multi_topic, and query_condition
00058 // are all disabled, define a macro to indicate common code these
00059 // three features depend on should not be built.
00060 #if defined(OPENDDS_NO_QUERY_CONDITION) && defined(OPENDDS_NO_CONTENT_FILTERED_TOPIC) && defined(OPENDDS_NO_MULTI_TOPIC)
00061 #define OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE
00062 #endif
00063 
00064 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00065 
00066 namespace OpenDDS {
00067 namespace DCPS {
00068 
00069 typedef Cached_Allocator_With_Overflow<ACE_Message_Block, ACE_Thread_Mutex> MessageBlockAllocator;
00070 typedef Cached_Allocator_With_Overflow<ACE_Data_Block, ACE_Thread_Mutex> DataBlockAllocator;
00071 struct DataSampleHeader;
00072 typedef Cached_Allocator_With_Overflow<DataSampleHeader, ACE_Null_Mutex> DataSampleHeaderAllocator;
00073 
00074 #define DUP true
00075 #define NO_DUP false
00076 
00077 /// This struct holds both object reference and the corresponding servant.
00078 template <typename T_impl, typename T, typename T_ptr, typename T_var>
00079 struct Objref_Servant_Pair {
00080   Objref_Servant_Pair()
00081     : svt_(0)
00082   {}
00083 
00084   Objref_Servant_Pair(T_impl* svt, T_ptr obj, bool dup)
00085     : svt_(svt)
00086   {
00087     if (dup) {
00088       obj_ = T::_duplicate(obj);
00089 
00090     } else {
00091       obj_ = obj;
00092     }
00093   }
00094 
00095   ~Objref_Servant_Pair()
00096   {}
00097 
00098   bool operator==(const Objref_Servant_Pair & pair) const {
00099     return pair.svt_ == this->svt_;
00100   }
00101 
00102   bool operator<(const Objref_Servant_Pair & pair) const {
00103     return this->svt_ < pair.svt_;
00104   }
00105 
00106   T_impl* svt_;
00107   T_var   obj_;
00108 };
00109 
00110 /// Use a Foo_var in a std::set or std::map with this comparison function,
00111 /// for example std::set<Foo_var, VarLess<Foo> >
00112 template <class T, class V = typename T::_var_type>
00113 struct VarLess : public std::binary_function<V, V, bool> {
00114   bool operator()(const V& x, const V& y) const {
00115     return x.in() < y.in();
00116   }
00117 };
00118 
00119 } // namespace OpenDDS
00120 } // namespace DCPS
00121 
00122 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00123 
00124 #endif /* OPENDDS_DCPS_DEFINITION_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1