Project
Loading...
Searching...
No Matches
o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT > Class Template Reference

#include <PageParser.h>

Classes

class  Iterator
 

Public Types

using PageHeaderType = PageHeaderT
 
using BufferType = unsigned char
 
using value_type = ElementT
 
using GroupType = GroupT
 
using GetNElements = GetNElementsFctT
 
using TargetInPageBuffer = std::true_type
 
using SourceInPageBuffer = std::false_type
 
using iterator = Iterator< value_type >
 
using const_iterator = Iterator< const value_type >
 

Public Member Functions

 PageParser ()=delete
 
template<typename T >
 PageParser (T *buffer, size_t size, GetNElements getNElementsFct=pageparser::defaultGetNElementsFct)
 
 ~PageParser ()
 
size_t setElement (size_t position, const value_type &element) const
 set an object at position
 
template<typename T >
size_t readGroupHeader (size_t position, T *groupHeader) const
 
bool getElement (size_t &position, value_type &element) const
 retrieve an object at position
 
template<typename SwitchT >
size_t copy (const BufferType *source, BufferType *target, size_t pageCapacity) const
 
const GroupType getGroupHeader () const
 
const_iterator begin () const
 
const_iterator end () const
 
iterator begin ()
 
iterator end ()
 

Static Public Attributes

static const size_t page_size = PageSize
 

Detailed Description

template<typename PageHeaderT, size_t PageSize, typename ElementT, typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
class o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >

Parser for a set of data objects in consecutive memory pages.

All memory pages have a fixed size and start with a page header. Depending on the page size and size of the data object, some objects can be split at the page boundary and have the page header embedded.

The class iterator can be used to iterate over the data objects transparently.

In addition data elements can be grouped. In that case a group header comes immediately after the first page header. The header has to store the number of elements which follow, a getter function has to be provided to retrieve the number from the header.

In the most simple case, the group header consists of just one element of arbitrary integral type, the parser implements a default getter function to retrieve that number. The parser can be invoked by simply specifying an integral type as GroupT template parameter.

Multiple blocks of grouped data elements can be in the group, a block can wrap over page boundery. A new block of grouped elements can however only start in a new page right after the page header.

Usage: ungrouped elements RawParser<PageHeaderType, N, ElementType> RawParser; RawParser parser(ptr, size); for (auto element : parser) { // do something with element }

Usage: grouped elements RawParser<PageHeaderType, N, ElementType, int> RawParser; RawParser parser(ptr, size); for (auto element : parser) { // do something with element }

Definition at line 163 of file PageParser.h.

Member Typedef Documentation

◆ BufferType

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::BufferType = unsigned char

Definition at line 167 of file PageParser.h.

◆ const_iterator

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::const_iterator = Iterator<const value_type>

Definition at line 457 of file PageParser.h.

◆ GetNElements

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::GetNElements = GetNElementsFctT

Definition at line 170 of file PageParser.h.

◆ GroupType

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::GroupType = GroupT

Definition at line 169 of file PageParser.h.

◆ iterator

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::iterator = Iterator<value_type>

Definition at line 456 of file PageParser.h.

◆ PageHeaderType

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::PageHeaderType = PageHeaderT

Definition at line 166 of file PageParser.h.

◆ SourceInPageBuffer

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::SourceInPageBuffer = std::false_type

Definition at line 179 of file PageParser.h.

◆ TargetInPageBuffer

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::TargetInPageBuffer = std::true_type

Definition at line 178 of file PageParser.h.

◆ value_type

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
using o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::value_type = ElementT

Definition at line 168 of file PageParser.h.

Constructor & Destructor Documentation

◆ PageParser() [1/2]

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::PageParser ( )
delete

◆ PageParser() [2/2]

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
template<typename T >
o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::PageParser ( T *  buffer,
size_t  size,
GetNElements  getNElementsFct = pageparser::defaultGetNElementsFct 
)
inline

Definition at line 183 of file PageParser.h.

◆ ~PageParser()

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::~PageParser ( )
inline

Definition at line 194 of file PageParser.h.

Member Function Documentation

◆ begin() [1/2]

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
iterator o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::begin ( )
inline

Definition at line 469 of file PageParser.h.

◆ begin() [2/2]

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
const_iterator o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::begin ( ) const
inline

Definition at line 459 of file PageParser.h.

◆ copy()

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
template<typename SwitchT >
size_t o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::copy ( const BufferType source,
BufferType target,
size_t  pageCapacity 
) const
inline

Definition at line 416 of file PageParser.h.

◆ end() [1/2]

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
iterator o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::end ( )
inline

Definition at line 480 of file PageParser.h.

◆ end() [2/2]

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
const_iterator o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::end ( ) const
inline

Definition at line 464 of file PageParser.h.

◆ getElement()

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
bool o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::getElement ( size_t &  position,
value_type element 
) const
inline

retrieve an object at position

Definition at line 345 of file PageParser.h.

◆ getGroupHeader()

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
const GroupType o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::getGroupHeader ( ) const
inline

Definition at line 451 of file PageParser.h.

◆ readGroupHeader()

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
template<typename T >
size_t o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::readGroupHeader ( size_t  position,
T *  groupHeader 
) const
inline

Definition at line 333 of file PageParser.h.

◆ setElement()

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
size_t o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::setElement ( size_t  position,
const value_type element 
) const
inline

set an object at position

Definition at line 311 of file PageParser.h.

Member Data Documentation

◆ page_size

template<typename PageHeaderT , size_t PageSize, typename ElementT , typename GroupT = void, typename GetNElementsFctT = pageparser::DefaultGetNElementsFctT<GroupT>>
const size_t o2::algorithm::PageParser< PageHeaderT, PageSize, ElementT, GroupT, GetNElementsFctT >::page_size = PageSize
static

Definition at line 171 of file PageParser.h.


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