aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::GumMRFWriter< GUM_SCALAR > Class Template Reference

Writes a MarkovRandomField in the GUM json format. More...

#include <agrum/MRF/io/GUM/GumMRFWriter.h>

Inheritance diagram for gum::GumMRFWriter< GUM_SCALAR >:
Collaboration diagram for gum::GumMRFWriter< GUM_SCALAR >:

Public Member Functions

std::string toString (const IMarkovRandomField< GUM_SCALAR > &mrf)
 Serializes a MarkovRandomField to a string in GUM json format.
void write (std::ostream &output, const IMarkovRandomField< GUM_SCALAR > &mrf) override
 Writes a MarkovRandomField to the output stream.
void write (std::string_view filePath, IMarkovRandomField< GUM_SCALAR > &mrf) override
 Writes a MarkovRandomField to the file at filePath, updating metadata first.
void write (std::string_view filePath, const IMarkovRandomField< GUM_SCALAR > &mrf) override
 Writes a MarkovRandomField to the file at filePath (const variant, no metadata update).
Constructor & destructor
 GumMRFWriter (bool binary=false, int indent=-1)
 Default constructor.
 ~GumMRFWriter () override
 Default constructor.
 GumMRFWriter (const GumMRFWriter &)=delete
 Default constructor.
 GumMRFWriter (GumMRFWriter &&) noexcept=delete
 Default constructor.
GumMRFWriteroperator= (const GumMRFWriter &)=delete
 Default constructor.
GumMRFWriteroperator= (GumMRFWriter &&) noexcept=delete
 Default constructor.

Private Attributes

bool _binary_
int _indent_

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::GumMRFWriter< GUM_SCALAR >

Writes a MarkovRandomField in the GUM json format.

Each factor is serialized as an inline object {"vars": [...], "values": [...]}, avoiding any key-separator ambiguity with variable names.

Supports both text (.jgum) and binary msgpack (.bgum) output.

Definition at line 75 of file GumMRFWriter.h.

Constructor & Destructor Documentation

◆ GumMRFWriter() [1/3]

template<GUM_Numeric GUM_SCALAR>
gum::GumMRFWriter< GUM_SCALAR >::GumMRFWriter ( bool binary = false,
int indent = -1 )

Default constructor.

Parameters
binaryIf true, output uses the msgpack binary format; otherwise JSON text.
indentIndentation level for text output. -1 produces compact output.

Referenced by GumMRFWriter(), GumMRFWriter(), operator=(), and operator=().

Here is the caller graph for this function:

◆ ~GumMRFWriter()

template<GUM_Numeric GUM_SCALAR>
gum::GumMRFWriter< GUM_SCALAR >::~GumMRFWriter ( )
override

Default constructor.

Parameters
binaryIf true, output uses the msgpack binary format; otherwise JSON text.
indentIndentation level for text output. -1 produces compact output.

◆ GumMRFWriter() [2/3]

template<GUM_Numeric GUM_SCALAR>
gum::GumMRFWriter< GUM_SCALAR >::GumMRFWriter ( const GumMRFWriter< GUM_SCALAR > & )
delete

Default constructor.

Parameters
binaryIf true, output uses the msgpack binary format; otherwise JSON text.
indentIndentation level for text output. -1 produces compact output.

References GumMRFWriter().

Here is the call graph for this function:

◆ GumMRFWriter() [3/3]

template<GUM_Numeric GUM_SCALAR>
gum::GumMRFWriter< GUM_SCALAR >::GumMRFWriter ( GumMRFWriter< GUM_SCALAR > && )
deletenoexcept

Default constructor.

Parameters
binaryIf true, output uses the msgpack binary format; otherwise JSON text.
indentIndentation level for text output. -1 produces compact output.

References GumMRFWriter().

Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/2]

template<GUM_Numeric GUM_SCALAR>
GumMRFWriter & gum::GumMRFWriter< GUM_SCALAR >::operator= ( const GumMRFWriter< GUM_SCALAR > & )
delete

Default constructor.

Parameters
binaryIf true, output uses the msgpack binary format; otherwise JSON text.
indentIndentation level for text output. -1 produces compact output.

References GumMRFWriter().

Here is the call graph for this function:

◆ operator=() [2/2]

template<GUM_Numeric GUM_SCALAR>
GumMRFWriter & gum::GumMRFWriter< GUM_SCALAR >::operator= ( GumMRFWriter< GUM_SCALAR > && )
deletenoexcept

Default constructor.

Parameters
binaryIf true, output uses the msgpack binary format; otherwise JSON text.
indentIndentation level for text output. -1 produces compact output.

References GumMRFWriter().

Here is the call graph for this function:

◆ toString()

template<GUM_Numeric GUM_SCALAR>
std::string gum::GumMRFWriter< GUM_SCALAR >::toString ( const IMarkovRandomField< GUM_SCALAR > & mrf)

Serializes a MarkovRandomField to a string in GUM json format.

References toString().

Referenced by toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [1/3]

template<GUM_Numeric GUM_SCALAR>
void gum::GumMRFWriter< GUM_SCALAR >::write ( std::ostream & output,
const IMarkovRandomField< GUM_SCALAR > & mrf )
overridevirtual

Writes a MarkovRandomField to the output stream.

Parameters
outputThe output stream.
mrfThe MarkovRandomField to write.
Exceptions
IOErrorif the stream is not writable.

Implements gum::MRFWriter< GUM_SCALAR >.

References write().

Referenced by write(), write(), and write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [2/3]

template<GUM_Numeric GUM_SCALAR>
void gum::GumMRFWriter< GUM_SCALAR >::write ( std::string_view filePath,
const IMarkovRandomField< GUM_SCALAR > & mrf )
overridevirtual

Writes a MarkovRandomField to the file at filePath (const variant, no metadata update).

Parameters
filePathPath to the output file (created or overwritten).
mrfThe MarkovRandomField to write.
Exceptions
IOErrorif an I/O error occurs.

Implements gum::MRFWriter< GUM_SCALAR >.

References write().

Here is the call graph for this function:

◆ write() [3/3]

template<GUM_Numeric GUM_SCALAR>
void gum::GumMRFWriter< GUM_SCALAR >::write ( std::string_view filePath,
IMarkovRandomField< GUM_SCALAR > & mrf )
overridevirtual

Writes a MarkovRandomField to the file at filePath, updating metadata first.

Parameters
filePathPath to the output file (created or overwritten).
mrfThe MarkovRandomField to write (non-const to allow metadata update).
Exceptions
IOErrorif an I/O error occurs.

Reimplemented from gum::MRFWriter< GUM_SCALAR >.

References write().

Here is the call graph for this function:

Member Data Documentation

◆ _binary_

template<GUM_Numeric GUM_SCALAR>
bool gum::GumMRFWriter< GUM_SCALAR >::_binary_
private

Definition at line 132 of file GumMRFWriter.h.

◆ _indent_

template<GUM_Numeric GUM_SCALAR>
int gum::GumMRFWriter< GUM_SCALAR >::_indent_
private

Definition at line 133 of file GumMRFWriter.h.


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