libSBML C++ API  5.18.0
CompValidator Class Referenceabstract
Inheritance diagram for CompValidator:
[legend]

Detailed Description

comp Entry point for package validation.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

LibSBML implements facilities for verifying that a given SBML document is valid according to the SBML specifications; it also exposes the validation interface so that user programs and SBML Level 3 package authors may use the facilities to implement new validators. There are two main interfaces to libSBML's validation facilities, based on the classes Validator and SBMLValidator.

The CompValidator class extends the Validator class from core libSBML to apply validation to the constructs introduced by the SBML Level 3 Hierarchical Model Composition package. This class then acts as a base class for any validators that apply rules to the “comp” package specification constructs or to entire models that use the “comp” package, and may therefore be subject to other global restrictions introduced.

General information about package-specific validators

The general SBMLDocument::checkConsistency() methods that perform validation make use of the libSBML plugin mechanism to invoke the package-specific validators via the relevant document plugin. In the case of a validator such as FbcValidator, QualValidator, and others, the package-specific validator acts on the constructs from the relevant package rather than on core SBML constructs. (However, this does not necessarily mean it does not take into account the whole SBML model—the information needed by a given validator to do its work is up to the validator itself.)

Package-specific validators are invoked when SBMLDocument::checkConsistency() is invoked on the overall SBMLDocument object. As the main validation procedure executes, it passes control to each libSBML package plugin via the plugin's PackageSBMLDocumentPlugin class, (where Package is the package prefix, such as Qual, or Fbc). These class implement their own consistency-checking functions for rules defined in the relevant SBML Level 3 package.

The package-specific validators obey the same categories of consistency/error checks as are used by the overall SBMLDocument::checkConsistency(). This means that, for example, if identifier validation is turned off, it is turned off in all SBML Level 3 package validators too. See SBMLDocument::setConsistencyChecks() for more information about categories and how to control them.

See also
SBMLDocument::checkConsistency()
SBMLDocument::checkInternalConsistency()
SBMLDocument::setConsistencyChecks()

Public Member Functions

virtual void addConstraint (VConstraint *c)
 Adds the given VContraint object to this validator. More...
 
void clearFailures ()
 Clears this Validator's list of validation failures. More...
 
 CompValidator (SBMLErrorCategory_t category=LIBSBML_CAT_SBML)
 Constructor; creates a new CompValidator object for the given category of validation. More...
 
unsigned int getCategory () const
 Get the category of validation rules covered by this validator. More...
 
const std::list< SBMLError > & getFailures () const
 Get the list of SBMLError objects logged during validator execution. More...
 
virtual void init ()=0
 Initializes this CompValidator object. More...
 
void logFailure (const SBMLError &err)
 Adds the given failure to this list of validation failures. More...
 
virtual unsigned int validate (const SBMLDocument &d)
 Validates the given SBML document. More...
 
virtual unsigned int validate (const std::string &filename)
 Validates the SBML document located at the given file name. More...
 
virtual ~CompValidator ()
 Destroys this CompValidator object. More...
 

Constructor & Destructor Documentation

CompValidator::CompValidator ( SBMLErrorCategory_t  category = LIBSBML_CAT_SBML)

Constructor; creates a new CompValidator object for the given category of validation.

Parameters
categorycode indicating the kind of validations that this validator will perform. The category code value must be taken from the enumeration SBMLErrorCategory_t
CompValidator::~CompValidator ( )
virtual

Destroys this CompValidator object.

Member Function Documentation

void CompValidator::addConstraint ( VConstraint c)
virtual

Adds the given VContraint object to this validator.

Parameters
cthe VConstraint ("validator constraint") object to add.

Reimplemented from Validator.

void Validator::clearFailures ( )
inherited

Clears this Validator's list of validation failures.

If you are validating multiple SBML documents with the same Validator, call this method after you have processed the list of failures from the last Validation run and before validating the next document.

unsigned int Validator::getCategory ( ) const
inherited

Get the category of validation rules covered by this validator.

Returns
an integer code representing the category of validator rules covered by this validator class. The category values are drawn from the enumeration SBMLErrorCategory_t. See the documentation for the class SBMLError for more information.
const std::list< SBMLError > & Validator::getFailures ( ) const
inherited

Get the list of SBMLError objects logged during validator execution.

Returns
a list of failures logged during validation. The list may be empty if no errors or other diagnostics were logged by the validator.
virtual void CompValidator::init ( )
pure virtual

Initializes this CompValidator object.

When creating a subclass of CompValidator, override this method to add your own validation code.

Implements Validator.

void Validator::logFailure ( const SBMLError err)
inherited

Adds the given failure to this list of validation failures.

This method can be used in the implementation of custom validators.

Parameters
errthe SBMLError object to append.
unsigned int CompValidator::validate ( const SBMLDocument d)
virtual

Validates the given SBML document.

Parameters
dthe SBMLDocument object to be validated.
Returns
the number of validation failures that occurred. The objects describing the actual failures can be retrieved using getFailures().

Reimplemented from Validator.

unsigned int CompValidator::validate ( const std::string &  filename)
virtual

Validates the SBML document located at the given file name.

Parameters
filenamethe path to the file to be read and validated.
Returns
the number of validation failures that occurred. The objects describing the actual failures can be retrieved using getFailures().

Reimplemented from Validator.