aGrUM  0.13.2
gum::BIFReader< GUM_SCALAR > Class Template Reference

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, const std::string &filename)
 
 ~BIFReader () final
 
BIF::Scanner & scanner ()
 Direct access to BIF scanner (mandatory for listener connection) More...
 
const std::string & streamName () const
 name of readen file More...
 
bool trace () const
 accessor to trace function (just write the number of parser line) More...
 
void trace (bool b)
 
Size proceed () final
 parse. More...
 
Size errors ()
 publishing Errors API More...
 
Size warnings ()
 

of errors

More...
 
Idx errLine (Idx i)
 line of ith error or warning More...
 
Idx errCol (Idx i)
 col of ith error or warning More...
 
bool errIsError (Idx i)
 type of ith error or warning More...
 
std::string errMsg (Idx i)
 message of ith error or warning More...
 
void showElegantErrors (std::ostream &o=std::cerr)
 send on std::cerr the list of errors More...
 
void showElegantErrorsAndWarnings (std::ostream &o=std::cerr)
 send on std::cerr the list of errors or warnings More...
 
void showErrorCounts (std::ostream &o=std::cerr)
 send on std::cerr the number of errors and the number of warnings More...
 

Protected 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<typename 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 recieved 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;
Author
Pierre-Henri WUILLEMIN

Definition at line 123 of file BIFReader.h.

Constructor & Destructor Documentation

template<typename GUM_SCALAR>
gum::BIFReader< GUM_SCALAR >::BIFReader ( BayesNet< GUM_SCALAR > *  bn,
const std::string &  filename 
)
template<typename GUM_SCALAR>
gum::BIFReader< GUM_SCALAR >::~BIFReader ( )
final

Member Function Documentation

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

col of ith error or warning

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

type of ith error or warning

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

line of ith error or warning

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

message of ith error or warning

template<typename GUM_SCALAR>
Size gum::BIFReader< GUM_SCALAR >::errors ( )

publishing Errors API

of errors

template<typename GUM_SCALAR>
Size gum::BIFReader< GUM_SCALAR >::proceed ( )
finalvirtual

parse.

Returns
the number of detected errors
Exceptions
IOErrorif file not exists

Implements gum::BNReader< GUM_SCALAR >.

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

+ Here is the caller graph for this function:

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

Direct access to BIF scanner (mandatory for listener connection)

Exceptions
IOErrorif file not exists
template<typename GUM_SCALAR>
void gum::BIFReader< GUM_SCALAR >::showElegantErrors ( std::ostream &  o = std::cerr)

send on std::cerr the list of errors

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

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

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

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

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

name of readen file

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

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

template<typename GUM_SCALAR>
void gum::BIFReader< GUM_SCALAR >::trace ( bool  b)
template<typename GUM_SCALAR>
Size gum::BIFReader< GUM_SCALAR >::warnings ( )

of errors

Member Data Documentation

template<typename GUM_SCALAR>
BayesNet< GUM_SCALAR >* gum::BIFReader< GUM_SCALAR >::__bn
protected

Definition at line 173 of file BIFReader.h.

template<typename GUM_SCALAR>
BayesNetFactory< GUM_SCALAR >* gum::BIFReader< GUM_SCALAR >::__factory
protected

Definition at line 174 of file BIFReader.h.

template<typename GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::__ioerror
protected

Definition at line 184 of file BIFReader.h.

template<typename GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::__parseDone
protected

Definition at line 180 of file BIFReader.h.

template<typename GUM_SCALAR>
BIF::Parser* gum::BIFReader< GUM_SCALAR >::__parser
protected

Definition at line 176 of file BIFReader.h.

template<typename GUM_SCALAR>
BIF::Scanner* gum::BIFReader< GUM_SCALAR >::__scanner
protected

Definition at line 175 of file BIFReader.h.

template<typename GUM_SCALAR>
std::string gum::BIFReader< GUM_SCALAR >::__streamName
protected

Definition at line 178 of file BIFReader.h.

template<typename GUM_SCALAR>
bool gum::BIFReader< GUM_SCALAR >::__traceScanning
protected

Definition at line 179 of file BIFReader.h.


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