Voxomap
A C++11 voxel container.
voxomap::AbstractSparseIDArray< T, T_Size, T_Container > Class Template Reference

#include <SparseIDArray.hpp>

Classes

struct  SerializationData
 

Public Member Functions

uint16_t getNbData () const
 Returns number of datas. More...
 
bool hasData (uint8_t x) const
 Check if there is data inside. More...
 
bool hasData (uint8_t x, uint8_t y) const
 Check if there is data inside. More...
 
bool hasData (uint8_t x, uint8_t y, uint8_t z) const
 Check if data exist. More...
 
T * findData (uint8_t x, uint8_t y, uint8_t z)
 Find data. More...
 
T const * findData (uint8_t x, uint8_t y, uint8_t z) const
 Find data. More...
 
template<typename... Args>
bool addData (uint8_t x, uint8_t y, uint8_t z, T *&data, Args &&... args)
 Add a data, don't update an existing data. More...
 
template<typename... Args>
bool updateData (uint8_t x, uint8_t y, uint8_t z, T *&data, Args &&... args)
 Update an existing data, don't create a new one. More...
 
template<typename... Args>
void putData (uint8_t x, uint8_t y, uint8_t z, T *&data, Args &&... args)
 Add or update a data. More...
 
bool removeData (uint8_t x, uint8_t y, uint8_t z)
 Remove an existing data. More...
 
bool removeData (uint8_t x, uint8_t y, uint8_t z, T *data)
 Remove an existing data. More...
 
void serialize (std::string &str) const
 Serialize the structure. More...
 
size_t unserialize (char const *str, size_t size)
 Unserialize str inside this. More...
 
void shrinkToFit ()
 Requests the sparse array to reduce its capacity to fit its size. More...
 

Protected Member Functions

 AbstractSparseIDArray ()
 Default constructor. More...
 
 AbstractSparseIDArray (AbstractSparseIDArray const &other)
 Copy constructor. More...
 
uint16_t getId (uint8_t x, uint8_t y, uint8_t z) const
 
void setId (uint8_t x, uint8_t y, uint8_t z, uint16_t id)
 
uint16_t getNewId ()
 
template<typename T_Old , typename T_New >
void reallocIds ()
 
template<typename Type >
void changeId (uint16_t oldId, uint16_t newId)
 
template<typename Type >
void reset (Type &data)
 
template<typename Type >
void reset (std::unique_ptr< Type > &data)
 
template<typename Type >
void reset (std::shared_ptr< Type > &data)
 
template<typename T_Data >
void copy (T_Container< T_Data > const &other)
 
template<typename T_Data >
void copy (T_Container< std::unique_ptr< T_Data >> const &other)
 
template<typename T_Data >
std::enable_if< std::is_trivially_copyable< T_Data >::value >::type serializeContainer (std::string &str, T_Container< T_Data > const &datas) const
 
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable< T_Data >::value >::type serializeContainer (std::string &str, T_Container< T_Data > const &datas) const
 
template<typename T_Data >
void serializeContainer (std::string &str, T_Container< T_Data * > const &datas) const
 
template<typename T_Data >
void serializeContainer (std::string &str, T_Container< std::unique_ptr< T_Data >> const &datas) const
 
template<typename T_Data >
void serializeContainer (std::string &str, T_Container< std::shared_ptr< T_Data >> const &datas) const
 
template<typename T_Data >
std::enable_if< std::is_trivially_copyable< T_Data >::value >::type serializeData (std::string &str, T_Data const &data) const
 
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable< T_Data >::value >::type serializeData (std::string &str, T_Data const &data) const
 
template<typename T_Data >
std::enable_if< std::is_trivially_copyable< T_Data >::value, size_t >::type unserializeContainer (char const *str, size_t size, T_Container< T_Data > &datas)
 
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable< T_Data >::value, size_t >::type unserializeContainer (char const *str, size_t size, T_Container< T_Data > &datas)
 
template<typename T_Data >
size_t unserializeContainer (char const *str, size_t size, T_Container< T_Data * > &datas)
 
template<typename T_Data >
size_t unserializeContainer (char const *str, size_t size, T_Container< std::unique_ptr< T_Data >> &datas)
 
template<typename T_Data >
size_t unserializeContainer (char const *str, size_t size, T_Container< std::shared_ptr< T_Data >> &datas)
 
template<typename T_Data >
std::enable_if< std::is_trivially_copyable< T_Data >::value, size_t >::type unserializeData (char const *str, size_t size, T_Data &data)
 
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable< T_Data >::value, size_t >::type unserializeData (char const *str, size_t size, T_Data &data)
 

Protected Attributes

T_Container< T > _data
 
T_Container< uint16_t > _idFreed
 
std::unique_ptr< uint8_t[]> _ids
 

Detailed Description

template<typename T, uint8_t T_Size, template< class... > class T_Container = std::vector>
class voxomap::AbstractSparseIDArray< T, T_Size, T_Container >

Definition at line 17 of file SparseIDArray.hpp.

Constructor & Destructor Documentation

◆ AbstractSparseIDArray() [1/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::AbstractSparseIDArray ( )
protected

Default constructor.

◆ AbstractSparseIDArray() [2/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::AbstractSparseIDArray ( AbstractSparseIDArray< T, T_Size, T_Container > const &  other)
protected

Copy constructor.

Member Function Documentation

◆ getNbData()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
uint16_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::getNbData ( ) const

Returns number of datas.

◆ hasData() [1/3]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::hasData ( uint8_t  x) const

Check if there is data inside.

Parameters
xX index
Returns
True if there is a data

◆ hasData() [2/3]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::hasData ( uint8_t  x,
uint8_t  y 
) const

Check if there is data inside.

Parameters
xX index
yY index
Returns
True if there is a data

◆ hasData() [3/3]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::hasData ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const

Check if data exist.

Parameters
xX index
yY index
zZ index
Returns
True if data exist

◆ findData() [1/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
T* voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::findData ( uint8_t  x,
uint8_t  y,
uint8_t  z 
)

Find data.

Parameters
xX index
yY index
zZ index
Returns
The data if exists, otherwise nullptr

◆ findData() [2/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
T const* voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::findData ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const

Find data.

Parameters
xX index
yY index
zZ index
Returns
The data if exists, otherwise nullptr

◆ addData()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename... Args>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::addData ( uint8_t  x,
uint8_t  y,
uint8_t  z,
T *&  data,
Args &&...  args 
)

Add a data, don't update an existing data.

Parameters
xX position of the data
yY position of the data
zZ position of the data
dataReturn the pointer on the data created
argsArguments to forward to data constructor
Returns
True if success

◆ updateData()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename... Args>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::updateData ( uint8_t  x,
uint8_t  y,
uint8_t  z,
T *&  data,
Args &&...  args 
)

Update an existing data, don't create a new one.

Parameters
xX position of the data
yY position of the data
zZ position of the data
dataReturn the pointer on the data updated
argsArguments to forward to data constructor
Returns
True if success

◆ putData()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename... Args>
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::putData ( uint8_t  x,
uint8_t  y,
uint8_t  z,
T *&  data,
Args &&...  args 
)

Add or update a data.

Parameters
xX position of the data
yY position of the data
zZ position of the data
dataReturn the pointer on the data created or updated
argsArguments to forward to data constructor

◆ removeData() [1/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::removeData ( uint8_t  x,
uint8_t  y,
uint8_t  z 
)

Remove an existing data.

Parameters
xX position of the data
yY position of the data
zZ position of the data
dataPointer on a data structure, filled with the data of the removed data
Returns
True if success

◆ removeData() [2/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
bool voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::removeData ( uint8_t  x,
uint8_t  y,
uint8_t  z,
T *  data 
)

Remove an existing data.

Parameters
xX position of the data
yY position of the data
zZ position of the data
dataPointer on a data structure, filled with the data of the removed data
Returns
True if success

◆ serialize()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serialize ( std::string &  str) const

Serialize the structure.

Parameters
strString use for save the serialization

◆ unserialize()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
size_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserialize ( char const *  str,
size_t  size 
)

Unserialize str inside this.

Parameters
strString that contains data
sizeSize of the string
Returns
Number of bytes read inside str

◆ shrinkToFit()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::shrinkToFit ( )

Requests the sparse array to reduce its capacity to fit its size.

◆ getId()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
uint16_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::getId ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const
protected

◆ setId()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::setId ( uint8_t  x,
uint8_t  y,
uint8_t  z,
uint16_t  id 
)
protected

◆ getNewId()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
uint16_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::getNewId ( )
protected

◆ reallocIds()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Old , typename T_New >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::reallocIds ( )
protected

◆ changeId()

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename Type >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::changeId ( uint16_t  oldId,
uint16_t  newId 
)
protected

◆ reset() [1/3]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename Type >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::reset ( Type &  data)
protected

◆ reset() [2/3]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename Type >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::reset ( std::unique_ptr< Type > &  data)
protected

◆ reset() [3/3]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename Type >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::reset ( std::shared_ptr< Type > &  data)
protected

◆ copy() [1/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::copy ( T_Container< T_Data > const &  other)
protected

◆ copy() [2/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::copy ( T_Container< std::unique_ptr< T_Data >> const &  other)
protected

◆ serializeContainer() [1/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<std::is_trivially_copyable<T_Data>::value>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeContainer ( std::string &  str,
T_Container< T_Data > const &  datas 
) const
protected

◆ serializeContainer() [2/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable<T_Data>::value>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeContainer ( std::string &  str,
T_Container< T_Data > const &  datas 
) const
protected

◆ serializeContainer() [3/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeContainer ( std::string &  str,
T_Container< T_Data * > const &  datas 
) const
protected

◆ serializeContainer() [4/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeContainer ( std::string &  str,
T_Container< std::unique_ptr< T_Data >> const &  datas 
) const
protected

◆ serializeContainer() [5/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
void voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeContainer ( std::string &  str,
T_Container< std::shared_ptr< T_Data >> const &  datas 
) const
protected

◆ serializeData() [1/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<std::is_trivially_copyable<T_Data>::value>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeData ( std::string &  str,
T_Data const &  data 
) const
protected

◆ serializeData() [2/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable<T_Data>::value>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::serializeData ( std::string &  str,
T_Data const &  data 
) const
protected

◆ unserializeContainer() [1/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<std::is_trivially_copyable<T_Data>::value, size_t>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeContainer ( char const *  str,
size_t  size,
T_Container< T_Data > &  datas 
)
protected

◆ unserializeContainer() [2/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable<T_Data>::value, size_t>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeContainer ( char const *  str,
size_t  size,
T_Container< T_Data > &  datas 
)
protected

◆ unserializeContainer() [3/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
size_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeContainer ( char const *  str,
size_t  size,
T_Container< T_Data * > &  datas 
)
protected

◆ unserializeContainer() [4/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
size_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeContainer ( char const *  str,
size_t  size,
T_Container< std::unique_ptr< T_Data >> &  datas 
)
protected

◆ unserializeContainer() [5/5]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
size_t voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeContainer ( char const *  str,
size_t  size,
T_Container< std::shared_ptr< T_Data >> &  datas 
)
protected

◆ unserializeData() [1/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<std::is_trivially_copyable<T_Data>::value, size_t>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeData ( char const *  str,
size_t  size,
T_Data &  data 
)
protected

◆ unserializeData() [2/2]

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
template<typename T_Data >
std::enable_if<!std::is_trivially_copyable<T_Data>::value, size_t>::type voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::unserializeData ( char const *  str,
size_t  size,
T_Data &  data 
)
protected

Member Data Documentation

◆ _data

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
T_Container<T> voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::_data
protected

Definition at line 211 of file SparseIDArray.hpp.

◆ _idFreed

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
T_Container<uint16_t> voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::_idFreed
protected

Definition at line 212 of file SparseIDArray.hpp.

◆ _ids

template<typename T , uint8_t T_Size, template< class... > class T_Container = std::vector>
std::unique_ptr<uint8_t[]> voxomap::AbstractSparseIDArray< T, T_Size, T_Container >::_ids
protected

Definition at line 213 of file SparseIDArray.hpp.


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