A Hopf, Skip and a Jump
Public Member Functions | Protected Attributes | List of all members
slidingbuffer::Segment< T, P > Class Template Reference

A Segment is an aggregation of base data with a SlidingBuffer. More...

#include <slidingbuffer.h>

Public Member Functions

 Segment (const std::size_t size, const std::size_t origin, P &sp)
 Construct a Segment. More...
 
virtual ~Segment ()
 Destroy this object and all the entities it contains.
 
T & operator[] (std::size_t idx)
 Access an entity, waiting for it to be constructed if deferred construction is still taking place. More...
 
std::size_t get_size (void) const
 Get the Segment's size. More...
 

Protected Attributes

T * seg
 Dynamic array of entities in storage.
 
bool valid
 Indicates entities have been constructed (for deferred initialisation: not yet implemented). More...
 
std::size_t size
 Number of entities held.
 
const std::size_t origin
 Index of the first entity in this Segment from the point of view of the SlidingBuffer. More...
 
P & sp
 The producer invoked to fill this Segment.
 

Detailed Description

template<typename T, typename P>
class slidingbuffer::Segment< T, P >

A Segment is an aggregation of base data with a SlidingBuffer.

It is the underlying blocksize which is required of a SegmentProducer.

Segements provide an implementation of the [] operator; however, access to the underlying data would normally be via the aggregating class SlidingBuffer. Classes derived from SlidingBuffer may need to access the segements' data directly, however.

Template Parameters
TThe type of each entity stored in the Segment.
PThe type of the Segment's Producer.

Definition at line 137 of file slidingbuffer.h.

Constructor & Destructor Documentation

◆ Segment()

template<typename T, typename P>
slidingbuffer::Segment< T, P >::Segment ( const std::size_t  size,
const std::size_t  origin,
P &  sp 
)
inline

Construct a Segment.

Parameters
sizeThe number of base entities to be held in the segment.
originThe offset with in the aggregating SlidingBuffer of the first element in this Segment
spThe Producer for this Segment

Definition at line 153 of file slidingbuffer.h.

Member Function Documentation

◆ get_size()

template<typename T, typename P>
std::size_t slidingbuffer::Segment< T, P >::get_size ( void  ) const
inline

Get the Segment's size.

Returns
Number of entities stored in this Segment

Definition at line 190 of file slidingbuffer.h.

◆ operator[]()

template<typename T, typename P>
T& slidingbuffer::Segment< T, P >::operator[] ( std::size_t  idx)
inline

Access an entity, waiting for it to be constructed if deferred construction is still taking place.

Since deferred construction is not yet implemented, this method currently returns the entity reference immediately.

Parameters
idxIndex of the entity within this segment.
Returns
Reference to the indexed entity

Definition at line 176 of file slidingbuffer.h.

Member Data Documentation

◆ origin

template<typename T, typename P>
const std::size_t slidingbuffer::Segment< T, P >::origin
protected

Index of the first entity in this Segment from the point of view of the SlidingBuffer.

Definition at line 143 of file slidingbuffer.h.

◆ valid

template<typename T, typename P>
bool slidingbuffer::Segment< T, P >::valid
protected

Indicates entities have been constructed (for deferred initialisation: not yet implemented).

Definition at line 140 of file slidingbuffer.h.


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