Helios++
Helios software for LiDAR simulations
SerialIO Class Reference

Utils for Input/Output operations of serializable objects. More...

#include <SerialIO.h>

Collaboration diagram for SerialIO:

Public Member Functions

template<class SerialClass >
void write (std::string const &path, SerialClass const *object, bool fastCompression=true)
 
template<typename SerialClass >
SerialClass * read (std::string const &path, bool const fastCompression=true)
 

Static Public Member Functions

static SerialIOgetInstance ()
 

Protected Member Functions

void handleArchiveException (std::string const &perpetrator, boost::archive::archive_exception &aex)
 Handle given archive exception. More...
 

Private Member Functions

 SerialIO ()=default
 Singleton constructor.
 

Static Private Attributes

static SerialIOinstance = nullptr
 Pointer to singleton instance of SerialIO.
 

Detailed Description

Utils for Input/Output operations of serializable objects.

Author
Alberto M. Esmoris Pena
Version
1.0

Member Function Documentation

◆ getInstance()

SerialIO * SerialIO::getInstance ( )
static

Obtain the singleton instance of SerialIO. It will be instantiated iff no instance is available

Returns
Singleton instance of SerialIO

◆ handleArchiveException()

void SerialIO::handleArchiveException ( std::string const &  perpetrator,
boost::archive::archive_exception &  aex 
)
protected

Handle given archive exception.

A detailed message for the exception will be built and logged as a warning

Parameters
perpetratorName of the perpetrator where the archive exception occurred. Generally speaking, it will be the name of a method (i.e. "SerialIO::read")
aexArchive exception to be handled

◆ read()

template<typename SerialClass >
SerialClass* SerialIO::read ( std::string const &  path,
bool const  fastCompression = true 
)

Read a serialized object and build corresponding instance from it.

Template Parameters
SerialClassSpecify the serializable type to use
Parameters
pathPath to read the serialized object from
fastCompressionSpecify if use the fast compression mode (true), which means the compression will be as fast as possible, or the best compression mode (false), which means the compression will lead to a size as small as possible at expenses of execution time.
Returns
Instance built from serialized object file

◆ write()

template<class SerialClass >
void SerialIO::write ( std::string const &  path,
SerialClass const *  object,
bool  fastCompression = true 
)

Serialize an object and write it to a file.

Template Parameters
SerialClassSpecify the serializable type to use
Parameters
pathPath to write the serialized object to
objectObject to be serialized and stored
fastCompressionSpecify if use the fast compression mode (true), which means the compression will be as fast as possible, or the best compression mode (false), which means the compression will lead to a size as small as possible at expenses of execution time.

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