OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | List of all members
OpenDDS::DCPS::DurabilityArray< T > Class Template Reference

Array class that provides a means to reset the underlying ACE_Allocator. More...

#include <DurabilityArray.h>

Inheritance diagram for OpenDDS::DCPS::DurabilityArray< T >:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::DurabilityArray< T >:
Collaboration graph
[legend]

Public Member Functions

 DurabilityArray (size_t size, ACE_Allocator *allocator)
 
 DurabilityArray (size_t size, T const &default_value, ACE_Allocator *allocator)
 
 DurabilityArray (DurabilityArray< T > const &rhs)
 
 ~DurabilityArray ()
 
void operator= (DurabilityArray< T > const &rhs)
 
void set_allocator (ACE_Allocator *allocator)
 Reset allocator. More...
 
void swap (DurabilityArray< T > &rhs)
 
- Public Member Functions inherited from ACE_Array_Base< T >
ACE_DECLARE_STL_REVERSE_ITERATORS ACE_Array_Base (size_type size=0, ACE_Allocator *the_allocator=0)
 
 ACE_Array_Base (size_type size, T const &default_value, ACE_Allocator *the_allocator=0)
 
 ACE_Array_Base (ACE_Array_Base< T > const &s)
 
void operator= (ACE_Array_Base< T > const &s)
 
 ~ACE_Array_Base (void)
 
T & operator[] (size_type slot)
 
T const & operator[] (size_type slot) const
 
int set (T const &new_item, size_type slot)
 
int get (T &item, size_type slot) const
 
size_type size (void) const
 
int size (size_type new_size)
 
size_type max_size (void) const
 
int max_size (size_type new_size)
 
void swap (ACE_Array_Base< T > &array)
 
iterator begin (void)
 
iterator end (void)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
reverse_iterator rbegin (void)
 
reverse_iterator rend (void)
 
const_reverse_iterator rbegin (void) const
 
const_reverse_iterator rend (void) const
 
iterator begin (void)
 
iterator end (void)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
reverse_iterator rbegin (void)
 
reverse_iterator rend (void)
 
const_reverse_iterator rbegin (void) const
 
const_reverse_iterator rend (void) const
 

Additional Inherited Members

- Public Types inherited from ACE_Array_Base< T >
typedef T TYPE
 
typedef ACE_Array_Iterator< T > ITERATOR
 
typedef T value_type
 
typedef value_typeiterator
 
typedef value_type const * const_iterator
 
typedef value_typereference
 
typedef value_type const & const_reference
 
typedef value_typepointer
 
typedef value_type const * const_pointer
 
typedef ptrdiff_t difference_type
 
typedef ACE_Allocator::size_type size_type
 
- Protected Member Functions inherited from ACE_Array_Base< T >
bool in_range (size_type slot) const
 
- Protected Attributes inherited from ACE_Array_Base< T >
size_type max_size_
 
size_type cur_size_
 
value_typearray_
 
ACE_Allocatorallocator_
 

Detailed Description

template<typename T>
class OpenDDS::DCPS::DurabilityArray< T >

Array class that provides a means to reset the underlying ACE_Allocator.

This class only exists to provide a means to reset the allocator used by the ACE_Array_Base base class. It has a specific use case, namely to correctly support instances created by a persistent allocator. The allocator address may change between process runs, meaning the allocator address stored in the persistent ACE_Array_Base instance will be invalid. Use the set_allocator() method to reset the allocator address before performing any operations that will require use of the allocator (e.g. increasing the size of the array).

Definition at line 38 of file DurabilityArray.h.

Constructor & Destructor Documentation

◆ DurabilityArray() [1/3]

template<typename T>
OpenDDS::DCPS::DurabilityArray< T >::DurabilityArray ( size_t  size,
ACE_Allocator allocator 
)
inline

Definition at line 41 of file DurabilityArray.h.

43  : ACE_Array_Base<T> (size, allocator)
44  {}
size_type size(void) const

◆ DurabilityArray() [2/3]

template<typename T>
OpenDDS::DCPS::DurabilityArray< T >::DurabilityArray ( size_t  size,
T const &  default_value,
ACE_Allocator allocator 
)
inline

Definition at line 46 of file DurabilityArray.h.

49  : ACE_Array_Base<T> (size, default_value, allocator)
50  {}
size_type size(void) const

◆ DurabilityArray() [3/3]

template<typename T>
OpenDDS::DCPS::DurabilityArray< T >::DurabilityArray ( DurabilityArray< T > const &  rhs)
inline

Definition at line 52 of file DurabilityArray.h.

References ACE_Array_Base< T >::array_, and size_.

53  : ACE_Array_Base<T> (rhs.size(), rhs.allocator_)
54  {
55  for (size_t i = 0; i < this->size_; ++i)
56  this->array_[i] = rhs.array_[i];
57  }
size_t size_
value_type * array_

◆ ~DurabilityArray()

template<typename T>
OpenDDS::DCPS::DurabilityArray< T >::~DurabilityArray ( )
inline

Definition at line 59 of file DurabilityArray.h.

60  {}

Member Function Documentation

◆ operator=()

template<typename T>
void OpenDDS::DCPS::DurabilityArray< T >::operator= ( DurabilityArray< T > const &  rhs)
inline

Definition at line 62 of file DurabilityArray.h.

References OpenDDS::DCPS::DurabilityArray< T >::swap().

63  {
64  DurabilityArray tmp(rhs);
65  this->swap(rhs);
66  }
void swap(DurabilityArray< T > &rhs)
DurabilityArray(size_t size, ACE_Allocator *allocator)

◆ set_allocator()

template<typename T>
void OpenDDS::DCPS::DurabilityArray< T >::set_allocator ( ACE_Allocator allocator)
inline

Reset allocator.

Definition at line 69 of file DurabilityArray.h.

References ACE_Array_Base< T >::allocator_, and ACE_Allocator::instance().

70  {
71  if (allocator == 0)
72  allocator = ACE_Allocator::instance();
73 
74  this->allocator_ = allocator;
75  }
static ACE_Allocator * instance(void)
ACE_Allocator * allocator_

◆ swap()

template<typename T>
void OpenDDS::DCPS::DurabilityArray< T >::swap ( DurabilityArray< T > &  rhs)
inline

Definition at line 77 of file DurabilityArray.h.

References ACE_Array_Base< T >::allocator_, ACE_Array_Base< T >::array_, ACE_Array_Base< T >::cur_size_, ACE_Array_Base< T >::max_size_, OPENDDS_END_VERSIONED_NAMESPACE_DECL, and OpenDDS::DCPS::swap().

Referenced by OpenDDS::DCPS::DurabilityArray< T >::operator=().

78  {
79  std::swap(this->max_size_, rhs.max_size_);
80  std::swap(this->cur_size_, rhs.current_size_);
81  std::swap(this->array_, rhs.array_);
82  std::swap(this->allocator_, rhs.allocator_);
83  }
size_type max_size_
static ACE_Allocator * allocator_
size_type cur_size_
ACE_Allocator * allocator_
void swap(MessageBlock &lhs, MessageBlock &rhs)
value_type * array_

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