The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::ArchData::Line Class Reference

Line object which composes part of an entire ArchData. More...

#include <ArchData.hpp>

Public Member Functions

 Line (line_idx_type idx, offset_type offset, offset_type size, uint64_t initial, uint32_t initial_val_size, uint8_t *pool_ptr=0)
 Line constructor.
 
 Line (const Line &)=delete
 Disallow copies, moves, and assignments.
 
 Line (Line &&)=delete
 
Lineoperator= (const Line &)=delete
 
void updateFrom (const Line &other)
 
void flagDirty ()
 Allows caller to explicitly flag this line as dirty.
 
void fillWithInitial (uint64_t initial, uint32_t initial_val_size)
 Fills the line's data with the initial value.
 
template<typename StorageT >
void restore (StorageT &in)
 Restore data from input buffer.
 
template<typename StorageT >
void save (StorageT &out)
 Store data to output buffer.
 
line_idx_type getIdx () const
 Index of this line (typically offset/line_size)
 
offset_type getOffset () const
 Offset into the owning ArchData.
 
offset_type getLayoutSize () const
 Size of this line's data including padding. Accessing bytes from this line with an offset greater than or equal to this value is invalid.
 
bool isDirty () const
 Has this line been modified since the last save or restore. Immediately after construction, this will be true.
 
const uint8_t * getDataPointer (offset_type offset) const
 Gets a pointer to data within this line for direct read access.
 
uint8_t * getRawDataPtr (const offset_type offset)
 return the raw data pointer for this line for direct read and write. No error checking is performed. Should be used with care.
 
Reading and Writing
template<typename T , ByteOrder BO>
read (offset_type offset, uint32_t idx=0) const
 Read from this line, reordering bytes based on byte order if required.
 
void read (offset_type offset, offset_type size, uint8_t *data) const
 Read a number of contiguous bytes from this line.
 
template<typename T , ByteOrder BO>
void write (offset_type offset, const T &t, uint32_t idx=0)
 Write to this line, reordering bytes based on byte order if required.
 
void write (offset_type offset, offset_type size, const uint8_t *data) const
 Write a number of contiguous bytes to this line.
 

Static Public Attributes

static constexpr char QUICK_CHECKPOINT_PREFIX [] = "<L>"
 Prefix for Line checkpoint entries.
 
static const uint32_t QUICK_CHECKPOINT_OFFSET_SIZE = 7
 Size of offset and size entries in quick checkpoint.
 

Detailed Description

Line object which composes part of an entire ArchData.

Data of line is always allocated when line is constructed unless a pool_ptr is given at construction.

Allocated line is dirty by default. An ArchData should not allocate a line being read if the initial value is known.

Definition at line 157 of file ArchData.hpp.

Constructor & Destructor Documentation

◆ Line()

sparta::ArchData::Line::Line ( line_idx_type  idx,
offset_type  offset,
offset_type  size,
uint64_t  initial,
uint32_t  initial_val_size,
uint8_t *  pool_ptr = 0 
)
inline

Line constructor.

Parameters
idxIndex of this line
offsetEffective address offset of this line from the starting memory range of the owning ArchData.
sizebytes contained in this line. Assumes this is a power of 2 and greather than 0.
initialInital value to fill all data in this line with. The data is set regardless of whether memory comes from a pool or is allocated here.
initial_val_sizeSize of initial value in bytes
pool_ptroptional pointer into pool data which contains <size> number of bytes reserved exclusively for this Line. ArchData can allocate one pool for each line and assign each line a position within that pool to improve data locality.

A newly-constructed line is always flagged as dirty and all bytes set to <initial>.

Definition at line 183 of file ArchData.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ fillWithInitial()

void sparta::ArchData::Line::fillWithInitial ( uint64_t  initial,
uint32_t  initial_val_size 
)
inline

Fills the line's data with the initial value.

Parameters
initialValue to write to this Line's memory
initial_val_sizeBytes to use of initial value

Definition at line 235 of file ArchData.hpp.

Here is the call graph for this function:

◆ flagDirty()

void sparta::ArchData::Line::flagDirty ( )
inline

Allows caller to explicitly flag this line as dirty.

The only way to clear a dirty flag is to save this ArchData.

Definition at line 226 of file ArchData.hpp.

◆ getDataPointer()

const uint8_t * sparta::ArchData::Line::getDataPointer ( offset_type  offset) const
inline

Gets a pointer to data within this line for direct read access.

Parameters
offsetOffset into this line in bytes
Returns
Pointer to const memory. This method should be used for reading data only since writes are required to flag this dataview as dirty

Definition at line 395 of file ArchData.hpp.

◆ getIdx()

line_idx_type sparta::ArchData::Line::getIdx ( ) const
inline

Index of this line (typically offset/line_size)

Definition at line 272 of file ArchData.hpp.

◆ getLayoutSize()

offset_type sparta::ArchData::Line::getLayoutSize ( ) const
inline

Size of this line's data including padding. Accessing bytes from this line with an offset greater than or equal to this value is invalid.

Definition at line 288 of file ArchData.hpp.

◆ getOffset()

offset_type sparta::ArchData::Line::getOffset ( ) const
inline

Offset into the owning ArchData.

Definition at line 279 of file ArchData.hpp.

◆ getRawDataPtr()

uint8_t * sparta::ArchData::Line::getRawDataPtr ( const offset_type  offset)
inline

return the raw data pointer for this line for direct read and write. No error checking is performed. Should be used with care.

Definition at line 403 of file ArchData.hpp.

◆ isDirty()

bool sparta::ArchData::Line::isDirty ( ) const
inline

Has this line been modified since the last save or restore. Immediately after construction, this will be true.

Definition at line 296 of file ArchData.hpp.

◆ read() [1/2]

void sparta::ArchData::Line::read ( offset_type  offset,
offset_type  size,
uint8_t *  data 
) const
inline

Read a number of contiguous bytes from this line.

Parameters
offsetOffset in bytes into this line
sizeSize of the read in bytes
dataBuffer to populate with size bytes copied from this ArchData
Note
offset+size must be <= the size of this line

Definition at line 335 of file ArchData.hpp.

◆ read() [2/2]

template<typename T , ByteOrder BO>
T sparta::ArchData::Line::read ( offset_type  offset,
uint32_t  idx = 0 
) const
inline

Read from this line, reordering bytes based on byte order if required.

Template Parameters
Ttype of variable to read (e.g. uint32_t). This dictates access size
BOByte-order of access when read from memory
Parameters
offsetOffset in bytes into this line
idxIndex into this line as a multiple of sizeof(T) bytes
Returns
The value read
Note
offset+((idx+1)*sizeof(T)) must be <= the size of this line

Definition at line 316 of file ArchData.hpp.

◆ restore()

template<typename StorageT >
void sparta::ArchData::Line::restore ( StorageT &  in)
inline

Restore data from input buffer.

Parameters
inInput buffer. Must contain bytes equal to the size of the Line. All bytes will be read
Postcondition
dirty flag cleared for this line
Exceptions
SpartaExceptionif in could not be read as expected.

Definition at line 249 of file ArchData.hpp.

◆ save()

template<typename StorageT >
void sparta::ArchData::Line::save ( StorageT &  out)
inline

Store data to output buffer.

Parameters
outOutput buffer. Must allow writing a number of bytes equal to the size of this Line. All bytes will be written
Postcondition
dirty flag cleared for this line
Exceptions
SpartaExceptionif out could not be written as expected.

Definition at line 264 of file ArchData.hpp.

◆ updateFrom()

void sparta::ArchData::Line::updateFrom ( const Line other)
inline

Definition at line 214 of file ArchData.hpp.

◆ write() [1/2]

template<typename T , ByteOrder BO>
void sparta::ArchData::Line::write ( offset_type  offset,
const T &  t,
uint32_t  idx = 0 
)
inline

Write to this line, reordering bytes based on byte order if required.

Template Parameters
Ttype of variable to write (e.g. uint32_t). This dictates access size
BOByte-order of access when written to memory
Parameters
offsetOffset in bytes into this line
idxIndex into this line as a multiple of sizeof(T) bytes
Note
offset+((idx+1)*sizeof(T)) must be <= the size of this line

Definition at line 354 of file ArchData.hpp.

◆ write() [2/2]

void sparta::ArchData::Line::write ( offset_type  offset,
offset_type  size,
const uint8_t *  data 
) const
inline

Write a number of contiguous bytes to this line.

Parameters
offsetOffset in bytes into this line
sizeSize of the write in bytes
dataBuffer containing size bytes to copy to this object
Note
offset+size must be <= the size of this line

Definition at line 375 of file ArchData.hpp.

Member Data Documentation

◆ QUICK_CHECKPOINT_OFFSET_SIZE

const uint32_t sparta::ArchData::Line::QUICK_CHECKPOINT_OFFSET_SIZE = 7
static

Size of offset and size entries in quick checkpoint.

Definition at line 162 of file ArchData.hpp.

◆ QUICK_CHECKPOINT_PREFIX

constexpr char sparta::ArchData::Line::QUICK_CHECKPOINT_PREFIX[] = "<L>"
staticconstexpr

Prefix for Line checkpoint entries.

Definition at line 161 of file ArchData.hpp.


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