IDS peak ICV v1.5.0
Loading...
Searching...
No Matches
Archive Class Referenceabstract

#include <peak_icv/serialization/peak_icv_archive.hpp>

Inheritance diagram for Archive:

Public Types

enum class  ValueType {
  Bool ,
  BoolArray ,
  Int ,
  IntArray ,
  Double ,
  DoubleArray ,
  String ,
  StringArray ,
  Archive ,
  ArchiveArray
}
 Enumerates supported value types that can be stored or queried in the archive. More...
 

Public Member Functions

 Archive ()
 Constructs an empty Archive instance.
 
 ~Archive () override
 Virtual destructor.
 
 Archive (const Archive &)=delete
 Archive instances cannot be copied.
 
Archive & operator= (const Archive &)=delete
 Archive instances cannot be copy-assigned.
 
 Archive (Archive &&other) noexcept
 Constructs an Archive by moving from another instance.
 
Archive & operator= (Archive &&other) noexcept
 Assigns this archive by moving from another instance.
 
std::shared_ptr< IArchive > CreateArchive () const override
 Creates a new archive instance.
 
bool HasKey (const std::string &key) const override
 Checks whether a key exists in the archive.
 
ValueType GetValueType (const std::string &key) const override
 Returns the type of value stored under a key.
 
std::vector< std::string > GetKeys () const override
 Returns all keys stored in the archive.
 
size_t GetArrayCount (const std::string &key) const override
 Retruns the number of elements in an array value.
 
void SetBool (const std::string &key, bool value) override
 Sets a boolean value.
 
void SetInt (const std::string &key, int64_t value) override
 Sets an integer value.
 
void SetDouble (const std::string &key, double value) override
 Sets a double precision floating point value.
 
void SetString (const std::string &key, const std::string &value) override
 Sets a string value.
 
void SetArchive (const std::string &key, const std::shared_ptr< IArchive > &value) override
 Sets a nested archive.
 
void SetBoolArray (const std::string &key, const std::vector< bool > &value) override
 Sets an array of boolean values.
 
void SetIntArray (const std::string &key, const std::vector< int64_t > &value) override
 Sets an array of integer values.
 
void SetDoubleArray (const std::string &key, const std::vector< double > &value) override
 Sets an array of double precision floating point values.
 
void SetStringArray (const std::string &key, const std::vector< std::string > &value) override
 Sets an array of string values.
 
void SetArchiveArray (const std::string &key, const std::vector< std::shared_ptr< IArchive > > &value) override
 Sets an array of nested archives.
 
bool GetBool (const std::string &key) const override
 Returns the boolean value.
 
int64_t GetInt (const std::string &key) const override
 Returns the integer value.
 
double GetDouble (const std::string &key) const override
 Returns the double precision floating point value.
 
std::string GetString (const std::string &key) const override
 Returns the string value.
 
std::shared_ptr< IArchive > GetArchive (const std::string &key) const override
 Returns the nested archive.
 
std::vector< bool > GetBoolArray (const std::string &key) const override
 Returns the array of boolean values.
 
std::vector< int64_t > GetIntArray (const std::string &key) const override
 Returns the array of integer values.
 
std::vector< double > GetDoubleArray (const std::string &key) const override
 Returns the array of double precision floating point values.
 
std::vector< std::string > GetStringArray (const std::string &key) const override
 Returns the array of string values.
 
std::vector< std::shared_ptr< IArchive > > GetArchiveArray (const std::string &key) const override
 Returns the array of nested archives.
 
virtual void SetArchive (const std::string &key, const std::shared_ptr< IArchive > &value)=0
 Stores a nested archive object.
 
virtual void SetArchiveArray (const std::string &key, const std::vector< std::shared_ptr< IArchive > > &value)=0
 Stores an array of nested archives.
 

Detailed Description

A key-value store that implements the IArchive interface.

The Archive class provides a concrete implementation of a serialization archive that stores data as key-value pairs. It supports various data types including primitives (bool, int64_t, double), strings, nested archives, and arrays of these types.

Example

archive.SetInt("A", 1);
archive.SetString("B", "Text");
archive.SetIntArray("C", std::vector<int64_t>({ 1, 2, 3 }));
auto subArchive = std::make_shared<peak::icv::Archive>();
subArchive->SetDouble("a", 1.2);
subArchive->SetBool("b", true);
archive.SetArchive("D", subArchive);
A key-value store that implements the IArchive interface.
Definition peak_icv_archive.hpp:70
void SetInt(const std::string &key, int64_t value) override
Sets an integer value.
Definition peak_icv_archive.ipp:175

This class inherits from peak::common::serialization::IArchive.

Note
This class is non-copyable but supports move semantics.
See also
peak::common::serialization::IArchive
Since
ids_peak_icv 1.0

Member Enumeration Documentation

◆ ValueType

enum class ValueType
stronginherited

Enumerates supported value types that can be stored or queried in the archive.

Enumerator
Bool 

Single boolean value.

BoolArray 

Array of booleans.

Int 

64-bit signed integer

IntArray 

Array of integers.

Double 

Double-precision floating point.

DoubleArray 

Array of doubles.

String 

UTF-8 encoded string.

StringArray 

Array of strings.

Archive 

Nested archive object.

ArchiveArray 

Array of nested archives.

Constructor & Destructor Documentation

◆ Archive() [1/3]

Archive ( )
inline

Constructs an empty Archive instance.

Exceptions
InvalidConfigurationExceptionThe library is not initialized.
Since
ids_peak_icv 1.0

◆ ~Archive()

~Archive ( )
inlineoverride

Virtual destructor.

Ensures proper cleanup of resources when the archive is destroyed.

Since
ids_peak_icv 1.0

◆ Archive() [2/3]

Archive ( const Archive & )
delete

Archive instances cannot be copied.

Since
ids_peak_icv 1.0

◆ Archive() [3/3]

Archive ( Archive && other)
inlinenoexcept

Constructs an Archive by moving from another instance.

Parameters
otherThe Archive instance to move from.
Since
ids_peak_icv 1.0

Member Function Documentation

◆ CreateArchive()

std::shared_ptr< peak::common::serialization::IArchive > CreateArchive ( ) const
inlineoverridevirtual

Creates a new archive instance.

Factory method that creates a new archive wrapped in a shared_ptr.

Returns
A shared pointer to a new IArchive instance.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetArchive()

std::shared_ptr< peak::common::serialization::IArchive > GetArchive ( const std::string & key) const
inlineoverridevirtual

Returns the nested archive.

Parameters
keyThe key of the archive to retrieve.
Returns
A shared pointer to the IArchive instance stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetArchiveArray()

std::vector< std::shared_ptr< peak::common::serialization::IArchive > > GetArchiveArray ( const std::string & key) const
inlineoverridevirtual

Returns the array of nested archives.

Parameters
keyThe key of the array to retrieve.
Returns
The vector of shared pointers to IArchive instances stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetArrayCount()

size_t GetArrayCount ( const std::string & key) const
inlineoverridevirtual

Retruns the number of elements in an array value.

Parameters
keyThe key of the array.
Returns
The number of elements in the array, or 0 if key doesn't exist or is not an array.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetBool()

bool GetBool ( const std::string & key) const
inlineoverridevirtual

Returns the boolean value.

Parameters
keyThe key of the value to retrieve.
Returns
The boolean value stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetBoolArray()

std::vector< bool > GetBoolArray ( const std::string & key) const
inlineoverridevirtual

Returns the array of boolean values.

Parameters
keyThe key of the array to retrieve.
Returns
The vector of boolean values stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetDouble()

double GetDouble ( const std::string & key) const
inlineoverridevirtual

Returns the double precision floating point value.

Parameters
keyThe key of the value to retrieve.
Returns
The double value stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetDoubleArray()

std::vector< double > GetDoubleArray ( const std::string & key) const
inlineoverridevirtual

Returns the array of double precision floating point values.

Parameters
keyThe key of the array to retrieve.
Returns
The vector of double values stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetInt()

int64_t GetInt ( const std::string & key) const
inlineoverridevirtual

Returns the integer value.

Parameters
keyThe key of the value to retrieve.
Returns
The integer value stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetIntArray()

std::vector< int64_t > GetIntArray ( const std::string & key) const
inlineoverridevirtual

Returns the array of integer values.

Parameters
keyThe key of the array to retrieve.
Returns
The vector of integer values stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetKeys()

std::vector< std::string > GetKeys ( ) const
inlineoverridevirtual

Returns all keys stored in the archive.

Returns
A vector containing all keys currently stored.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetString()

std::string GetString ( const std::string & key) const
inlineoverridevirtual

Returns the string value.

Parameters
keyThe key of the value to retrieve.
Returns
The string value stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetStringArray()

std::vector< std::string > GetStringArray ( const std::string & key) const
inlineoverridevirtual

Returns the array of string values.

Parameters
keyThe key of the array to retrieve.
Returns
The vector of string values stored under the specified key.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ GetValueType()

Archive::ValueType GetValueType ( const std::string & key) const
inlineoverridevirtual

Returns the type of value stored under a key.

Parameters
keyThe key to get query.
Returns
The ValueType representing the stored type.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ HasKey()

bool HasKey ( const std::string & key) const
inlineoverridevirtual

Checks whether a key exists in the archive.

Parameters
keyThe key to check.
Returns
true if the key exists, false otherwise.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ operator=() [1/2]

Archive & operator= ( Archive && other)
inlinenoexcept

Assigns this archive by moving from another instance.

Parameters
otherThe Archive instance to move from.
Returns
A Reference to this Archive.
Since
ids_peak_icv 1.0

◆ operator=() [2/2]

Archive & operator= ( const Archive & )
delete

Archive instances cannot be copy-assigned.

Since
ids_peak_icv 1.0

◆ SetArchive() [1/2]

virtual void SetArchive ( const std::string & key,
const std::shared_ptr< IArchive > & value )
pure virtualinherited

Stores a nested archive object.

◆ SetArchive() [2/2]

void SetArchive ( const std::string & key,
const std::shared_ptr< IArchive > & value )
inlineoverride

Sets a nested archive.

Parameters
keyThe key under which to store the archive.
valueA shared pointer to the IArchive instance to store.
Since
ids_peak_icv 1.0

◆ SetArchiveArray() [1/2]

virtual void SetArchiveArray ( const std::string & key,
const std::vector< std::shared_ptr< IArchive > > & value )
pure virtualinherited

Stores an array of nested archives.

◆ SetArchiveArray() [2/2]

void SetArchiveArray ( const std::string & key,
const std::vector< std::shared_ptr< IArchive > > & value )
inlineoverride

Sets an array of nested archives.

Parameters
keyThe key under which to store the array.
valueThe vector of shared pointers to IArchive instances to store.
Since
ids_peak_icv 1.0

◆ SetBool()

void SetBool ( const std::string & key,
bool value )
inlineoverridevirtual

Sets a boolean value.

Parameters
keyThe key under which to store the value.
valueThe boolean value to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetBoolArray()

void SetBoolArray ( const std::string & key,
const std::vector< bool > & value )
inlineoverridevirtual

Sets an array of boolean values.

Parameters
keyThe key under which to store the array.
valueThe vector of boolean values to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetDouble()

void SetDouble ( const std::string & key,
double value )
inlineoverridevirtual

Sets a double precision floating point value.

Parameters
keyThe key under which to store the value.
valueThe double value to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetDoubleArray()

void SetDoubleArray ( const std::string & key,
const std::vector< double > & value )
inlineoverridevirtual

Sets an array of double precision floating point values.

Parameters
keyThe key under which to store the array.
valueThe vector of double values to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetInt()

void SetInt ( const std::string & key,
int64_t value )
inlineoverridevirtual

Sets an integer value.

Parameters
keyThe key under which to store the value.
valueThe 64-bit integer value to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetIntArray()

void SetIntArray ( const std::string & key,
const std::vector< int64_t > & value )
inlineoverridevirtual

Sets an array of integer values.

Parameters
keyThe key under which to store the array.
valueThe vector of 64-bit integer values to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetString()

void SetString ( const std::string & key,
const std::string & value )
inlineoverridevirtual

Sets a string value.

Parameters
keyThe key under which to store the value.
valueThe string value to store.
Since
ids_peak_icv 1.0

Implements IArchive.

◆ SetStringArray()

void SetStringArray ( const std::string & key,
const std::vector< std::string > & value )
inlineoverridevirtual

Sets an array of string values.

Parameters
keyThe key under which to store the array.
valueThe vector of string values to store.
Since
ids_peak_icv 1.0

Implements IArchive.