HIPO4 C++ Library 4.4.1
Columnar I/O library for CLAS12 physics data
Loading...
Searching...
No Matches
hipo::bank::rowlist Class Reference

rowlist encapsulates a list of rows for this bank, providing a way to iterate over them More...

#include <bank.h>

Public Types

using list_t = std::vector< int >
 

Public Member Functions

 rowlist ()=default
 
 ~rowlist ()=default
 
void reset (int numRows=-1)
 initialize with a full list with specified number of rows
 
bool isInitialized () const
 
list_t constgetList () const
 
void setList (list_t const &list)
 
template<typename F , std::enable_if_t< std::is_invocable_r_v< bool, F &, bank &, int >, int > = 0>
void filter (F &&func)
 filter the list according to a function
 
void filter (char const *expression)
 filter the list according to an expression
 
void filter (Parser &p)
 filter the list according to a parsed expression
 
void setOwnerBank (bank *const ownerBank)
 

Static Public Member Functions

static list_t createFullList (int num)
 

Detailed Description

rowlist encapsulates a list of rows for this bank, providing a way to iterate over them

Member Typedef Documentation

◆ list_t

Constructor & Destructor Documentation

◆ rowlist()

hipo::bank::rowlist::rowlist ( )
default

◆ ~rowlist()

hipo::bank::rowlist::~rowlist ( )
default

Member Function Documentation

◆ reset()

void hipo::bank::rowlist::reset ( int  numRows = -1)

initialize with a full list with specified number of rows

Parameters
numRowsif negative, use the owner bank to set the number of rows, otherwise use numRows

◆ isInitialized()

bool hipo::bank::rowlist::isInitialized ( ) const
inline

◆ getList()

bank::rowlist::list_t const & hipo::bank::rowlist::getList ( ) const
Returns
reference to the immutable list

◆ setList()

void hipo::bank::rowlist::setList ( list_t const list)
Parameters
listset the list to this list

◆ filter() [1/3]

template<typename F , std::enable_if_t< std::is_invocable_r_v< bool, F &, bank &, int >, int > = 0>
void hipo::bank::rowlist::filter ( F &&  func)

filter the list according to a function

Parameters
funca callable bool(bank&, Row), where Row is any arithmetic type (int, double, float, ...); it takes a hipo::bank reference and a row number, and if it returns true, the row is accepted
Warning
the bank parameter of func MUST be an lvalue reference (bank&/bank const& or auto&/auto const&, NOT bank/bank const or auto/auto const), otherwise you may create a (rare) data race: passing the bank by value copies it each row, and the copy shallow-aliases the original's internal buffer pointer. This is now rejected at compile time with a static_assert:
// this is okay: the bank parameter is passed by lvalue reference
my_bank.getMutableRowList().filter([](auto& bank, auto row) { ..... });
// this is a COMPILE ERROR: the bank parameter is passed by value (no ampersand '&')
my_bank.getMutableRowList().filter([](auto bank, auto row) { ..... });
Definition bank.h:211
T get(int item, int index) const noexcept
Definition bank.h:321
Note
the std::enable_if_t enables this overload only for callables, so the char const* and Parser& overloads below are still selected for their argument types. Defined out-of-line below, after bank is complete.

◆ filter() [2/3]

void hipo::bank::rowlist::filter ( char const expression)

filter the list according to an expression

Parameters
expressionthe filter expression

◆ filter() [3/3]

void hipo::bank::rowlist::filter ( Parser p)

filter the list according to a parsed expression

Parameters
pthe parser with the filter expression

◆ createFullList()

bank::rowlist::list_t hipo::bank::rowlist::createFullList ( int  num)
static
Returns
create a list of numbers from 0 to num
Parameters
numthe size of the list

◆ setOwnerBank()

void hipo::bank::rowlist::setOwnerBank ( bank *const  ownerBank)
inline
Parameters
ownerBankset the owner bank

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