11 #ifndef RTIREFLEX_SAFE_TYPECODE_H
12 #define RTIREFLEX_SAFE_TYPECODE_H
19 #include <boost/type_traits.hpp>
21 #include <ndds/ndds_cpp.h>
28 REFLEX_DLL_EXPORT void check_exception_code(
const char * message, DDS_ExceptionCode_t ex);
49 DDS_TypeCodeFactory * factory_;
50 DDS_TypeCode * typecode_;
60 : factory_(DDS_TypeCodeFactory::get_instance()),
70 : factory_(DDS_TypeCodeFactory::get_instance()),
71 typecode_(const_cast<DDS_TypeCode *>(tc)),
87 const DDS_TypeCode * tc)
89 typecode_(const_cast<DDS_TypeCode *>(tc)),
100 : factory_(safetc.factory_)
102 if (safetc.is_shared_)
104 typecode_ = safetc.typecode_;
109 DDS_ExceptionCode_t ex = DDS_NO_EXCEPTION_CODE;
110 typecode_ = factory_->clone_tc(safetc.typecode_, ex);
112 detail::check_exception_code(
113 "SafeTypeCode::SafeTypeCode: Unable to clone typecode, error = ",
130 #ifdef REFLEX_HAS_RVALUE_REF
137 : factory_(src.factory_),
138 typecode_(src.typecode_),
139 is_shared_(src.is_shared_)
162 DDS_ExceptionCode_t ex = DDS_NO_EXCEPTION_CODE;
163 if (factory_ && typecode_ && !is_shared_)
165 factory_->delete_tc(typecode_, ex);
167 if (ex != DDS_NO_EXCEPTION_CODE)
169 std::cerr <<
"~SafeTypeCode: Unable to delete typecode, error = "
170 << detail::get_readable_ex_code(ex)
187 const DDS_TypeCode *
get()
const
223 #endif // RTIREFLEX_SAFE_TYPECODE_H
SafeTypeCode(SafeTypeCode &&src)
Moves the ownership of the TypeCode from src to a newly created SafeTypeCode object. The src typecode is set to NULL.
Definition: safe_typecode.h:136
SafeTypeCode(DDS_TypeCode *tc)
Construct an SafeTypeCode object that owns the TypeCode.
Definition: safe_typecode.h:59
SafeTypeCode & operator=(const SafeTypeCode &rhs)
Create a copy of the argument SafeTypeCode.
Definition: safe_typecode.h:124
~SafeTypeCode()
Deletes the underlying TypeCode if the object was was constructed using a non-const TypeCode...
Definition: safe_typecode.h:160
SafeTypeCode(DDS_TypeCodeFactory *fact, DDS_TypeCode *tc)
Construct an SafeTypeCode object that owns the TypeCode.
Definition: safe_typecode.h:77
SafeTypeCode(const SafeTypeCode &safetc)
Create a copy of the argument SafeTypeCode.
Definition: safe_typecode.h:99
void swap(AutoDynamicData &lhs, AutoDynamicData &rhs)
Swap the contents of two AutoDynamicData instances. Never throws.
Definition: auto_dd.cxx:106
#define REFLEX_DLL_EXPORT
Definition: dllexport.h:35
SafeTypeCode(DDS_TypeCodeFactory *fact, const DDS_TypeCode *tc)
Construct an SafeTypeCode object that does not own the TypeCode.
Definition: safe_typecode.h:86
void swap(SafeTypeCode &stc)
Swap the contents of two SafeTypeCode objects. Never throws.
Definition: safe_typecode.h:203
SafeTypeCode(const DDS_TypeCode *tc)
Construct an SafeTypeCode object that does not own the TypeCode.
Definition: safe_typecode.h:69
A type-safe, exception-safe wrapper for DDS TypeCode.
Definition: reflex_fwd.h:27
DDS_TypeCode * release()
Release the ownership of the underlying TypeCode. The SafeTypeCode object remains usable...
Definition: safe_typecode.h:195