lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
psalg::AllocArray1D< T > Class Template Reference

Rank-1 AllocArray with std::vector-like push_back(), clear(), size() and capacity(). More...

#include <AllocArray.hh>

Inherits psalg::AllocArray< T >.

Public Member Functions

 AllocArray1D (Allocator *allocator, size_t maxElem)
 Rank-1 AllocArray from *allocator with capacity maxElem and size 0.
 
 AllocArray1D (Allocator &allocator, size_t maxElem)
 Rank-1 AllocArray from allocator with capacity maxElem and size 0.
 
 AllocArray1D (const AllocArray1D< T > &other)
 Share other's block (AllocArray copy constructor) and copy its capacity.
 
AllocArray1D< T > & operator= (const AllocArray1D< T > &other)
 Assign other as AllocArray::operator= does and copy its capacity.
 
void push_back (const T &i)
 Copy-construct i at index size() and increment the size.
 
void clear ()
 Call the destructor of each element and set the size to 0.
 
uint32_t capacity ()
 Return the capacity given to the constructor.
 
uint32_t size ()
 Return the number of elements (shape entry 0).
 
- Public Member Functions inherited from psalg::AllocArray< T >
 AllocArray (Allocator &allocator, size_t maxElem, uint32_t rank)
 Allocate one block for the shape, the reference count and maxElem elements, and set the rank, every shape entry to 0 and the count to 1.
 
 AllocArray (const AllocArray< T > &other)
 Share other's block and increment the reference count.
 
AllocArray< T > & operator= (const AllocArray< T > &other)
 Decrement this object's count, freeing its block with its allocator when the count reaches 0, then share other's block and increment that count.
 
virtual ~AllocArray ()
 Log a syslog error if the count is already <= 0, decrement it, and when it reaches 0 call the destructor of each of the num_elem() elements and free the block.
 
void incRefCnt ()
 Increment the shared reference count.
 
void decRefCnt ()
 Decrement the shared reference count.
 
uint32_t & _refCnt ()
 Return a reference to the shared reference count; public so cython can reach it (per the comment above).
 
- Public Member Functions inherited from XtcData::Array< T >
 Array (void *data, uint32_t *shape, uint32_t rank)
 Wrap data (reinterpreted as T*), shape and rank; nothing is copied.
 
 Array ()
 Construct an empty view: null data and shape pointers, rank 0.
 
 Array (const Array &a)
 Copy the data pointer, shape pointer and rank of a (shallow copy).
 
Array & operator= (const Array &o)
 Copy the data pointer, shape pointer and rank of o (shallow); self-assignment does nothing.
 
T & operator() (unsigned i)
 Return a reference to element i.
 
T & operator() (unsigned i, unsigned j)
 Return a reference to element (i, j) at offset i*shape[1]+j.
 
T & operator() (unsigned i, unsigned j, unsigned k)
 Return a reference to element (i, j, k) at the row-major offset.
 
T & operator() (unsigned i, unsigned j, unsigned k, unsigned l)
 Return a reference to element (i, j, k, l) at the row-major offset.
 
T & operator() (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m)
 Return a reference to element (i, j, k, l, m) at the row-major offset.
 
uint32_t rank () const
 Return the rank.
 
uint32_t * shape () const
 Return the shape pointer (not a copy).
 
T * data ()
 Return the data pointer.
 
const T * const_data () const
 Return the data pointer as const T*.
 
uint64_t num_elem () const
 Return the product of shape[0] .
 
void shape (uint32_t a, uint32_t b=0, uint32_t c=0, uint32_t d=0, uint32_t e=0)
 Write a, b, c, d, e into shape[0..4] (always five entries).
 
void set_rank (uint32_t rank)
 Set the rank.
 
void set_shape (uint32_t *shape)
 Set the shape pointer.
 
void set_data (void *data)
 Set the data pointer (reinterpreted as T*).
 

Additional Inherited Members

- Protected Attributes inherited from psalg::AllocArray< T >
uint32_t * _refCntPtr
 
Allocator & _allocator
 
- Protected Attributes inherited from XtcData::Array< T >
uint32_t * _shape
 
T * _data
 
uint32_t _rank
 

Detailed Description

template<typename T>
class psalg::AllocArray1D< T >

Rank-1 AllocArray with std::vector-like push_back(), clear(), size() and capacity().

Constructor & Destructor Documentation

◆ AllocArray1D() [1/3]

template<typename T >
psalg::AllocArray1D< T >::AllocArray1D ( Allocator *  allocator,
size_t  maxElem 
)
inline

Rank-1 AllocArray from *allocator with capacity maxElem and size 0.

◆ AllocArray1D() [2/3]

template<typename T >
psalg::AllocArray1D< T >::AllocArray1D ( Allocator &  allocator,
size_t  maxElem 
)
inline

Rank-1 AllocArray from allocator with capacity maxElem and size 0.

◆ AllocArray1D() [3/3]

template<typename T >
psalg::AllocArray1D< T >::AllocArray1D ( const AllocArray1D< T > &  other)
inline

Share other's block (AllocArray copy constructor) and copy its capacity.

Member Function Documentation

◆ capacity()

template<typename T >
uint32_t psalg::AllocArray1D< T >::capacity ( )
inline

Return the capacity given to the constructor.

◆ clear()

template<typename T >
void psalg::AllocArray1D< T >::clear ( )
inline

Call the destructor of each element and set the size to 0.

◆ operator=()

template<typename T >
AllocArray1D< T > & psalg::AllocArray1D< T >::operator= ( const AllocArray1D< T > &  other)
inline

Assign other as AllocArray::operator= does and copy its capacity.

Returns
*this.

◆ push_back()

template<typename T >
void psalg::AllocArray1D< T >::push_back ( const T &  i)
inline

Copy-construct i at index size() and increment the size.

When the array is full a syslog error is logged, but the element is still written past the capacity.

◆ size()

template<typename T >
uint32_t psalg::AllocArray1D< T >::size ( )
inline

Return the number of elements (shape entry 0).


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