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

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

#include <agrum/BN/io/GUM/GumBNWriter.h>

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

Public Member Functions

void write (std::ostream &output, IBayesNet< GUM_SCALAR > &bn)
 Writes a Bayesian network in the output stream.
void write (std::string_view filePath, IBayesNet< GUM_SCALAR > &bn)
 Writes a Bayesian network in the file referenced by filePath.
GUM_NODISCARD bool isModificationAllowed () const
void setAllowModification (bool am)
std::string toString (const IBayesNet< GUM_SCALAR > &bn)
Constructor & destructor
 GumBNWriter (bool binary=false, int indent=-1)
 Default constructor.
 ~GumBNWriter () override
 Destructor.
 GumBNWriter (const GumBNWriter &)=delete
 Default constructor.
 GumBNWriter (GumBNWriter &&) noexcept=delete
 Default constructor.
GumBNWriteroperator= (const GumBNWriter &)=delete
 Default constructor.
GumBNWriteroperator= (GumBNWriter &&) noexcept=delete
 Default constructor.

Protected Member Functions

void _doWrite (std::ostream &output, const IBayesNet< GUM_SCALAR > &bn) final
 Writes a Bayesian network in the output stream using the BN format.
void _doWrite (std::string_view filePath, const IBayesNet< GUM_SCALAR > &bn) final
 Writes a Bayesian network in the referenced file using the BN format.

Private Attributes

bool _binary_
 If true, the output will be in binary format, otherwise in text format.
int _indent_
 The indentation level for the output.
bool _allowModification_ = false
 }
virtual void _syntacticalCheck (const IBayesNet< GUM_SCALAR > &bn)
 Check whether the BN is syntactically correct for BIF format.
void _validCharInNamesCheck (const IBayesNet< GUM_SCALAR > &bn)
 }
std::string _onlyValidCharsInName (std::string_view name)
 }
std::string _buildNameWithOnlyValidChars (std::string_view name)
 }

Detailed Description

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

Writes a IBayesNet in the GUM json format.

This class to write the content of a Bayesian network in the GUM json format.

Definition at line 80 of file GumBNWriter.h.

Constructor & Destructor Documentation

◆ GumBNWriter() [1/3]

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

Default constructor.

JGUM format is a json format. In binary mode, the output use the BJData format.

Parameters
binaryIf true, the output will be in binary format, otherwise in text format.
indentThe indentation level for the output in text format. If -1, the format is as compact as possible.

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

Here is the caller graph for this function:

◆ ~GumBNWriter()

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

Destructor.

◆ GumBNWriter() [2/3]

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

Default constructor.

JGUM format is a json format. In binary mode, the output use the BJData format.

Parameters
binaryIf true, the output will be in binary format, otherwise in text format.
indentThe indentation level for the output in text format. If -1, the format is as compact as possible.

References GumBNWriter().

Here is the call graph for this function:

◆ GumBNWriter() [3/3]

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

Default constructor.

JGUM format is a json format. In binary mode, the output use the BJData format.

Parameters
binaryIf true, the output will be in binary format, otherwise in text format.
indentThe indentation level for the output in text format. If -1, the format is as compact as possible.

References GumBNWriter().

Here is the call graph for this function:

Member Function Documentation

◆ _buildNameWithOnlyValidChars()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::_buildNameWithOnlyValidChars ( std::string_view name)
protectedinherited

}

References _buildNameWithOnlyValidChars().

Referenced by _buildNameWithOnlyValidChars().

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

◆ _doWrite() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::GumBNWriter< GUM_SCALAR >::_doWrite ( std::ostream & output,
const IBayesNet< GUM_SCALAR > & bn )
finalprotectedvirtual

Writes a Bayesian network in the output stream using the BN format.

Parameters
outputThe output stream.
bnThe Bayesian network writen in output.
Exceptions
IOErrorRaised if and I/O error occurs.

Implements gum::BNWriter< GUM_SCALAR >.

References _doWrite().

Referenced by _doWrite(), and _doWrite().

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

◆ _doWrite() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::GumBNWriter< GUM_SCALAR >::_doWrite ( std::string_view filePath,
const IBayesNet< GUM_SCALAR > & bn )
finalprotectedvirtual

Writes a Bayesian network in the referenced file using the BN format.

If the files doesn't exists, it is created.

Parameters
filePathThe path to the file used to write the Bayesian network.
bnThe Bayesian network writed in the file.
Exceptions
IOErrorRaised if and I/O error occurs.

Implements gum::BNWriter< GUM_SCALAR >.

References _doWrite().

Here is the call graph for this function:

◆ _onlyValidCharsInName()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::_onlyValidCharsInName ( std::string_view name)
protectedinherited

}

References _onlyValidCharsInName().

Referenced by _onlyValidCharsInName().

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

◆ _syntacticalCheck()

template<GUM_Numeric GUM_SCALAR>
virtual void gum::BNWriter< GUM_SCALAR >::_syntacticalCheck ( const IBayesNet< GUM_SCALAR > & bn)
protectedvirtualinherited

Check whether the BN is syntactically correct for BIF format.

Exceptions
FatalErrorif found.

Reimplemented in gum::BIFWriter< GUM_SCALAR >, and gum::DSLWriter< GUM_SCALAR >.

References _syntacticalCheck().

Referenced by _syntacticalCheck().

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

◆ _validCharInNamesCheck()

template<GUM_Numeric GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::_validCharInNamesCheck ( const IBayesNet< GUM_SCALAR > & bn)
protectedinherited

}

References _validCharInNamesCheck().

Referenced by _validCharInNamesCheck().

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

◆ isModificationAllowed()

template<GUM_Numeric GUM_SCALAR>
GUM_NODISCARD bool gum::BNWriter< GUM_SCALAR >::isModificationAllowed ( ) const
inherited

References GUM_NODISCARD, and isModificationAllowed().

Referenced by isModificationAllowed().

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

◆ operator=() [1/2]

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

Default constructor.

JGUM format is a json format. In binary mode, the output use the BJData format.

Parameters
binaryIf true, the output will be in binary format, otherwise in text format.
indentThe indentation level for the output in text format. If -1, the format is as compact as possible.

References GumBNWriter().

Here is the call graph for this function:

◆ operator=() [2/2]

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

Default constructor.

JGUM format is a json format. In binary mode, the output use the BJData format.

Parameters
binaryIf true, the output will be in binary format, otherwise in text format.
indentThe indentation level for the output in text format. If -1, the format is as compact as possible.

References GumBNWriter().

Here is the call graph for this function:

◆ setAllowModification()

template<GUM_Numeric GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::setAllowModification ( bool am)
inherited

References setAllowModification().

Referenced by setAllowModification().

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

◆ toString()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BNWriter< GUM_SCALAR >::toString ( const IBayesNet< GUM_SCALAR > & bn)
inherited

References toString().

Referenced by toString().

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

◆ write() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::write ( std::ostream & output,
IBayesNet< GUM_SCALAR > & bn )
inherited

Writes a Bayesian network in the output stream.

  • If the bn can not be written for syntactical reasons, throw an error or try to correct it (conditioned by the value of allowModification
Parameters
outputThe output stream.
bnThe Bayesian network written in output (not const since updateMetaData).
Exceptions
IOErrorRaised if an I/O error occurs.
SyntaxErrorRaised if syntactical errors in the BN

References write().

Referenced by gum::credal::CredalNet< GUM_SCALAR >::saveBNsMinMax(), write(), and write().

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

◆ write() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BNWriter< GUM_SCALAR >::write ( std::string_view filePath,
IBayesNet< GUM_SCALAR > & bn )
inherited

Writes a Bayesian network in the file referenced by filePath.

  • If the file doesn't exists, it is created.
  • If the file exists, it's content will be erased.
  • If the bn can not be written for syntactical reasons, throw an error or try to correct it (conditioned by the value of allowModification
Parameters
filePathThe path to the file used to write the Bayesian network.
bnThe Bayesian network written to the file (not const since updateMetaData).
Exceptions
IOErrorRaised if an I/O error occurs.

References write().

Here is the call graph for this function:

Member Data Documentation

◆ _allowModification_

template<GUM_Numeric GUM_SCALAR>
bool gum::BNWriter< GUM_SCALAR >::_allowModification_ = false
privateinherited

}

Definition at line 167 of file BNWriter.h.

◆ _binary_

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

If true, the output will be in binary format, otherwise in text format.

Definition at line 131 of file GumBNWriter.h.

◆ _indent_

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

The indentation level for the output.

Definition at line 132 of file GumBNWriter.h.


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