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

#include <peak_icv/serialization/peak_icv_archive.hpp>

Inheritance diagram for Archive:
Collaboration 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 ()
 Default constructor.
 
 ~Archive () override
 Virtual destructor.
 
 Archive (const Archive &)=delete
 Deleted copy constructor.
 
Archive & operator= (const Archive &)=delete
 Deleted copy assignment operator.
 
 Archive (Archive &&other) noexcept
 Move constructor.
 
Archive & operator= (Archive &&other) noexcept
 Move assignment operator.
 
std::shared_ptr< IArchive > CreateArchive () const override
 Creates a new Archive instance.
 
bool HasKey (const std::string &key) const override
 Checks if a key exists in the archive.
 
ValueType GetValueType (const std::string &key) const override
 Gets the type of value stored under a key.
 
std::vector< std::string > GetKeys () const override
 Gets all keys stored in the archive.
 
size_t GetArrayCount (const std::string &key) const override
 Gets the count 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 value.
 
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 archive values.
 
bool GetBool (const std::string &key) const override
 Gets a boolean value.
 
int64_t GetInt (const std::string &key) const override
 Gets an integer value.
 
double GetDouble (const std::string &key) const override
 Gets a double precision floating point value.
 
std::string GetString (const std::string &key) const override
 Gets a string value.
 
std::shared_ptr< IArchive > GetArchive (const std::string &key) const override
 Gets a nested archive value.
 
std::vector< bool > GetBoolArray (const std::string &key) const override
 Gets an array of boolean values.
 
std::vector< int64_t > GetIntArray (const std::string &key) const override
 Gets an array of integer values.
 
std::vector< double > GetDoubleArray (const std::string &key) const override
 Gets an array of double precision floating point values.
 
std::vector< std::string > GetStringArray (const std::string &key) const override
 Gets an array of string values.
 
std::vector< std::shared_ptr< IArchive > > GetArchiveArray (const std::string &key) const override
 Gets an array of nested archive values.
 
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 simple 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.

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
1.0

Definition at line 46 of file peak_icv_archive.hpp.

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.

Definition at line 64 of file peak_common_iarchive.hpp.

Constructor & Destructor Documentation

◆ Archive() [1/3]

Archive ( )
inline

Default constructor.

Creates an empty Archive instance.

Exceptions
InvalidConfigurationExceptionIf the library is not initialized.

Definition at line 59 of file peak_icv_archive.ipp.

◆ ~Archive()

~Archive ( )
inlineoverride

Virtual destructor.

Ensures proper cleanup of resources when the Archive is destroyed.

Definition at line 70 of file peak_icv_archive.ipp.

◆ Archive() [2/3]

Archive ( const Archive & )
delete

Deleted copy constructor.

Archive instances cannot be copied.

◆ Archive() [3/3]

Archive ( Archive && other)
inlinenoexcept

Move constructor.

Creates an Archive by moving from another Archive instance.

Parameters
otherThe Archive instance to move from

Definition at line 78 of file peak_icv_archive.ipp.

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 instance wrapped in a shared_ptr.

Returns
A shared pointer to a new IArchive instance

Implements IArchive.

Definition at line 149 of file peak_icv_archive.ipp.

◆ GetArchive()

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

Gets a nested archive value.

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

Implements IArchive.

Definition at line 330 of file peak_icv_archive.ipp.

◆ GetArchiveArray()

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

Gets an array of nested archive values.

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

Implements IArchive.

Definition at line 454 of file peak_icv_archive.ipp.

◆ GetArrayCount()

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

Gets the count of elements in an array value.

Parameters
keyThe key of the array to get the count for
Returns
The number of elements in the array, or 0 if key doesn't exist or isn't an array

Implements IArchive.

Definition at line 140 of file peak_icv_archive.ipp.

◆ GetBool()

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

Gets a boolean value.

Parameters
keyThe key of the value to retrieve
Returns
The boolean value stored under the specified key

Implements IArchive.

Definition at line 268 of file peak_icv_archive.ipp.

◆ GetBoolArray()

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

Gets an array of boolean values.

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

Implements IArchive.

Definition at line 341 of file peak_icv_archive.ipp.

◆ GetDouble()

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

Gets a double precision floating point value.

Parameters
keyThe key of the value to retrieve
Returns
The double value stored under the specified key

Implements IArchive.

Definition at line 290 of file peak_icv_archive.ipp.

◆ GetDoubleArray()

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

Gets an 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

Implements IArchive.

Definition at line 388 of file peak_icv_archive.ipp.

◆ GetInt()

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

Gets an integer value.

Parameters
keyThe key of the value to retrieve
Returns
The integer value stored under the specified key

Implements IArchive.

Definition at line 279 of file peak_icv_archive.ipp.

◆ GetIntArray()

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

Gets an array of integer values.

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

Implements IArchive.

Definition at line 368 of file peak_icv_archive.ipp.

◆ GetKeys()

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

Gets all keys stored in the archive.

Returns
A vector containing all keys currently stored in the archive

Implements IArchive.

Definition at line 103 of file peak_icv_archive.ipp.

◆ GetString()

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

Gets a string value.

Parameters
keyThe key of the value to retrieve
Returns
The string value stored under the specified key

Implements IArchive.

Definition at line 301 of file peak_icv_archive.ipp.

◆ GetStringArray()

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

Gets an array of string values.

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

Implements IArchive.

Definition at line 410 of file peak_icv_archive.ipp.

◆ GetValueType()

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

Gets the type of value stored under a key.

Parameters
keyThe key to get the type for
Returns
The ValueType enumeration value representing the stored type

Implements IArchive.

Definition at line 93 of file peak_icv_archive.ipp.

◆ HasKey()

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

Checks if a key exists in the archive.

Parameters
keyThe key to check for existence
Returns
true if the key exists, false otherwise

Implements IArchive.

Definition at line 158 of file peak_icv_archive.ipp.

◆ operator=() [1/2]

Archive & operator= ( Archive && other)
inlinenoexcept

Move assignment operator.

Assigns this Archive by moving from another Archive instance.

Parameters
otherThe Archive instance to move from
Returns
Reference to this Archive instance

Definition at line 83 of file peak_icv_archive.ipp.

◆ operator=() [2/2]

Archive & operator= ( const Archive & )
delete

Deleted copy assignment operator.

Archive instances cannot be copy-assigned.

◆ 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 value.

Parameters
keyThe key to store the archive under
valueA shared pointer to the IArchive instance to store

Definition at line 196 of file peak_icv_archive.ipp.

◆ 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 archive values.

Parameters
keyThe key to store the array under
valueThe vector of shared pointers to IArchive instances to store

Definition at line 250 of file peak_icv_archive.ipp.

◆ SetBool()

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

Sets a boolean value.

Parameters
keyThe key to store the value under
valueThe boolean value to store

Implements IArchive.

Definition at line 168 of file peak_icv_archive.ipp.

◆ SetBoolArray()

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

Sets an array of boolean values.

Parameters
keyThe key to store the array under
valueThe vector of boolean values to store

Implements IArchive.

Definition at line 208 of file peak_icv_archive.ipp.

◆ SetDouble()

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

Sets a double precision floating point value.

Parameters
keyThe key to store the value under
valueThe double value to store

Implements IArchive.

Definition at line 182 of file peak_icv_archive.ipp.

◆ 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 to store the array under
valueThe vector of double values to store

Implements IArchive.

Definition at line 230 of file peak_icv_archive.ipp.

◆ SetInt()

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

Sets an integer value.

Parameters
keyThe key to store the value under
valueThe integer value to store

Implements IArchive.

Definition at line 175 of file peak_icv_archive.ipp.

◆ SetIntArray()

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

Sets an array of integer values.

Parameters
keyThe key to store the array under
valueThe vector of 64-bit integer values to store

Implements IArchive.

Definition at line 223 of file peak_icv_archive.ipp.

◆ SetString()

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

Sets a string value.

Parameters
keyThe key to store the value under
valueThe string value to store

Implements IArchive.

Definition at line 189 of file peak_icv_archive.ipp.

◆ SetStringArray()

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

Sets an array of string values.

Parameters
keyThe key to store the array under
valueThe vector of string values to store

Implements IArchive.

Definition at line 237 of file peak_icv_archive.ipp.