Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
serialbox::gridtools::savepoint Class Reference

Savepoint implemenation of the gridtools frontend. More...

#include <Savepoint.h>

Public Member Functions

 savepoint (const std::string &name)
 Construct a savepoint. More...
 
 savepoint (const std::string &name, meta_info_map meta_info)
 Construct savepoint with name and metaInfo More...
 
 savepoint (const savepoint &other)=default
 Copy constructor. More...
 
 savepoint (savepoint &&)=default
 Move constructor.
 
savepointoperator= (const savepoint &other)=default
 Copy assignment. More...
 
savepointoperator= (savepoint &&)=default
 Move assignment.
 
savepoint clone () const
 Clone the current savepoint object by performing a deep copy. More...
 
 savepoint (const std::shared_ptr< SavepointImpl > &savepoint_impl)
 Construct with SavepointImpl (internal use)
 
template<class StringType , class ValueType >
void add_meta_info (StringType &&key, ValueType &&value)
 Add a new key = value or key = {value1, ..., valueN} pair to the meta-information of the savepoint. More...
 
bool operator== (const savepoint &right) const
 Test for equality.
 
bool operator!= (const savepoint &right) const
 Test for inequality.
 
void swap (savepoint &other) noexcept
 Swap with other.
 
const std::string & name () const noexcept
 Access name.
 
meta_info_map meta_info () const noexcept
 Access meta-info.
 
bool empty () const noexcept
 Returns a bool value indicating whether the savepoint is empty (i.e has no meta-information attached)
 
std::string to_string () const
 Convert savepoint to string.
 
const std::shared_ptr< SavepointImpl > & impl () const
 Get implementation pointer.
 

Friends

std::ostream & operator<< (std::ostream &stream, const savepoint &s)
 Convert to stream.
 

Detailed Description

Savepoint implemenation of the gridtools frontend.

Savepoints are primarily identified by their name and further distinguished by their meta_info. Savepoints are used within the serializer to discriminate fields at different points in time.

Definition at line 34 of file Savepoint.h.

Constructor & Destructor Documentation

◆ savepoint() [1/3]

serialbox::gridtools::savepoint::savepoint ( const std::string &  name)
inlineexplicit

Construct a savepoint.

This method prepares the savepoint for usage and gives a name, which is the only required information for the savepoint to be usable. Meta-information can be added after the initialization has been performed.

Parameters
nameName of the savepoint

Definition at line 43 of file Savepoint.h.

◆ savepoint() [2/3]

serialbox::gridtools::savepoint::savepoint ( const std::string &  name,
meta_info_map  meta_info 
)
inline

Construct savepoint with name and metaInfo

Parameters
nameName of the savepoint
meta_infoArguments forwarded to the constructor of meta_info_map

Definition at line 50 of file Savepoint.h.

◆ savepoint() [3/3]

serialbox::gridtools::savepoint::savepoint ( const savepoint other)
default

Copy constructor.

This performs a shallow copy, meaning the objects share the same underlying SavepointImpl. To deep copy the object call meta_info_map::clone().

Example

savepoint s1("s1", {{"key1", meta_info_value(4.0)}});
savepoint s2(s1);
s1.meta_info().clear();
assert(s2.meta_info().empty()); // s1 and s2 share the same SavepointImpl, hence the
// meta_info_map of s2 was cleared as well
See also
meta_info_map::clone()

Member Function Documentation

◆ add_meta_info()

template<class StringType , class ValueType >
void serialbox::gridtools::savepoint::add_meta_info ( StringType &&  key,
ValueType &&  value 
)
inline

Add a new key = value or key = {value1, ..., valueN} pair to the meta-information of the savepoint.

Parameters
keyKey of the new element
valueObject to be copied to (or moved as) the value of the new element
Exceptions
exceptionValue cannot be inserted as it already exists

Definition at line 121 of file Savepoint.h.

◆ clone()

savepoint serialbox::gridtools::savepoint::clone ( ) const
inline

Clone the current savepoint object by performing a deep copy.

Example

savepoint s1("s1", {{"key1", meta_info_value(4.0)}});
savepoint s2 = s1.clone();
s1.meta_info().clear();
assert(!s2.meta_info().empty()); // s1 and s2 do NOT share the same SavepointImpl, hence the
// meta_info_map of s2 was NOT cleared

Definition at line 106 of file Savepoint.h.

◆ operator=()

savepoint& serialbox::gridtools::savepoint::operator= ( const savepoint other)
default

Copy assignment.

This performs a shallow copy, meaning the objects share the same underlying SavepointImpl. To deep copy the object call meta_info_map::clone().

Example

savepoint s1("s1", {{"key1", meta_info_value(4.0)}});
savepoint s2 = s1;
s1.meta_info().clear();
assert(s2.meta_info().empty()); // s1 and s2 share the same SavepointImpl, hence the
// meta_info_map of s2 was cleared as well
See also
meta_info_map::clone()

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