OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts > Class Template Reference

#include <SafetyProfileSequence.h>

Inheritance diagram for OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef seq_size_type size_type
typedef seq_size_type _size_type
typedef Elts ElementPolicy
typedef Elts::Element Element
typedef Elts::ConstElement ConstElement
typedef Elts::ConstRawElement ConstRawElement
typedef ConstElement const_subscript_type
typedef Element subscript_type
typedef T value_type
typedef T & reference
typedef const T & const_reference
typedef T * iterator
typedef const T * const_iterator
typedef std::ptrdiff_t difference_type

Public Member Functions

void length (size_type len)
size_type length () const
ConstElement operator[] (size_type idx) const
Element operator[] (size_type idx)
seq_flag_type release () const
T * get_buffer (seq_flag_type orphan=false)
const ConstRawElementget_buffer () const
const T * begin () const
T * begin ()
const T * end () const
T * end ()
bool operator== (const Sequence &rhs) const
bool operator!= (const Sequence &rhs) const
size_type size () const
bool empty () const

Static Public Member Functions

static void freebuf (T *data)

Protected Member Functions

 Sequence (size_type maximum=0, size_type length=0, T *data=0, seq_flag_type release=false)
 Sequence (const Sequence &seq)
 ~Sequence ()
Sequenceoperator= (const Sequence &seq)
void swap (Sequence &rhs) throw ()

Private Member Functions

void replace_i (size_type maximum, size_type length, T *data, seq_flag_type release)
void lazy_alloc () const

Private Attributes

size_type length_
seq_flag_type release_
T * buffer_

Friends

struct AllocPolicy< T, Sequence, Bounds >

Detailed Description

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
class OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >

Generic base class for all IDL-defined sequences accepted by opendds_idl. Derived classes (generated by opendds_idl) need to provide the following methods to be compliant with the IDL-to-C++ specification: If bounded:

Definition at line 245 of file SafetyProfileSequence.h.


Member Typedef Documentation

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef seq_size_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::_size_type

Definition at line 250 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef const T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::const_iterator

Definition at line 297 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef const T& OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::const_reference

Definition at line 295 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef ConstElement OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::const_subscript_type

Definition at line 270 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef Elts::ConstElement OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::ConstElement

Definition at line 267 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef Elts::ConstRawElement OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::ConstRawElement

Definition at line 268 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef std::ptrdiff_t OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::difference_type

Definition at line 298 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef Elts::Element OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Element

Definition at line 266 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef Elts OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::ElementPolicy

Definition at line 251 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::iterator

Definition at line 296 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef T& OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::reference

Definition at line 294 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef seq_size_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::size_type

Definition at line 249 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef Element OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::subscript_type

Definition at line 271 of file SafetyProfileSequence.h.

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
typedef T OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::value_type

Definition at line 293 of file SafetyProfileSequence.h.


Constructor & Destructor Documentation

template<typename T, typename Bounds, typename Elts>
OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence ( size_type  maximum = 0,
size_type  length = 0,
T *  data = 0,
seq_flag_type  release = false 
) [inline, explicit, protected]

Definition at line 528 of file SafetyProfileSequence.h.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator=(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::replace_i().

00531     : AllocPolicy<T, Sequence, Bounds>(maximum)
00532     , length_(length)
00533     , release_(release)
00534     , buffer_(data)
00535   {
00536   }

template<typename T, typename Bounds, typename Elts>
OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence ( const Sequence< T, Bounds, Elts > &  seq  )  [inline, protected]

Definition at line 539 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_.

00540     : AllocPolicy<T, Sequence, Bounds>(seq.maximum())
00541     , length_(seq.length_)
00542     , release_(true)
00543     , buffer_((seq.maximum() && seq.buffer_) ? allocate() : 0)
00544   {
00545     if (buffer_) {
00546       Elts::copy_n(seq.buffer_, length_, buffer_);
00547     }
00548   }

template<typename T, typename Bounds, typename Elts>
OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::~Sequence (  )  [inline, protected]

Definition at line 551 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::freebuf(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_.

00552   {
00553     if (release_) {
00554       freebuf(buffer_);
00555     }
00556   }


Member Function Documentation

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::begin (  )  [inline]

Definition at line 301 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_.

00301 { return buffer_; }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
const T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::begin (  )  const [inline]

Definition at line 300 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_.

00300 { return buffer_; }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
bool OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::empty (  )  const [inline]

Definition at line 311 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_.

00311 { return !length_; }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::end (  )  [inline]

Definition at line 304 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_.

00304 { return buffer_ + length_; }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
const T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::end (  )  const [inline]

Definition at line 303 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_.

00303 { return buffer_ + length_; }

template<typename T, typename Bounds, typename Elts>
void OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::freebuf ( T *  data  )  [inline, static]

Definition at line 655 of file SafetyProfileSequence.h.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::~Sequence().

00656   {
00657     if (!data) return;
00658     T* const allocated = Elts::destroy(data, Bounds::Bounds);
00659     ACE_Allocator::instance()->free(allocated);
00660   }

template<typename T, typename Bounds, typename Elts>
const Sequence< T, Bounds, Elts >::ConstRawElement * OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer (  )  const [inline]

Definition at line 648 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::lazy_alloc().

00649   {
00650     lazy_alloc();
00651     return buffer_;
00652   }

template<typename T, typename Bounds, typename Elts>
T * OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer ( seq_flag_type  orphan = false  )  [inline]

Definition at line 628 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::lazy_alloc(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_, OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::swap().

00629   {
00630     if (orphan && !release_) {
00631       return 0;
00632     }
00633 
00634     lazy_alloc();
00635 
00636     if (orphan) {
00637       Sequence tmp;
00638       swap(tmp);
00639       tmp.release_ = false;
00640       return tmp.buffer_;
00641     }
00642 
00643     return buffer_;
00644   }

template<typename T, typename Bounds, typename Elts>
void OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::lazy_alloc (  )  const [inline, private]

Definition at line 586 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length().

00587   {
00588     if (!buffer_) {
00589       buffer_ = allocate();
00590       release_ = true;
00591     }
00592   }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
size_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length (  )  const [inline]

Definition at line 264 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_.

00264 { return length_; }

template<typename T, typename Bounds, typename Elts>
void OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length ( size_type  len  )  [inline]

Definition at line 595 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::lazy_alloc(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_, OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_, OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::swap().

00596   {
00597     if (len <= maximum()) {
00598       if (len && !buffer_) {
00599         lazy_alloc();
00600       }
00601       else if (release_ && len < length_) {
00602         Elts::reset_n(buffer_ + len, length_ - len);
00603       }
00604       length_ = len;
00605       return;
00606     }
00607 
00608     Sequence tmp(len, len, allocate(len), true);
00609     Elts::move_n(buffer_, length_, tmp.buffer_);
00610     swap(tmp);
00611   }

template<typename T, typename Bounds, typename Elts>
bool OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator!= ( const Sequence< T, Bounds, Elts > &  rhs  )  const [inline]

Definition at line 678 of file SafetyProfileSequence.h.

00679   {
00680     return !(*this == rhs);
00681   }

template<typename T, typename Bounds, typename Elts>
Sequence< T, Bounds, Elts > & OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator= ( const Sequence< T, Bounds, Elts > &  seq  )  [inline, protected]

Definition at line 560 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::swap().

00561   {
00562     Sequence cpy(seq);
00563     swap(cpy);
00564     return *this;
00565   }

template<typename T, typename Bounds, typename Elts>
bool OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator== ( const Sequence< T, Bounds, Elts > &  rhs  )  const [inline]

Definition at line 663 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::size().

00664   {
00665     const size_type sz = size();
00666     if (sz != rhs.size()) {
00667       return false;
00668     }
00669     for (size_type i = 0; i < sz; ++i) {
00670       if (!((*this)[i] == rhs[i])) {
00671         return false;
00672       }
00673     }
00674     return true;
00675   }

template<typename T, typename Bounds, typename Elts>
Sequence< T, Bounds, Elts >::Element OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator[] ( size_type  idx  )  [inline]

Definition at line 622 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_, and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_.

00623   {
00624     return Elts::make_element(buffer_[idx], release_);
00625   }

template<typename T, typename Bounds, typename Elts>
Sequence< T, Bounds, Elts >::ConstElement OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator[] ( size_type  idx  )  const [inline]

Definition at line 615 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_.

00616   {
00617     return buffer_[idx];
00618   }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
seq_flag_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release (  )  const [inline]

Definition at line 276 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_.

00276 { return release_; }

template<typename T, typename Bounds, typename Elts>
void OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::replace_i ( size_type  maximum,
size_type  length,
T *  data,
seq_flag_type  release 
) [inline, private]

Definition at line 577 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::swap().

00580   {
00581     Sequence tmp(maximum, length, data, release);
00582     swap(tmp);
00583   }

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
size_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::size (  )  const [inline]

Definition at line 309 of file SafetyProfileSequence.h.

References OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator==().

00309 { return length_; }

template<typename T, typename Bounds, typename Elts>
void OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::swap ( Sequence< T, Bounds, Elts > &  rhs  )  throw () [inline, protected]

Definition at line 568 of file SafetyProfileSequence.h.

References OpenDDS::DCPS::swap().

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator=(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::replace_i().

00569   {
00570     AllocPolicy<T, Sequence, Bounds>::swap(rhs);
00571     std::swap(length_, rhs.length_);
00572     std::swap(release_, rhs.release_);
00573     std::swap(buffer_, rhs.buffer_);
00574   }


Friends And Related Function Documentation

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
friend struct AllocPolicy< T, Sequence, Bounds > [friend]

Definition at line 315 of file SafetyProfileSequence.h.


Member Data Documentation

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
T* OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::buffer_ [mutable, private]

Definition at line 326 of file SafetyProfileSequence.h.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::begin(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::end(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::lazy_alloc(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator[](), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::~Sequence().

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
size_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length_ [private]

Definition at line 324 of file SafetyProfileSequence.h.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::empty(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::end(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::Sequence(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::size().

template<typename T, typename Bounds, typename Elts = DefaultEltPolicy<T>>
seq_flag_type OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release_ [mutable, private]

Definition at line 325 of file SafetyProfileSequence.h.

Referenced by OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::get_buffer(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::lazy_alloc(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::length(), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::operator[](), OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::release(), and OpenDDS::SafetyProfile::Sequence< T, Bounds, Elts >::~Sequence().


The documentation for this class was generated from the following file:
Generated on Fri Feb 12 20:06:51 2016 for OpenDDS by  doxygen 1.4.7