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

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

A class for representing Sparse (one or less entries per geometry)

Sparse data is stored in an opaque map structure. When creating new Sparse data, the size in bytes of the data to be represented must be known, along with the name of the associatd data.

Access to the data is only done through typed accessors

Definition at line 115 of file SparseData.H.

Public Member Functions

 SparseData ()=default
 Creates an empty (invalid) SparseData.
 
 SparseData (size_t elemSize, std::string const &name)
 Create a new Sparsedata. More...
 
 SparseData (SparseData const &other)=default
 Copy construction.
 
 SparseData (SparseData &&other)=default
 Move construction.
 
SparseDataoperator= (SparseData const &other)=default
 Assignment.
 
SparseDataoperator= (SparseData &&other)=default
 Move assignment.
 
void clearFrom (size_t const size)
 Removes all values that have keys equal to or greater than than size.
 
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
 Gets a constant reference to the data at an index. More...
 
bool hasData (size_t const index) const
 Checks for data at a specific index.
 
template<class T >
T * ptr (size_t index)
 Returns a pointer to the specified index. More...
 
template<class T >
T const * ptr (size_t index) const
 Returns a constant pointer to the specified index. More...
 
const_iterator begin () const
 Get an iterator to the beginning of the data. More...
 
const_iterator end () const
 Get an iterator to the end of the data. More...
 
template<class T >
void insert (size_t index, T const &data)
 Inserts a new entry to the end of the vector. More...
 
void insert (size_t const index)
 Inserts one junk element to the specified index. More...
 
void append (SparseData const &other, size_t const size)
 Appends all data in another SparseData to this one. More...
 
void remove (size_t index)
 Removes the element at the specified index.
 

Friends

class cereal::access
 

Constructor & Destructor Documentation

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

Create a new Sparsedata.

Parameters
[in]elemSizeSize in bytes of an element
[in]nameName of the type associated with the data

Member Function Documentation

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

Gets the data located at an index.

Template Parameters
THow to interpret the data

Definition at line 49 of file SparseDataImpl.H.

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

Gets a constant reference to the data at an index.

Template Parameters
THow to interpret the data

Definition at line 58 of file SparseDataImpl.H.

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

Returns a pointer to the specified index.

Template Parameters
THow to interpret the data

Definition at line 69 of file SparseDataImpl.H.

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

Returns a constant pointer to the specified index.

Template Parameters
THow to interpret the data

Definition at line 78 of file SparseDataImpl.H.

const_iterator nrt::SparseData::begin ( ) const

Get an iterator to the beginning of the data.

Note that this is a map iterator and will not provide safe access to the data - you will need to correctly cast data accessed through this.

Also note that because this iterator is not type safe with what we really hold, only read-only versions are available

const_iterator nrt::SparseData::end ( ) const

Get an iterator to the end of the data.

See notes for begin()

template<class T >
void nrt::SparseData::insert ( size_t  index,
T const &  data 
)
inline

Inserts a new entry to the end of the vector.

Template Parameters
THow to interpret the data

Definition at line 89 of file SparseDataImpl.H.

void nrt::SparseData::insert ( size_t const  index)

Inserts one junk element to the specified index.

This will only be utilized immediately before an assignment in special circumstances

void nrt::SparseData::append ( SparseData const &  other,
size_t const  size 
)

Appends all data in another SparseData to this one.

Parameters
otherThe other sparse data
sizeThe size of the point cloud that we belong to

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