Example of creating a custom validator to be called during validation.
#include <iostream>
{
public:
MyCustomValidator(
const MyCustomValidator& orig) :
SBMLValidator(orig) {
}
virtual ~MyCustomValidator() {}
virtual SBMLValidator* clone()
const {
return new MyCustomValidator(*
this); }
virtual unsigned int validate() {
if (getDocument() == NULL || getModel() == NULL)
return 0;
if (getModel()->getNumReactions() == 0 && getModel()->getNumRules() == 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];
document->addValidator(new MyCustomValidator());
return numErrors;
}