53#ifndef DOXYGEN_SHOULD_SKIP_THIS
57 template <
typename GUM_SCALAR >
59 BNReader< GUM_SCALAR >(bn, filename) {
60 GUM_CONSTRUCTOR(BIFReader);
62 _streamName_ = filename;
65 _factory_ =
new BayesNetFactory< GUM_SCALAR >(_bn_);
70 _scanner_ =
new BIF::Scanner(_streamName_.c_str());
71 _parser_ =
new BIF::Parser(_scanner_);
72 _parser_->setFactory(
static_cast< IBayesNetFactory*
>(_factory_));
73 }
catch (
IOError const&) { _ioerror_ =
true; }
76 template <
typename GUM_SCALAR >
77 BIFReader< GUM_SCALAR >::~BIFReader() {
78 GUM_DESTRUCTOR(BIFReader);
82 if (_parser_)
delete (_parser_);
84 if (_scanner_)
delete (_scanner_);
87 if (_factory_)
delete (_factory_);
90 template <
typename GUM_SCALAR >
91 INLINE BIF::Scanner& BIFReader< GUM_SCALAR >::scanner() {
92 if (_ioerror_) {
GUM_ERROR(gum::IOError,
"No such file " + streamName()) }
97 template <
typename GUM_SCALAR >
98 INLINE
const std::string& BIFReader< GUM_SCALAR >::streamName()
const {
102 template <
typename GUM_SCALAR >
103 INLINE
bool BIFReader< GUM_SCALAR >::trace()
const {
104 return _traceScanning_;
107 template <
typename GUM_SCALAR >
108 INLINE
void BIFReader< GUM_SCALAR >::trace(
bool b) {
110 scanner().setTrace(b);
113 template <
typename GUM_SCALAR >
114 Size BIFReader< GUM_SCALAR >::proceed() {
115 if (_ioerror_) {
GUM_ERROR(gum::IOError,
"No such file " + streamName()) }
123 return 1 + _parser_->errors().error_count;
127 return (_parser_->errors().error_count);
132 template <
typename GUM_SCALAR >
133 INLINE Idx BIFReader< GUM_SCALAR >::errLine(Idx i) {
134 if (_parseDone_)
return _parser_->errors().error(i).line;
138 template <
typename GUM_SCALAR >
139 INLINE Idx BIFReader< GUM_SCALAR >::errCol(Idx i) {
140 if (_parseDone_)
return _parser_->errors().error(i).column;
144 template <
typename GUM_SCALAR >
145 INLINE
bool BIFReader< GUM_SCALAR >::errIsError(Idx i) {
146 if (_parseDone_)
return _parser_->errors().error(i).is_error;
150 template <
typename GUM_SCALAR >
151 INLINE std::string BIFReader< GUM_SCALAR >::errMsg(Idx i) {
152 if (_parseDone_)
return _parser_->errors().error(i).msg;
156 template <
typename GUM_SCALAR >
157 INLINE
void BIFReader< GUM_SCALAR >::showElegantErrors(std::ostream& o) {
158 if (_parseDone_) _parser_->errors().elegantErrors(o);
162 template <
typename GUM_SCALAR >
163 INLINE
void BIFReader< GUM_SCALAR >::showElegantErrorsAndWarnings(std::ostream& o) {
164 if (_parseDone_) _parser_->errors().elegantErrorsAndWarnings(o);
168 template <
typename GUM_SCALAR >
169 INLINE
void BIFReader< GUM_SCALAR >::showErrorCounts(std::ostream& o) {
170 if (_parseDone_) _parser_->errors().syntheticResults(o);
174 template <
typename GUM_SCALAR >
175 INLINE Size BIFReader< GUM_SCALAR >::errors() {
176 return (!_parseDone_) ? (Size)0 : _parser_->errors().error_count;
179 template <
typename GUM_SCALAR >
180 INLINE Size BIFReader< GUM_SCALAR >::warnings() {
181 return (!_parseDone_) ? (Size)0 : _parser_->errors().warning_count;
Definition of templatized reader of BIF files for Bayesian networks.
Definition of abstract classes for file input manipulation of Bayesian networks.
BIFReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename)
Pure virtual class for reading a BN from a file.
Class representing a Bayesian network.
Base class for all aGrUM's exceptions.
Exception : input/output problem.
Exception : operation not allowed.
#define GUM_ERROR(type, msg)
gum is the global namespace for all aGrUM entities