iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::DenseData Class Reference

#include <nrt/PointCloud2/details/DenseData.H>

A class for representing dense (one entry per geometry) data.

Dense data is stored in a contiguous dynamic data structure that can be considered opaque by the developer. When creating new dense data, the size in bytes of the data to be represented must be known, along with the name associated with the data.

Access to the data is only done through typed accessors

Definition at line 81 of file DenseData.H.

Public Member Functions

 DenseData ()=default
 Creates an empty (invalid) DenseData.
 
 DenseData (size_t elemSize, size_t numElems, std::string const &name)
 Create a new densedata. More...
 
 DenseData (DenseData const &other)=default
 Copy construction.
 
 DenseData (DenseData &&other)=default
 Move construction.
 
DenseDataoperator= (DenseData const &other)=default
 Assignment.
 
DenseDataoperator= (DenseData &&other)=default
 Move assignment.
 
void resize (size_t size)
 Resizes the data. More...
 
void clear ()
 Clears all data.
 
size_t const size () const
 Returns the number of elements in the container.
 
std::string const & name () const
 Returns the name of the type associated with this data.
 
template<class T >
T & get (size_t index)
 Gets the data located at an index. More...
 
template<class T >
T const & get (size_t index) const
 Constant version of get. More...
 
template<class T >
T *const ptr (size_t index)
 Returns a pointer to the specified index. More...
 
template<class T >
T const *const ptr (size_t index) const
 Returns a constant pointer to the specified index. More...
 
template<class T >
T * begin ()
 Returns a pointer to the beginning of the data. More...
 
template<class T >
T const * begin () const
 Returns a pointer to the beginning of the data. More...
 
template<class T >
T * end ()
 Returns a pointer to the end of the data (one past the last element) More...
 
template<class T >
T const * end () const
 Returns a pointer to the end of the data (one past the last element) More...
 
size_t insert ()
 Inserts one junk element to the end of the vector. More...
 
template<class T >
size_t insert (T const &data=T())
 Inserts a new entry to the end of the vector. More...
 
void append (DenseData const &other)
 Appends all data in another DenseData into this one.
 
void remove (size_t index)
 Removes the element at the specified index. More...
 
void quickRemove (size_t index)
 Removes the elemnt at the specified index. More...
 

Protected Member Functions

size_t const convertIndex (size_t const index) const
 Converts an external index to an internal index.
 

Friends

class cereal::access
 

Constructor & Destructor Documentation

nrt::DenseData::DenseData ( size_t  elemSize,
size_t  numElems,
std::string const &  name 
)

Create a new densedata.

Parameters
[in]elemSizeSize in bytes of an element
[in]numElemsNumber of elements to include
[in]nameName of the type associated with the data

Member Function Documentation

void nrt::DenseData::resize ( size_t  size)

Resizes the data.

New data created through resizing will be zero filled and thus potentially invalid when cast to its true type

template<class T >
T & nrt::DenseData::get ( size_t  index)
inline

Gets the data located at an index.

Template Parameters
THow to interpret the data

Definition at line 55 of file DenseDataImpl.H.

template<class T >
T const & nrt::DenseData::get ( size_t  index) const
inline

Constant version of get.

Template Parameters
THow to interpret the data

Definition at line 64 of file DenseDataImpl.H.

template<class T >
T *const nrt::DenseData::ptr ( size_t  index)
inline

Returns a pointer to the specified index.

Template Parameters
THow to interpret the data

Definition at line 73 of file DenseDataImpl.H.

template<class T >
T const *const nrt::DenseData::ptr ( size_t  index) const
inline

Returns a constant pointer to the specified index.

Template Parameters
THow to interpret the data

Definition at line 82 of file DenseDataImpl.H.

template<class T >
T * nrt::DenseData::begin ( )
inline

Returns a pointer to the beginning of the data.

Template Parameters
THow to interpret the data

Definition at line 91 of file DenseDataImpl.H.

template<class T >
T const * nrt::DenseData::begin ( ) const
inline

Returns a pointer to the beginning of the data.

Template Parameters
THow to interpret the data

Definition at line 97 of file DenseDataImpl.H.

template<class T >
T * nrt::DenseData::end ( )
inline

Returns a pointer to the end of the data (one past the last element)

Template Parameters
THow to interpret the data

Definition at line 103 of file DenseDataImpl.H.

template<class T >
T const * nrt::DenseData::end ( ) const
inline

Returns a pointer to the end of the data (one past the last element)

Template Parameters
THow to interpret the data

Definition at line 109 of file DenseDataImpl.H.

size_t nrt::DenseData::insert ( )

Inserts one junk element to the end of the vector.

This is used when we do an insertion into a point cloud with a partially specified set of dense fields and need to add data to the other dense fields that were not specified. Since we don't know the type and it wouldn't necessarily be valid for us to store what a default value would look like, we'll just insert the appropriate amount of zero valued data into our array and leave it up to the user to figure out how to use it.

Returns
The external index of the newly inserted item
template<class T >
size_t nrt::DenseData::insert ( T const &  data = T())
inline

Inserts a new entry to the end of the vector.

Returns
The external index of the newly inserted item
Template Parameters
THow to interpret the data

Definition at line 115 of file DenseDataImpl.H.

void nrt::DenseData::remove ( size_t  index)

Removes the element at the specified index.

This process causes all data elements to be moved, taking O(n) time, but may be faster in actuallity due to caching and other reasons

void nrt::DenseData::quickRemove ( size_t  index)

Removes the elemnt at the specified index.

This process takes O(1) time but does not guarantee local ordering


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