Example of creating a custom validator to be called during validation.
Example of creating a custom validator to be called during validation.
#include <iostream>
using namespace std;
LIBSBML_CPP_NAMESPACE_USE
{
public:
return 0;
return 0;
unsigned int numErrors = 0;
for (
unsigned int i = 0; i <
getModel()->getNumRules(); i++)
{
"This model uses algebraic rules, however this application does not support them.",
0, 0,
));
numErrors++;
}
}
for (
unsigned int i = 0; i <
getModel()->getNumReactions(); i++)
{
if (
getModel()->getReaction(i)->isSetFast() &&
getModel()->getReaction(i)->getFast()) {
"This model uses fast reactions, however this application does not support them.",
0, 0,
));
numErrors++;
}
}
return numErrors;
}
};
int
main (int argc, char *argv[])
{
if (argc != 2)
{
cout << endl << "Usage: addCustomValidator filename" << endl << endl;
return 1;
}
const char* filename = argv[1];
MyCustomValidator* myCustomValidator = new MyCustomValidator();
document->addValidator(myCustomValidator);
delete myCustomValidator;
delete document;
return numErrors;
}
@ LIBSBML_CAT_SBML
Definition SBMLError.h:940
SBMLDocument_t * readSBML(const char *filename)
Reads an SBML document from the given file.
@ SBML_ALGEBRAIC_RULE
Definition SBMLTypeCodes.h:85
Include all SBML types in a single header file.
Definition of SBMLValidator, the base class for user callable SBML validators.
@ LIBSBML_SEV_WARNING
Definition XMLError.h:529
Definition SBMLDocument.h:351
unsigned int checkConsistency()
Performs consistency checking and validation on this SBML document.
Definition SBMLDocument.cpp:699
void printErrors(std::ostream &stream=std::cerr) const
Prints all the errors or warnings encountered trying to parse, check, or translate this SBML document...
Definition SBMLDocument.cpp:1192
Definition SBMLError.h:1100
Definition SBMLValidator.h:96
virtual SBMLValidator * clone() const
Creates and returns a deep copy of this SBMLValidator object.
Definition SBMLValidator.cpp:96
SBMLErrorLog * getErrorLog()
Returns the list of errors or warnings logged during parsing, consistency checking,...
Definition SBMLValidator.cpp:202
virtual unsigned int validate()
Runs this validator on the current SBML document.
Definition SBMLValidator.cpp:230
virtual SBMLDocument * getDocument()
Returns the current SBML document in use by this validator.
Definition SBMLValidator.cpp:103
const Model * getModel() const
Returns the Model object stored in the SBMLDocument.
Definition SBMLValidator.cpp:212