pstore2
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
pstore::header Class Reference

The data store file header. More...

#include <file_header.hpp>

Collaboration diagram for pstore::header:
Collaboration graph
[legend]

Classes

struct  body
 Represents the portion of the header structure which is covered by the computed CRC value. More...
 

Public Member Functions

bool is_valid () const noexcept
 
std::uint32_t get_crc () const noexcept
 Computes the CRC value for the header.
 
uuid id () const noexcept
 Returns the database ID. More...
 
void set_id (uuid const &id) noexcept
 
std::array< std::uint16_t, 2 > const & version () const noexcept
 Returns the file format version number (major, minor).
 

Public Attributes

body a
 
std::uint32_t crc = 0
 The fields of the header, up to and including this one, are not modified as the code interacts with the data store; they're effectively read-only. More...
 
std::uint32_t unused1 = 0
 
std::atomic< typed_address< trailer > > footer_pos
 The file offset of the current (most recent) file footer. More...
 

Static Public Attributes

static constexpr std::uint16_t major_version = 1
 
static constexpr std::uint16_t minor_version = 12
 
static std::array< std::uint8_t, 4 > const file_signature1 {{'p', 'S', 't', 'r'}}
 
static std::uint32_t const file_signature2 = 0x0507FFFF
 

Detailed Description

The data store file header.

Member Function Documentation

◆ id()

uuid pstore::header::id ( ) const
inlinenoexcept

Returns the database ID.

When created, each pstore file has a unique ID number. It is preserved by import/export and strip/merge. External references may use this ID to check that they are referring to the correct database.

Member Data Documentation

◆ crc

std::uint32_t pstore::header::crc = 0

The fields of the header, up to and including this one, are not modified as the code interacts with the data store; they're effectively read-only.

Unfortunately, we can't make them physically read-only – for example by marking the containing memory page as read-only – because the library does need to be able to modify the footer_pos field when a transaction is committed.

This crc is used to ensure that the fields from #signature1 to #sync_name are not modified.

◆ footer_pos

std::atomic<typed_address<trailer> > pstore::header::footer_pos

The file offset of the current (most recent) file footer.

This value is modified as the the very last step of commiting a transaction.


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