OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::DataDurabilityCache::sample_data_type Class Reference

Sample list data type for all samples. More...

#include <DataDurabilityCache.h>

Collaboration diagram for OpenDDS::DCPS::DataDurabilityCache::sample_data_type:
Collaboration graph
[legend]

Public Member Functions

 sample_data_type ()
 
 sample_data_type (DataSampleElement &element, ACE_Allocator *allocator)
 
 sample_data_type (DDS::Time_t timestamp, const ACE_Message_Block &mb, ACE_Allocator *allocator)
 
 sample_data_type (sample_data_type const &rhs)
 
 ~sample_data_type ()
 
sample_data_typeoperator= (sample_data_type const &rhs)
 
void get_sample (char const *&s, size_t &len, DDS::Time_t &source_timestamp)
 
void set_allocator (ACE_Allocator *allocator)
 

Private Member Functions

void init (const ACE_Message_Block *data)
 

Private Attributes

size_t length_
 
char * sample_
 
DDS::Time_t source_timestamp_
 
ACE_Allocatorallocator_
 

Detailed Description

Sample list data type for all samples.

Definition at line 147 of file DataDurabilityCache.h.

Constructor & Destructor Documentation

◆ sample_data_type() [1/4]

OpenDDS::DCPS::DataDurabilityCache::sample_data_type::sample_data_type ( )

◆ sample_data_type() [2/4]

OpenDDS::DCPS::DataDurabilityCache::sample_data_type::sample_data_type ( DataSampleElement element,
ACE_Allocator allocator 
)

Definition at line 179 of file DataDurabilityCache.cpp.

References ACE_Message_Block::cont(), OpenDDS::DCPS::DataSampleElement::get_header(), OpenDDS::DCPS::DataSampleElement::get_sample(), init(), DDS::Time_t::nanosec, DDS::Time_t::sec, source_timestamp_, OpenDDS::DCPS::DataSampleHeader::source_timestamp_nanosec_, and OpenDDS::DCPS::DataSampleHeader::source_timestamp_sec_.

182  : length_(0)
183  , sample_(0)
184  , allocator_(a)
185 {
186  this->source_timestamp_.sec = element.get_header().source_timestamp_sec_;
187  this->source_timestamp_.nanosec = element.get_header().source_timestamp_nanosec_;
188 
189  // Only copy the data provided by the user. The DataSampleHeader
190  // will be reconstructed when the durable data is retrieved by a
191  // DataWriterImpl instance.
192  //
193  // The user's data is stored in the first message block
194  // continuation.
195  ACE_Message_Block const * const data = element.get_sample()->cont();
196  init(data);
197 }
ACE_Message_Block * cont(void) const
unsigned long nanosec

◆ sample_data_type() [3/4]

OpenDDS::DCPS::DataDurabilityCache::sample_data_type::sample_data_type ( DDS::Time_t  timestamp,
const ACE_Message_Block mb,
ACE_Allocator allocator 
)

◆ sample_data_type() [4/4]

OpenDDS::DCPS::DataDurabilityCache::sample_data_type::sample_data_type ( sample_data_type const &  rhs)

Definition at line 229 of file DataDurabilityCache.cpp.

References ACE_ALLOCATOR, allocator_, length_, ACE_Allocator::malloc(), ACE_OS::memcpy(), DDS::Time_t::nanosec, sample_, DDS::Time_t::sec, and source_timestamp_.

231  : length_(rhs.length_)
232  , sample_(0)
233  , allocator_(rhs.allocator_)
234 {
235  this->source_timestamp_.sec = rhs.source_timestamp_.sec;
236  this->source_timestamp_.nanosec = rhs.source_timestamp_.nanosec;
237 
238  if (this->allocator_) {
239  ACE_ALLOCATOR(this->sample_,
240  static_cast<char *>(
241  this->allocator_->malloc(rhs.length_)));
242  ACE_OS::memcpy(this->sample_, rhs.sample_, rhs.length_);
243  }
244 }
void * memcpy(void *t, const void *s, size_t len)
#define ACE_ALLOCATOR(POINTER, ALLOCATOR)
unsigned long nanosec
virtual void * malloc(size_type nbytes)=0

◆ ~sample_data_type()

OpenDDS::DCPS::DataDurabilityCache::sample_data_type::~sample_data_type ( )

Definition at line 246 of file DataDurabilityCache.cpp.

References allocator_, ACE_Allocator::free(), and sample_.

247 {
248  if (this->allocator_)
249  this->allocator_->free(this->sample_);
250 }
virtual void free(void *ptr)=0

Member Function Documentation

◆ get_sample()

void OpenDDS::DCPS::DataDurabilityCache::sample_data_type::get_sample ( char const *&  s,
size_t &  len,
DDS::Time_t source_timestamp 
)

◆ init()

void OpenDDS::DCPS::DataDurabilityCache::sample_data_type::init ( const ACE_Message_Block data)
private

Definition at line 211 of file DataDurabilityCache.cpp.

References ACE_ALLOCATOR, allocator_, ACE_Message_Block::cont(), length_, ACE_Allocator::malloc(), ACE_OS::memcpy(), sample_, and ACE_Message_Block::total_length().

Referenced by sample_data_type().

212 {
213  this->length_ = data->total_length();
214 
215  ACE_ALLOCATOR(this->sample_,
216  static_cast<char *>(
217  this->allocator_->malloc(this->length_)));
218 
219  char * buf = this->sample_;
220 
221  for (ACE_Message_Block const * i = data;
222  i != 0;
223  i = i->cont()) {
224  ACE_OS::memcpy(buf, i->rd_ptr(), i->length());
225  buf += i->length();
226  }
227 }
void * memcpy(void *t, const void *s, size_t len)
ACE_Message_Block * cont(void) const
size_t total_length(void) const
#define ACE_ALLOCATOR(POINTER, ALLOCATOR)
virtual void * malloc(size_type nbytes)=0

◆ operator=()

OpenDDS::DCPS::DataDurabilityCache::sample_data_type & OpenDDS::DCPS::DataDurabilityCache::sample_data_type::operator= ( sample_data_type const &  rhs)

Definition at line 253 of file DataDurabilityCache.cpp.

References allocator_, length_, DDS::Time_t::nanosec, sample_, DDS::Time_t::sec, source_timestamp_, and OpenDDS::DCPS::swap().

255 {
256  // Strongly exception-safe copy assignment.
257  sample_data_type tmp(rhs);
258  std::swap(this->length_, tmp.length_);
259  std::swap(this->sample_, tmp.sample_);
260  std::swap(this->allocator_, tmp.allocator_);
261 
262  this->source_timestamp_.sec = rhs.source_timestamp_.sec;
263  this->source_timestamp_.nanosec = rhs.source_timestamp_.nanosec;
264 
265  return *this;
266 }
void swap(MessageBlock &lhs, MessageBlock &rhs)
static ACE_Allocator * allocator_
unsigned long nanosec

◆ set_allocator()

void OpenDDS::DCPS::DataDurabilityCache::sample_data_type::set_allocator ( ACE_Allocator allocator)

Definition at line 281 of file DataDurabilityCache.cpp.

References allocator_.

283 {
284  this->allocator_ = allocator;
285 }

Member Data Documentation

◆ allocator_

ACE_Allocator* OpenDDS::DCPS::DataDurabilityCache::sample_data_type::allocator_
private

◆ length_

size_t OpenDDS::DCPS::DataDurabilityCache::sample_data_type::length_
private

Definition at line 171 of file DataDurabilityCache.h.

Referenced by get_sample(), init(), operator=(), and sample_data_type().

◆ sample_

char* OpenDDS::DCPS::DataDurabilityCache::sample_data_type::sample_
private

◆ source_timestamp_

DDS::Time_t OpenDDS::DCPS::DataDurabilityCache::sample_data_type::source_timestamp_
private

Definition at line 173 of file DataDurabilityCache.h.

Referenced by get_sample(), operator=(), and sample_data_type().


The documentation for this class was generated from the following files: