aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::BIFReader< GUM_SCALAR > Class Template Referencefinal

Definition of templatized reader of BIF files for Bayesian networks. More...

#include <agrum/BN/io/BIF/BIFReader.h>

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

Public Member Functions

 BIFReader (BayesNet< GUM_SCALAR > *bn, std::string_view filename)
 ~BIFReader () override
BIF::Scanner & scanner ()
 Direct access to BIF scanner (mandatory for listener connection).
const std::string & streamName () const
 name of read file
bool trace () const
 accessor to trace function (just write the number of parser line)
void trace (bool b)
Size proceed () override
 parse.
Size errors () const
 publishing Errors API
Size warnings () const
Idx errLine (Idx i) const
 line of ith error or warning
Idx errCol (Idx i) const
 col of ith error or warning
bool errIsError (Idx i) const
 type of ith error or warning
std::string errMsg (Idx i) const
 message of ith error or warning
void showElegantErrors (std::ostream &o=std::cerr) const
 send on std::cerr the list of errors
void showElegantErrorsAndWarnings (std::ostream &o=std::cerr) const
 send on std::cerr the list of errors or warnings
void showErrorCounts (std::ostream &o=std::cerr) const
 send on std::cerr the number of errors and the number of warnings

Private Attributes

BayesNet< GUM_SCALAR > * _bn_
BayesNetFactory< GUM_SCALAR > * _factory_
BIF::Scanner * _scanner_
BIF::Parser * _parser_
std::string _streamName_
bool _traceScanning_
bool _parseDone_
bool _ioerror_

Detailed Description

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

Definition of templatized reader of BIF files for Bayesian networks.

how to use it :

// OPTIONAL LISTENER CLASS
class aSimpleListener : public gum::Listener {
public:
void whenLoading(const void *buffer,int percent) {
// percent goes from 0 to 100 (whenLoading is called at most once for each
integer between 0 and 100
// percent=200 received when End Of File.
}
};
// END OF OPTIONAL LISTENER
try {
gum::BIFReader<double> reader(&bn,std::string(args[1]));
// OPTIONAL SECTION
aSimpleListener l;
GUM_CONNECT(reader.scanner(),onLoad,l,aSimpleListener::whenLoading);
// END OF OPTIONNAL SECTION
if (reader.proceed()==0) {
std::cerr<<"Well done !"<<std::endl;
} else {
reader.showElegantErrorsAndWarnings();
reader.showErrorCounts();
}
} catch (gum::IOError& e) {GUM_SHOWERROR(e);}
return 0;
Definition of templatized reader of BIF files for Bayesian networks.
Definition BIFReader.h:143
Class representing a Bayesian network.
Definition BayesNet.h:99
Every class who would catch signal from signaler should derive from Listener.
Definition listener.h:93
#define GUM_SHOWERROR(e)
Definition exceptions.h:89
#define GUM_CONNECT(sender, signal, receiver, target)
Definition listener.h:117
Author
Pierre-Henri WUILLEMIN(_at_LIP6)

Definition at line 143 of file BIFReader.h.

Constructor & Destructor Documentation

◆ BIFReader()

template<GUM_Numeric GUM_SCALAR>
gum::BIFReader< GUM_SCALAR >::BIFReader ( BayesNet< GUM_SCALAR > * bn,
std::string_view filename )

◆ ~BIFReader()

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

Member Function Documentation

◆ errCol()

template<GUM_Numeric GUM_SCALAR>
Idx gum::BIFReader< GUM_SCALAR >::errCol ( Idx i) const

col of ith error or warning

◆ errIsError()

template<GUM_Numeric GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::errIsError ( Idx i) const

type of ith error or warning

◆ errLine()

template<GUM_Numeric GUM_SCALAR>
Idx gum::BIFReader< GUM_SCALAR >::errLine ( Idx i) const

line of ith error or warning

◆ errMsg()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BIFReader< GUM_SCALAR >::errMsg ( Idx i) const

message of ith error or warning

◆ errors()

template<GUM_Numeric GUM_SCALAR>
Size gum::BIFReader< GUM_SCALAR >::errors ( ) const

publishing Errors API

of errors

◆ proceed()

template<GUM_Numeric GUM_SCALAR>
Size gum::BIFReader< GUM_SCALAR >::proceed ( )
override

parse.

Returns
the number of detected errors
Exceptions
IOErrorif file not exists

Referenced by gum::credal::CredalNet< GUM_SCALAR >::_initCNNets_().

Here is the caller graph for this function:

◆ scanner()

template<GUM_Numeric GUM_SCALAR>
BIF::Scanner & gum::BIFReader< GUM_SCALAR >::scanner ( )

Direct access to BIF scanner (mandatory for listener connection).

Exceptions
IOErrorif file not exists

◆ showElegantErrors()

template<GUM_Numeric GUM_SCALAR>
void gum::BIFReader< GUM_SCALAR >::showElegantErrors ( std::ostream & o = std::cerr) const

send on std::cerr the list of errors

◆ showElegantErrorsAndWarnings()

template<GUM_Numeric GUM_SCALAR>
void gum::BIFReader< GUM_SCALAR >::showElegantErrorsAndWarnings ( std::ostream & o = std::cerr) const

send on std::cerr the list of errors or warnings

◆ showErrorCounts()

template<GUM_Numeric GUM_SCALAR>
void gum::BIFReader< GUM_SCALAR >::showErrorCounts ( std::ostream & o = std::cerr) const

send on std::cerr the number of errors and the number of warnings

◆ streamName()

template<GUM_Numeric GUM_SCALAR>
const std::string & gum::BIFReader< GUM_SCALAR >::streamName ( ) const

name of read file

◆ trace() [1/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::trace ( ) const

accessor to trace function (just write the number of parser line)

◆ trace() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BIFReader< GUM_SCALAR >::trace ( bool b)

◆ warnings()

template<GUM_Numeric GUM_SCALAR>
Size gum::BIFReader< GUM_SCALAR >::warnings ( ) const

of errors

Member Data Documentation

◆ _bn_

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR >* gum::BIFReader< GUM_SCALAR >::_bn_
private

Definition at line 193 of file BIFReader.h.

◆ _factory_

template<GUM_Numeric GUM_SCALAR>
BayesNetFactory< GUM_SCALAR >* gum::BIFReader< GUM_SCALAR >::_factory_
private

Definition at line 194 of file BIFReader.h.

◆ _ioerror_

template<GUM_Numeric GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::_ioerror_
private

Definition at line 204 of file BIFReader.h.

◆ _parseDone_

template<GUM_Numeric GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::_parseDone_
private

Definition at line 200 of file BIFReader.h.

◆ _parser_

template<GUM_Numeric GUM_SCALAR>
BIF::Parser* gum::BIFReader< GUM_SCALAR >::_parser_
private

Definition at line 196 of file BIFReader.h.

◆ _scanner_

template<GUM_Numeric GUM_SCALAR>
BIF::Scanner* gum::BIFReader< GUM_SCALAR >::_scanner_
private

Definition at line 195 of file BIFReader.h.

◆ _streamName_

template<GUM_Numeric GUM_SCALAR>
std::string gum::BIFReader< GUM_SCALAR >::_streamName_
private

Definition at line 198 of file BIFReader.h.

◆ _traceScanning_

template<GUM_Numeric GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::_traceScanning_
private

Definition at line 199 of file BIFReader.h.


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