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

Stack-based implementation of IDBMemento for BlockAccessor. More...

#include <DBMemento.h>

Inheritance diagram for DBMemento:
Collaboration diagram for DBMemento:

Public Member Functions

void takeSnapshot (std::shared_ptr< BlockAccessor > blocks)
 Takes a snapshot of the given BlockAccessor.
 
void restore (size_t n_steps=1)
 Restores the state n_steps snapshots back.
 
void print_snapshot_content (size_t n=0)
 Prints the content of a stored snapshot.
 
size_t stack_size ()
 Returns the number of snapshots currently stored.
 
- Public Member Functions inherited from IDBMemento
virtual ~IDBMemento ()=default
 Virtual destructor for proper polymorphic cleanup.
 
virtual void restore (std::size_t n_steps=1)=0
 Restores the state n_steps snapshots back.
 
virtual void print_snapshot_content (std::size_t n=0)=0
 Prints the content of a stored snapshot.
 

Detailed Description

Stack-based implementation of IDBMemento for BlockAccessor.

DBMemento maintains an internal stack of BlockAccessor snapshots: each call to takeSnapshot() pushes a new copy onto the stack, while restore() pops one or more entries and overwrites the target BlockAccessor with the stored state.

This is used by MemoryManager to:

  • save the state after loading default inputs,
  • restore prior states when reloading user input or switching LHA files.
See also
IDBMemento
BlockAccessor
MemoryManager

Definition at line 39 of file DBMemento.h.

Member Function Documentation

◆ print_snapshot_content()

void DBMemento::print_snapshot_content ( size_t  n = 0)

Prints the content of a stored snapshot.

Mainly for debugging. If n is 0, it usually refers to the most recent snapshot (implementation dependent).

Parameters
nIndex of the snapshot to print (default 0).

Definition at line 20 of file DBMemento.cpp.

◆ restore()

void DBMemento::restore ( size_t  n_steps = 1)

Restores the state n_steps snapshots back.

Pops up to n_steps snapshots from the internal stack and uses the last popped snapshot to overwrite the current BlockAccessor state.

Parameters
n_stepsNumber of snapshots to roll back (default 1).

Definition at line 7 of file DBMemento.cpp.

◆ stack_size()

size_t DBMemento::stack_size ( )
virtual

Returns the number of snapshots currently stored.

Returns
Size of the snapshot stack.

Implements IDBMemento.

Definition at line 39 of file DBMemento.cpp.

◆ takeSnapshot()

void DBMemento::takeSnapshot ( std::shared_ptr< BlockAccessor blocks)
virtual

Takes a snapshot of the given BlockAccessor.

The snapshot is stored internally and can be restored later with restore().

Parameters
blocksShared pointer to the BlockAccessor to snapshot.

Implements IDBMemento.

Definition at line 3 of file DBMemento.cpp.


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