libSBML C++ API
libSBML 5.17.2 C++ API
|
Example #2 from the SBML Level 3 Hierarchical Model Composition specification.
#include <iostream>
#include <sstream>
#ifdef WIN32
#include <conio.h>
#endif
using namespace std;
int main(int argc,char** argv)
{
int retval = 0;
= static_cast<CompSBMLDocumentPlugin*>(document->
getPlugin(
"comp"));
extmod->
setId(
"ExtMod1");
submod1->setModelRef("ExtMod1");
re.setSubmodelRef("A");
re.setSubmodelRef("B");
re.setIdRef("S");
re.setSubmodelRef("A");
re.setSubmodelRef("B");
delete document;
if (document == NULL)
{
cout << "Error reading back in file." << endl;
retval = -1;
}
else
{
{
stringstream errorstream;
cout << "Errors encoutered when round-tripping SBML file: \n"
<< errorstream.str() << endl;
retval = -1;
}
delete document;
}
#ifdef WIN32
if (retval != 0)
{
cout << "(Press any key to exit.)" << endl;
_getch();
}
#endif
return retval;
}
The registry class for tracking package extensions.
int setConstant(bool value)
Sets the value of the "constant" attribute of this Compartment object.
Definition: Compartment.cpp:677
virtual int setModelRef(const std::string &id)
Sets the value of the "modelRef" attribute of this ExternalModelDefinition.
Definition: ExternalModelDefinition.cpp:218
virtual int setSource(const std::string &source)
Sets the value of the "source" attribute of this ExternalModelDefinition.
Definition: ExternalModelDefinition.cpp:324
Include all SBML types in a single header file.
static SBMLExtensionRegister< CompExtension > compExtensionRegistry
Definition: CompExtension.cpp:100
Species * createSpecies()
Creates a new Species inside this Model and returns it.
Definition: Model.cpp:1582
Definition of CompModelPlugin, the plugin class of comp package for the Model element.
virtual int setRequired(bool value)
Sets the bool value of "required" attribute of corresponding package in SBMLDocument element.
Definition: CompSBMLDocumentPlugin.cpp:599
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Compartment object.
Definition: Compartment.cpp:470
int writeSBMLToFile(const SBMLDocument_t *d, const char *filename)
Writes the given SBML document d to the file filename.
A reference to an externally-defined model.
Definition: ExternalModelDefinition.h:118
int setConstant(bool value)
Sets the "constant" attribute of this Species object.
Definition: Species.cpp:820
An SBML compartment, where species are located.
Definition: Compartment.h:480
ExternalModelDefinition * createExternalModelDefinition()
Creates a ExternalModelDefinition object, adds it to the end of the ExternalModelDefinition objects l...
Definition: CompSBMLDocumentPlugin.cpp:535
Extension of SBMLDocument.
Definition: CompSBMLDocumentPlugin.h:84
Template class for extension package registration
Definition: SBMLExtensionRegister.h:64
Extension of SBase.
Definition: CompSBasePlugin.h:75
An SBML model.
Definition: Model.h:475
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Species.
Definition: Species.cpp:582
SBMLDocument_t * readSBMLFromFile(const char *filename)
virtual int setIdRef(const std::string &id)
Sets the value of the "idRef" attribute of this SBaseRef.
Definition: SBaseRef.cpp:300
unsigned int checkConsistency()
Performs consistency checking and validation on this SBML document.
Definition: SBMLDocument.cpp:705
Definition of CompSBMLDocumentPlugin, the plugin class of comp package for the Model element.
int addReplacedElement(const ReplacedElement *replacedElement)
Adds a copy of the given ReplacedElement object to the list of ReplacedElements.
Definition: CompSBasePlugin.cpp:314
virtual int setModelRef(const std::string &modelRef)
Sets the value of the "modelRef" attribute of this Submodel.
Definition: Submodel.cpp:245
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:1199
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Submodel.
Definition: Submodel.cpp:169
Definition of CompExtension, the core module of comp package.
unsigned int getNumFailsWithSeverity(unsigned int severity)
Returns the number of errors that have been logged with the given severity code.
Definition: SBMLErrorLog.cpp:333
Definition of CompSBasePlugin, the plugin class of comp package for the Model element.
Definition: SBMLError.h:964
Template class for registering extension packages.
Set of SBML Level + Version + namespace triples.
Definition: SBMLNamespaces.h:135
Submodel * createSubmodel()
Creates a Submodel object, adds it to the end of the submodel objects list and returns a pointer to t...
Definition: CompModelPlugin.cpp:307
SBMLErrorLog * getErrorLog()
Returns the list of errors or warnings logged during parsing, consistency checking,...
Definition: SBMLDocument.cpp:1356
int setCompartment(const std::string &sid)
Sets the "compartment" attribute of this Species object.
Definition: Species.cpp:661
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this ExternalModelDefinition.
Definition: ExternalModelDefinition.cpp:146
Compartment * createCompartment()
Creates a new Compartment inside this Model and returns it.
Definition: Model.cpp:1555
Extension of Model.
Definition: CompModelPlugin.h:77
void setConsistencyChecks(SBMLErrorCategory_t category, bool apply)
Controls the consistency checks that are performed when SBMLDocument::checkConsistency() is called.
Definition: SBMLDocument.cpp:683
An SBML species – a pool of entities.
Definition: Species.h:419
A model instance inside another model.
Definition: Submodel.h:146
int setSpatialDimensions(unsigned int value)
Sets the "spatialDimensions" attribute of this Compartment object.
Definition: Compartment.cpp:552
#define LIBSBML_CPP_NAMESPACE_USE
Definition: libsbml-namespace.h:63
Overall SBML container object.
Definition: SBMLDocument.h:338
int setSize(double value)
Sets the "size" attribute (or "volume" in SBML Level 1) of this Compartment object.
Definition: Compartment.cpp:601
int setBoundaryCondition(bool value)
Sets the "boundaryCondition" attribute of this Species object.
Definition: Species.cpp:787
SBasePlugin * getPlugin(const std::string &package)
Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given p...
Definition: SBase.cpp:3456
int setHasOnlySubstanceUnits(bool value)
Sets the "hasOnlySubstanceUnits" attribute of this Species object.
Definition: Species.cpp:767
Indicates an object replaces another.
Definition: ReplacedElement.h:133
Model * createModel(const std::string &sid="")
Creates a new Model inside this SBMLDocument, and returns a pointer to it.
Definition: SBMLDocument.cpp:635