Public Types | Public Member Functions | Private Attributes | List of all members
RTT::types::carray< T > Class Template Reference

#include <carray.hpp>

Public Types

typedef T value_type
 

Public Member Functions

value_typeaddress () const
 
 carray (value_type *t, std::size_t s)
 
 carray ()
 
 carray (boost::serialization::array< T > const &orig)
 
template<std::size_t N>
 carray (boost::array< T, N > &orig)
 
std::size_t count () const
 
void init (value_type *t, std::size_t s)
 
template<class OtherT >
const carray< T > & operator= (const carray< OtherT > &orig)
 
template<class OtherT >
const carray< T > & operator= (boost::serialization::array< OtherT > const &orig)
 
template<class OtherT , std::size_t OtherN>
const carray< T > & operator= (const boost::array< OtherT, OtherN > &orig)
 

Private Attributes

std::size_t m_element_count
 
value_typem_t
 

Detailed Description

template<class T>
class RTT::types::carray< T >

Wraps a C array such that we can return a C array from a DataSource. Inspired on boost::serialization::array.

Default copy-constructible (shallow copy).

An assignment (operator=) makes a 'deep copy', while copy construction makes a 'shallow copy', where the copy refers to the same C array. This was chosen in the spirit of this class, where it keeps track of the original data, but when assigned from another carray, is meant as copying the data itself.

You can also point to parts of arrays. An uninitialized carray object returns null for both count() and address().

Parameters
TThe data type of the array.

Definition at line 77 of file types/carray.hpp.

Member Typedef Documentation

template<class T>
typedef T RTT::types::carray< T >::value_type

Definition at line 80 of file types/carray.hpp.

Constructor & Destructor Documentation

template<class T>
RTT::types::carray< T >::carray ( value_type t,
std::size_t  s 
)
inline

Create an C array wrapper.

Parameters
tPointer to first element of array.
sLength of array. If zero, the parameter t will be ignored.

Definition at line 88 of file types/carray.hpp.

template<class T>
RTT::types::carray< T >::carray ( )
inline

Creates an empty carray. You are not allowed to read or write (operator=) to this array until it has been initialized.

See also
init() in order to initialize it later on.

Definition at line 99 of file types/carray.hpp.

template<class T>
RTT::types::carray< T >::carray ( boost::serialization::array< T > const &  orig)
inline

We are constructible from boost::serialization::array<T> Makes a shallow copy in order to keep the reference to the original data.

Parameters
orig

Definition at line 110 of file types/carray.hpp.

template<class T>
template<std::size_t N>
RTT::types::carray< T >::carray ( boost::array< T, N > &  orig)
inline

We are constructible from boost::array<T,N> Makes a shallow copy in order to keep the reference to the original data.

Parameters
orig

Definition at line 124 of file types/carray.hpp.

Member Function Documentation

template<class T>
value_type* RTT::types::carray< T >::address ( ) const
inline

The address of the first element of the array

Returns
null if count() == 0, the address otherwise.

Definition at line 142 of file types/carray.hpp.

template<class T>
std::size_t RTT::types::carray< T >::count ( ) const
inline
Returns
The number of elements in the array.

Definition at line 150 of file types/carray.hpp.

template<class T>
void RTT::types::carray< T >::init ( value_type t,
std::size_t  s 
)
inline

(Re-)initialize this carray to a new address and size.

Definition at line 133 of file types/carray.hpp.

template<class T>
template<class OtherT >
const carray<T>& RTT::types::carray< T >::operator= ( const carray< OtherT > &  orig)
inline

Assignment only copies max(this->count(), orig.count()) elements from orig to this object. If orig.count() is smaller than this->count() the contents of the remaining elements is left unmodified. If it's greater, the excess elements are ignored.

Definition at line 162 of file types/carray.hpp.

template<class T>
template<class OtherT >
const carray<T>& RTT::types::carray< T >::operator= ( boost::serialization::array< OtherT > const &  orig)
inline

Assignment only copies max(this->count(), orig.count()) elements from orig to this object. If orig.count() is smaller than this->count() the contents of the remaining elements is left unmodified. If it's greater, the excess elements are ignored.

Parameters
orig

Definition at line 180 of file types/carray.hpp.

template<class T>
template<class OtherT , std::size_t OtherN>
const carray<T>& RTT::types::carray< T >::operator= ( const boost::array< OtherT, OtherN > &  orig)
inline

Assignment only copies max(this->count(), orig.size()) elements from orig to this object. If orig.size() is smaller than this->count() the contents of the remaining elements is left unmodified. If it's greater, the excess elements are ignored.

Parameters
orig

Definition at line 196 of file types/carray.hpp.

Member Data Documentation

template<class T>
std::size_t RTT::types::carray< T >::m_element_count
private

Definition at line 205 of file types/carray.hpp.

template<class T>
value_type* RTT::types::carray< T >::m_t
private

Definition at line 204 of file types/carray.hpp.


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


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:47