Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LhaBlock Class Reference

Represents an LHA/FLHA block with multiple typed elements. More...

#include <lha_blocks.h>

Public Member Functions

 LhaBlock (const Prototype &prototype_)
 Constructs an LhaBlock using a specified prototype.
 
void readData (const std::vector< std::vector< std::string > > &lines)
 Reads data and populates the block with elements from raw lines.
 
bool hasElement (const LhaID &id) const
 Checks whether an element is present in the block.
 
bool hasElement (const std::vector< long > &id) const
 Convenience overload: checks presence from raw ID parts.
 
AbstractElementget (const LhaID &id) const
 Retrieves an element by its identifier.
 
AbstractElementget (const std::vector< long > &id) const
 Convenience overload: retrieves an element from raw ID parts.
 
const std::vector< std::shared_ptr< AbstractElement > > * getEntries () const
 Returns a read-only view of all entries in the block.
 
void addElement (const std::vector< std::string > &line)
 Adds a new element to the block from a line of data.
 
Prototype getPrototype ()
 Returns the Prototype associated with this block.
 
std::string toString () const
 Serializes the block and all its entries to a string.
 
std::shared_ptr< DBNodetoDBNode () const
 Converts the block and its entries to a DBNode representation.
 
 ~LhaBlock ()
 Destructor for LhaBlock.
 

Detailed Description

Represents an LHA/FLHA block with multiple typed elements.

An LhaBlock:

  • is defined by a Prototype that describes the block layout (value column, scale column, etc.),
  • owns a list of entries (AbstractElement) created from parsed lines,
  • provides lookup by LhaID,
  • can be serialized to a human-readable string or to a DBNode.

Definition at line 34 of file lha_blocks.h.

Constructor & Destructor Documentation

◆ LhaBlock()

LhaBlock::LhaBlock ( const Prototype prototype_)
inlineexplicit

Constructs an LhaBlock using a specified prototype.

The block starts empty; elements are later added via readData() or addElement().

Parameters
prototypePrototype defining the block structure.

Definition at line 48 of file lha_blocks.h.

◆ ~LhaBlock()

LhaBlock::~LhaBlock ( )
inline

Destructor for LhaBlock.

Clears the entries vector; shared_ptr semantics ensure any remaining elements are properly destroyed when no longer referenced.

Definition at line 169 of file lha_blocks.h.

Member Function Documentation

◆ addElement()

void LhaBlock::addElement ( const std::vector< std::string > &  line)

Adds a new element to the block from a line of data.

The line is interpreted according to this block's Prototype and passed to LhaElementFactory::createElement().

Parameters
lineTokens representing one block entry.
Exceptions
std::runtime_errorif the line is incompatible with the prototype.

Definition at line 40 of file lha_blocks.cpp.

◆ get() [1/2]

AbstractElement * LhaBlock::get ( const LhaID id) const

Retrieves an element by its identifier.

Performs a linear search and returns a non-owning pointer to the stored element if found.

Parameters
idIdentifier of the element.
Returns
Pointer to AbstractElement if found, nullptr otherwise.

Definition at line 3 of file lha_blocks.cpp.

◆ get() [2/2]

AbstractElement * LhaBlock::get ( const std::vector< long > &  id) const
inline

Convenience overload: retrieves an element from raw ID parts.

Constructs an LhaID from id and forwards to get(const LhaID&).

Parameters
idComponents of the identifier.
Returns
Pointer to AbstractElement if found, nullptr otherwise.

Definition at line 102 of file lha_blocks.h.

◆ getEntries()

const std::vector< std::shared_ptr< AbstractElement > > * LhaBlock::getEntries ( ) const

Returns a read-only view of all entries in the block.

The lifetime of the returned pointer is tied to the LhaBlock instance. It must not be deleted by the caller.

Returns
Pointer to the internal vector of shared_ptr<AbstractElement>.

Definition at line 12 of file lha_blocks.cpp.

◆ getPrototype()

Prototype LhaBlock::getPrototype ( )
inline

Returns the Prototype associated with this block.

The prototype is returned by value (copy).

Returns
Prototype describing this block.

Definition at line 133 of file lha_blocks.h.

◆ hasElement() [1/2]

bool LhaBlock::hasElement ( const LhaID id) const

Checks whether an element is present in the block.

This performs a linear search over the stored entries and compares their LhaID with id.

Parameters
idIdentifier of the element.
Returns
true if an element with this id exists, false otherwise.

Definition at line 53 of file lha_blocks.cpp.

◆ hasElement() [2/2]

bool LhaBlock::hasElement ( const std::vector< long > &  id) const
inline

Convenience overload: checks presence from raw ID parts.

Constructs an LhaID from id and forwards to hasElement(const LhaID&).

Parameters
idComponents of the identifier.
Returns
true if an element with this id exists, false otherwise.

Definition at line 81 of file lha_blocks.h.

◆ readData()

void LhaBlock::readData ( const std::vector< std::vector< std::string > > &  lines)

Reads data and populates the block with elements from raw lines.

Each non-empty line is passed to LhaElementFactory::createElement() together with this block's prototype to create the appropriate LhaElement<T>, which is then stored in the block.

Parameters
linesVector of tokenized lines; each inner vector represents one block entry (split into string fields).

Definition at line 45 of file lha_blocks.cpp.

◆ toDBNode()

std::shared_ptr< DBNode > LhaBlock::toDBNode ( ) const

Converts the block and its entries to a DBNode representation.

The resulting node has the following structure:

  • If the prototype has globalScale == true, the node stores: "scale" : <double> (taken from the first entry)
  • Under a child block named prototype.blockName, each entry is stored as: "<id>" : <DBNode> (DBNode produced by entry->toDBNode())
Returns
Shared pointer to the root DBNode representing this block.

Definition at line 26 of file lha_blocks.cpp.

◆ toString()

std::string LhaBlock::toString ( ) const

Serializes the block and all its entries to a string.

The format is: "Block <BLOCKNAME>:\n" "<entry1>\n" "<entry2>\n" ... where each entry line is produced by AbstractElement::toString().

Returns
Human-readable string representation of the block.

Definition at line 16 of file lha_blocks.cpp.


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