14 #ifndef RTI_ROUTING_PROCESSOR_LOANED_SAMPLE_HPP_
15 #define RTI_ROUTING_PROCESSOR_LOANED_SAMPLE_HPP_
19 namespace rti {
namespace routing {
namespace processor {
27 template <
typename T,
typename U>
45 LoanedSample(
const DataType * the_data,
const InfoType * the_info)
46 : _data_ptr(the_data),
51 LoanedSample(
const DataType & the_data,
const InfoType & the_info)
52 : _data_ptr(&the_data),
56 LoanedSample(
const void * the_data,
const void * the_info)
57 : _data_ptr(static_cast<const T*>(the_data)),
58 _info_ptr(static_cast<const U*>(the_info))
62 const DataType & data()
const
64 if (!info().valid()) {
65 throw dds::core::PreconditionNotMetError(
"Invalid data");
74 const InfoType & info()
const {
79 operator const DataType & ()
const
84 LoanedSample<DataType, InfoType> * operator ->() {
88 const LoanedSample<DataType, InfoType> * operator ->()
const {
95 bool operator==(
const LoanedSample& other)
const
97 if (info() != other.info()) {
101 if (info().valid()) {
102 if (data() != other.data()) {
110 bool operator!=(
const LoanedSample& other)
const
112 return !(*
this == other);
115 void swap(LoanedSample & other)
throw()
119 swap(_data_ptr, other._data_ptr);
120 swap(_info_ptr, other._info_ptr);
124 const DataType * _data_ptr;
125 const InfoType * _info_ptr;
130 #endif // RTI_ROUTING_PROCESSOR_LOANED_SAMPLE_HPP_