libSBML C++ API
libSBML 5.18.0 C++ API
|
Example #4 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"));
= static_cast<CompModelPlugin*>(mod1->
getPlugin(
"comp"));
m1port.setId("comp_port");
m1port.setIdRef("S");
m1port.setId("S_port");
m1port.setIdRef("E");
m1port.setId("E_port");
m1port.setIdRef("D");
m1port.setId("D_port");
m1port.setIdRef("ES");
m1port.setId("ES_port");
m1port.setIdRef("J0");
m1port.setId("J0_port");
m1port.setIdRef("J1");
m1port.setId("J1_port");
= static_cast<CompModelPlugin*>(mod2->
getPlugin(
"comp"));
port.setIdRef("S");
port.setId("comp_port");
port.setIdRef("comp");
port.setId("J0_port");
port.setIdRef("J0");
model->
setId(
"complexified");
= static_cast<CompModelPlugin*>(model->
getPlugin(
"comp"));
submod1->setModelRef("enzyme");
= static_cast<CompSBasePlugin*>(mcomp->
getPlugin(
"comp"));
re.setSubmodelRef("A");
re.setSubmodelRef("B");
re.unsetIdRef();
re.setPortRef("comp_port");
= static_cast<CompSBasePlugin*>(spec.
getPlugin(
"comp"));
sre->setIdRef("S");
sre->setIdRef("D");
= static_cast<CompSBasePlugin*>(blankrxn.
getPlugin(
"comp"));
deletion.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;
}
A reference to an SBML species in a reaction.
Definition: SpeciesReference.h:275
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:681
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Deletion.
Definition: Deletion.cpp:113
An SBML reaction between species in an SBML model.
Definition: Reaction.h:218
int setInitialConcentration(double value)
Sets the "initialConcentration" attribute of this Species and marks the field as set.
Definition: Species.cpp:699
An interface to be used in composition.
Definition: Port.h:85
virtual int setName(const std::string &name)
Sets the value of the "name" attribute of this Model.
Definition: Model.cpp:744
Include all SBML types in a single header file.
int setReversible(bool value)
Sets the value of the "reversible" attribute of this Reaction.
Definition: Reaction.cpp:607
int addProduct(const SpeciesReference *sr)
Adds a given SpeciesReference object as a product in this Reaction.
Definition: Reaction.cpp:847
A model used in model composition.
Definition: ModelDefinition.h:65
static SBMLExtensionRegister< CompExtension > compExtensionRegistry
Definition: CompExtension.cpp:104
int unsetInitialConcentration()
Unsets the "initialConcentration" attribute value of this Species object.
Definition: Species.cpp:961
Model * createModel(const std::string sid="")
Creates a new Model inside this SBMLDocument, and returns a pointer to it.
Definition: SBMLDocument.cpp:643
int setFast(bool value)
Sets the value of the "fast" attribute of this Reaction.
Definition: Reaction.cpp:620
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:603
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Compartment object.
Definition: Compartment.cpp:474
int writeSBMLToFile(const SBMLDocument_t *d, const char *filename)
Writes the given SBML document d to the file filename.
int addReactant(const SpeciesReference *sr)
Adds a given SpeciesReference object as a reactant in this Reaction.
Definition: Reaction.cpp:792
virtual int setDeletion(const std::string &id)
Sets the value of the "deletion" attribute of this ReplacedElement.
Definition: ReplacedElement.cpp:155
int setConstant(bool value)
Sets the "constant" attribute of this Species object.
Definition: Species.cpp:824
virtual int setSubmodelRef(const std::string &id)
Sets the value of the "submodelRef" attribute of this SBaseRef.
Definition: Replacing.cpp:95
An SBML compartment, where species are located.
Definition: Compartment.h:484
Deletion of an object from a submodel.
Definition: Deletion.h:104
Extension of SBMLDocument.
Definition: CompSBMLDocumentPlugin.h:88
ReplacedElement * createReplacedElement()
Creates a ReplacedElement object, adds it to the end of the ReplacedElement objects list and returns ...
Definition: CompSBasePlugin.cpp:370
Template class for extension package registration
Definition: SBMLExtensionRegister.h:68
Extension of SBase.
Definition: CompSBasePlugin.h:79
SpeciesReference * removeReactant(unsigned int n)
Removes the nth reactant species (SpeciesReference object) in the list of reactants in this Reaction ...
Definition: Reaction.cpp:1296
int setSpecies(const std::string &sid)
Sets the "species" attribute of this SimpleSpeciesReference.
Definition: SimpleSpeciesReference.cpp:192
An SBML model.
Definition: Model.h:479
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Species.
Definition: Species.cpp:586
int addPort(const Port *port)
Adds a copy of the given Port object to the list of ports.
Definition: CompModelPlugin.cpp:411
virtual int setPortRef(const std::string &id)
Sets the value of the "portRef" attribute of this SBaseRef.
Definition: SBaseRef.cpp:242
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:304
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Port.
Definition: Port.cpp:98
unsigned int checkConsistency()
Performs consistency checking and validation on this SBML document.
Definition: SBMLDocument.cpp:713
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:320
virtual int setModelRef(const std::string &modelRef)
Sets the value of the "modelRef" attribute of this Submodel.
Definition: Submodel.cpp:249
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:1207
Port * createPort()
Creates a Port object, adds it to the end of the port objects list and returns a pointer to the newly...
Definition: CompModelPlugin.cpp:452
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Submodel.
Definition: Submodel.cpp:173
Definition of CompExtension, the core module of comp package.
ModelDefinition * createModelDefinition()
Creates a ModelDefinition object, adds it to the end of the ModelDefinition objects list and returns ...
Definition: CompSBMLDocumentPlugin.cpp:398
unsigned int getNumFailsWithSeverity(unsigned int severity)
Returns the number of errors that have been logged with the given severity code.
Definition: SBMLErrorLog.cpp:337
Definition of CompSBasePlugin, the plugin class of comp package for the Model element.
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Reaction.
Definition: Reaction.cpp:516
Indicates an object replaced by another.
Definition: ReplacedBy.h:65
int setStoichiometry(double value)
Sets the value of the "stoichiometry" attribute of this SpeciesReference.
Definition: SpeciesReference.cpp:307
Definition: SBMLError.h:970
ReplacedBy * createReplacedBy()
Creates a new, empty ReplacedBy, adds it to this CompSBasePlugin and returns the created ReplacedBy.
Definition: CompSBasePlugin.cpp:442
Template class for registering extension packages.
Deletion * createDeletion()
Creates a Deletion object, adds it to the end of the deletion objects list and returns a pointer to t...
Definition: Submodel.cpp:495
int addSpecies(const Species *s)
Adds a copy of the given Species object to this Model.
Definition: Model.cpp:1274
int setConstant(bool flag)
Sets the "constant" attribute of this SpeciesReference to the given boolean flag.
Definition: SpeciesReference.cpp:395
int addReaction(const Reaction *r)
Adds a copy of the given Reaction object to this Model.
Definition: Model.cpp:1394
Set of SBML Level + Version + namespace triples.
Definition: SBMLNamespaces.h:139
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:311
SBMLErrorLog * getErrorLog()
Returns the list of errors or warnings logged during parsing, consistency checking,...
Definition: SBMLDocument.cpp:1364
int setCompartment(const std::string &sid)
Sets the "compartment" attribute of this Species object.
Definition: Species.cpp:665
virtual int setId(const std::string &sid)
Sets the value of the "id" attribute of this Model.
Definition: Model.cpp:717
Compartment * createCompartment()
Creates a new Compartment inside this Model and returns it.
Definition: Model.cpp:1563
Extension of Model.
Definition: CompModelPlugin.h:81
void setConsistencyChecks(SBMLErrorCategory_t category, bool apply)
Controls the consistency checks that are performed when SBMLDocument::checkConsistency() is called.
Definition: SBMLDocument.cpp:691
An SBML species – a pool of entities.
Definition: Species.h:423
A model instance inside another model.
Definition: Submodel.h:150
int setSpatialDimensions(unsigned int value)
Sets the "spatialDimensions" attribute of this Compartment object.
Definition: Compartment.cpp:556
#define LIBSBML_CPP_NAMESPACE_USE
Definition: libsbml-namespace.h:67
Overall SBML container object.
Definition: SBMLDocument.h:342
int setSize(double value)
Sets the "size" attribute (or "volume" in SBML Level 1) of this Compartment object.
Definition: Compartment.cpp:605
int setBoundaryCondition(bool value)
Sets the "boundaryCondition" attribute of this Species object.
Definition: Species.cpp:791
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:3460
int setHasOnlySubstanceUnits(bool value)
Sets the "hasOnlySubstanceUnits" attribute of this Species object.
Definition: Species.cpp:771
Indicates an object replaces another.
Definition: ReplacedElement.h:137