libSBML C++ API  libSBML 5.13.0 C++ API
Port Class Reference
Inheritance diagram for Port:
[legend]

Detailed Description

{comp}

comp An interface to be used in composition.

The Port class was introduced by the SBML Level 3 Hierarchical Model Composition (“comp”) package to allow a Model to define a standard interface between it and other models that might use it as a submodel. It derives from the SBaseRef class, and the elements defined there refer to elements in the same parent Model as the Port object. A Port object instance therefore uses those attributes to define a port for a component in a model. When other SBaseRef or SBaseRef-derived classes refer to a Port object using a "portRef" attribute, the element being referenced is the element the Port object itself points to.

In the present formulation of the Hierarchical Model Composition package, the use of ports is not enforced, nor is there any mechanism to restrict which ports may be used in what ways—they are only an advisory construct. Future versions of this SBML package may provide additional functionality to support explicit restrictions on port use. For the present definition of Hierarchical Model Composition, users of models containing ports are encouraged to respect the modeler's intention in defining ports, and use the port definitions to interact with components through their ports (when they have ports defined) rather than interact directly with the components.

The required attribute "id" is used to give an identifier to a Port object so that other objects can refer to it. The attribute has type PortSId and is essentially identical to the SBML primitive type SId, except that its namespace is limited to the identifiers of Port objects defined within a Model object. In parallel, the PortSId type has a companion type, PortSIdRef, that corresponds to the SBML primitive type SIdRef; the value space of PortSIdRef is limited to PortSId values.

Examples:
spec_example3.cpp, and spec_example4.cpp.

Public Member Functions

virtual void clearReferencedElement ()
 Removes the saved referenced element, if it had been saved earlier. More...
 
virtual Portclone () const
 Creates and returns a deep copy of this Port object. More...
 
SBaseRefcreateSBaseRef ()
 Creates a new, empty SBaseRef, adds it to this SBaseRef and returns the created SBaseRef. More...
 
virtual ListgetAllElements (ElementFilter *filter=NULL)
 Returns a List of all child SBase* objects, including those nested to an arbitrary depth. More...
 
virtual SBasegetElementByMetaId (const std::string &metaid)
 Returns the first child element it can find with the given metaid, or itself if it has the given metaid, or NULL if no such object is found. More...
 
virtual SBasegetElementBySId (const std::string &id)
 Returns the first child element found that has the given id in the model-wide SId namespace, or NULL if no such object is found. More...
 
virtual const std::string & getElementName () const
 Returns the XML element name of this SBML object. More...
 
virtual const std::string & getId () const
 Returns the value of the "id" attribute of this Port. More...
 
virtual const std::string & getIdRef () const
 Returns the value of the "idRef" attribute of this SBaseRef. More...
 
virtual const std::string & getMetaIdRef () const
 Returns the value of the "metaIdRef" attribute of this SBaseRef. More...
 
virtual const std::string & getName () const
 Returns the value of the "name" attribute of this Port. More...
 
virtual int getNumReferents () const
 Returns how many elements are being referred to by this SBaseRef. More...
 
virtual const std::string & getPortRef () const
 Returns the value of the "portRef" attribute of this SBaseRef. More...
 
virtual SBasegetReferencedElement ()
 Returns the object pointed to by this element. More...
 
virtual SBasegetReferencedElementFrom (Model *model)
 Examines the referenced Model for the referenced object, and returns it, if found. More...
 
const SBaseRefgetSBaseRef () const
 Get the child sBaseRef of this sBaseRef. More...
 
SBaseRefgetSBaseRef ()
 Get the child sBaseRef of this SBaseRef. More...
 
virtual int getTypeCode () const
 Returns the libSBML type code of this object instance. More...
 
virtual const std::string & getUnitRef () const
 Returns the value of the "unitRef" attribute of this SBaseRef. More...
 
virtual bool hasRequiredAttributes () const
 Returns true if the 'id' attribute is set, and if exactly one of the optional attributes of SBaseRef (portRef, idRef, metaIdRef, and unitRef)are set. More...
 
virtual bool isSetId () const
 Predicate returning true or false depending on whether this Port's "id" attribute has been set. More...
 
virtual bool isSetIdRef () const
 Predicate returning true or false depending on whether this SBaseRef's "idRef" attribute has been set. More...
 
virtual bool isSetMetaIdRef () const
 Predicate returning true or false depending on whether this SBaseRef's "metaIdRef" attribute has been set. More...
 
virtual bool isSetName () const
 Predicate returning true or false depending on whether this Port's "name" attribute has been set. More...
 
virtual bool isSetPortRef () const
 Predicate returning true or false depending on whether this SBaseRef's "portRef" attribute has been set. More...
 
bool isSetSBaseRef () const
 Predicate for testing whether the sBaseRef for this SBaseRef is set. More...
 
virtual bool isSetUnitRef () const
 Predicate returning true or false depending on whether this SBaseRef's "unitRef" attribute has been set. More...
 
Portoperator= (const Port &source)
 Assignment operator. More...
 
virtual int performDeletion ()
 DEPRECATED FUNCTION: DO NOT USE. More...
 
 Port (unsigned int level=CompExtension::getDefaultLevel(), unsigned int version=CompExtension::getDefaultVersion(), unsigned int pkgVersion=CompExtension::getDefaultPackageVersion())
 Creates a new Port with the given level, version, and package version. More...
 
 Port (CompPkgNamespaces *compns)
 Creates a new Port with the given CompPkgNamespaces object. More...
 
 Port (const Port &source)
 Copy constructor. More...
 
virtual int removeFromParentAndDelete ()
 Finds this SBaseRef's parent, which can either be a List or can be another SBaseRef, and tells it to remove this. More...
 
virtual void renameMetaIdRefs (const std::string &oldid, const std::string &newid)
 
virtual void renameSIdRefs (const std::string &oldid, const std::string &newid)
 
virtual void renameUnitSIdRefs (const std::string &oldid, const std::string &newid)
 
virtual int saveReferencedElement ()
 Finds and stores the referenced object by finding its Model parent, calling 'getReferencedElementFrom()' on that model, and storing the result. More...
 
virtual int setId (const std::string &id)
 Sets the value of the "id" attribute of this Port. More...
 
virtual int setIdRef (const std::string &id)
 Sets the value of the "idRef" attribute of this SBaseRef. More...
 
virtual int setMetaIdRef (const std::string &id)
 Sets the value of the "metaIdRef" attribute of this SBaseRef. More...
 
virtual int setName (const std::string &name)
 Sets the value of the "name" attribute of this Port. More...
 
virtual int setPortRef (const std::string &id)
 Overrides SBaseRef::setPortRef to always fail, because Port objects themselves cannot refer to model elements by PortSId. More...
 
int setSBaseRef (const SBaseRef *sBaseRef)
 Sets the sBaseRef definition of this SBaseRef to a copy of the given SBaseRef object instance. More...
 
virtual int setUnitRef (const std::string &id)
 Sets the value of the "unitRef" attribute of this SBaseRef. More...
 
virtual int unsetId ()
 Unsets the value of the "id" attribute of this Port. More...
 
virtual int unsetIdRef ()
 Unsets the value of the "idRef" attribute of this SBaseRef. More...
 
virtual int unsetMetaIdRef ()
 Unsets the value of the "metaIdRef" attribute of this SBaseRef. More...
 
virtual int unsetName ()
 Unsets the value of the "name" attribute of this Port. More...
 
virtual int unsetPortRef ()
 Unsets the value of the "portRef" attribute of this SBaseRef. More...
 
virtual int unsetSBaseRef ()
 Unsets the child SBaseRef of this SBaseRef. More...
 
virtual int unsetUnitRef ()
 Unsets the value of the "unitRef" attribute of this SBaseRef. More...
 
virtual ~Port ()
 Destructor. More...
 

Constructor & Destructor Documentation

§ Port() [1/3]

Port::Port ( unsigned int  level = CompExtension::getDefaultLevel(),
unsigned int  version = CompExtension::getDefaultVersion(),
unsigned int  pkgVersion = CompExtension::getDefaultPackageVersion() 
)

Creates a new Port with the given level, version, and package version.

Parameters
levelthe SBML Level
versionthe Version within the SBML Level
pkgVersionthe version of the package

§ Port() [2/3]

Port::Port ( CompPkgNamespaces compns)

Creates a new Port with the given CompPkgNamespaces object.

Parameters
compnsthe namespace to use

§ Port() [3/3]

Port::Port ( const Port source)

Copy constructor.

§ ~Port()

Port::~Port ( )
virtual

Destructor.

Member Function Documentation

§ clearReferencedElement()

void SBaseRef::clearReferencedElement ( )
virtualinherited

Removes the saved referenced element, if it had been saved earlier.

§ clone()

Port * Port::clone ( ) const
virtual

Creates and returns a deep copy of this Port object.

Returns
a (deep) copy of this Port object

Reimplemented from SBaseRef.

§ createSBaseRef()

SBaseRef * SBaseRef::createSBaseRef ( )
inherited

Creates a new, empty SBaseRef, adds it to this SBaseRef and returns the created SBaseRef.

Returns
the newly created SBaseRef object instance.

§ getAllElements()

List * SBaseRef::getAllElements ( ElementFilter filter = NULL)
virtualinherited

Returns a List of all child SBase* objects, including those nested to an arbitrary depth.

Returns
a List* of pointers to all children objects.

§ getElementByMetaId()

SBase * SBaseRef::getElementByMetaId ( const std::string &  metaid)
virtualinherited

Returns the first child element it can find with the given metaid, or itself if it has the given metaid, or NULL if no such object is found.

Parameters
metaidstring representing the metaid of objects to find
Returns
a pointer to the SBase element with the given metaid.

§ getElementBySId()

SBase * SBaseRef::getElementBySId ( const std::string &  id)
virtualinherited

Returns the first child element found that has the given id in the model-wide SId namespace, or NULL if no such object is found.

Parameters
idstring representing the id of objects to find
Returns
a pointer to the SBase element with the given id.

§ getElementName()

const std::string & Port::getElementName ( ) const
virtual

Returns the XML element name of this SBML object.

Returns
the name of this element, as a text string.

Reimplemented from SBaseRef.

§ getId()

const string & Port::getId ( ) const
virtual

Returns the value of the "id" attribute of this Port.

Returns
the value of the "id" attribute of this Port.

§ getIdRef()

const string & SBaseRef::getIdRef ( ) const
virtualinherited

Returns the value of the "idRef" attribute of this SBaseRef.

Returns
the value of the "idRef" attribute of this SBaseRef.

§ getMetaIdRef()

const string & SBaseRef::getMetaIdRef ( ) const
virtualinherited

Returns the value of the "metaIdRef" attribute of this SBaseRef.

Returns
the value of the "metaIdRef" attribute of this SBaseRef.

§ getName()

const string & Port::getName ( ) const
virtual

Returns the value of the "name" attribute of this Port.

Returns
the value of the "name" attribute of this Port.

§ getNumReferents()

int SBaseRef::getNumReferents ( ) const
virtualinherited

Returns how many elements are being referred to by this SBaseRef.

A valid SBaseRef will have exactly one. Possible referents are portRef, idRef, unitRef, and metaIdRef.

Returns
integer value between 0 and 4: the number of different ways this element points to its referent.

Reimplemented in ReplacedElement.

§ getPortRef()

const string & SBaseRef::getPortRef ( ) const
virtualinherited

Returns the value of the "portRef" attribute of this SBaseRef.

Returns
the value of the "portRef" attribute of this SBaseRef.

§ getReferencedElement()

SBase * SBaseRef::getReferencedElement ( )
virtualinherited

Returns the object pointed to by this element.

If that element was previously found and set with 'saveReferencedElement', that element is returned; otherwise, 'saveReferencedElement' is called first, and the found element is returned.

§ getReferencedElementFrom()

SBase * SBaseRef::getReferencedElementFrom ( Model model)
virtualinherited

Examines the referenced Model for the referenced object, and returns it, if found.

Parameters
modelthe Model in which to look for the object referenced by this SBaseRef.
Returns
the element in the referenced Model to which this SBaseRef refers. If this object references an object in a Submodel, the returned object will be in the instantiated Model in that Submodel.

Reimplemented in ReplacedElement.

§ getSBaseRef() [1/2]

const SBaseRef * SBaseRef::getSBaseRef ( ) const
inherited

Get the child sBaseRef of this sBaseRef.

Returns
the const SBaseRef child of this SBaseRef, or NULL if none exists.

§ getSBaseRef() [2/2]

SBaseRef * SBaseRef::getSBaseRef ( )
inherited

Get the child sBaseRef of this SBaseRef.

Returns
the SBaseRef child of this SBaseRef, or NULL if none exists.

§ getTypeCode()

int Port::getTypeCode ( ) const
virtual

Returns the libSBML type code of this object instance.

LibSBML attaches an identifying code to every kind of SBML object. These are integer constants known as SBML type codes. The names of all the codes begin with the characters SBML_. The set of possible type codes for core elements is defined in the enumeration SBMLTypeCode_t, and in addition, libSBML plug-ins for SBML Level 3 packages define their own extra enumerations of type codes (e.g., SBMLLayoutTypeCode_t for the Level 3 Layout package). Note that different Level 3 package plug-ins may use overlapping type codes; to identify the package to which a given object belongs, call the getPackageName() method on the object.
Returns
the SBML type code for this object: SBML_COMP_PORTendif

Reimplemented from SBaseRef.

§ getUnitRef()

const string & SBaseRef::getUnitRef ( ) const
virtualinherited

Returns the value of the "unitRef" attribute of this SBaseRef.

Returns
the value of the "unitRef" attribute of this SBaseRef.

§ hasRequiredAttributes()

bool Port::hasRequiredAttributes ( ) const
virtual

Returns true if the 'id' attribute is set, and if exactly one of the optional attributes of SBaseRef (portRef, idRef, metaIdRef, and unitRef)are set.

Returns
boolean: 'true' if the attributes are correctly set; 'false' if not.

Reimplemented from SBaseRef.

§ isSetId()

bool Port::isSetId ( ) const
virtual

Predicate returning true or false depending on whether this Port's "id" attribute has been set.

Returns
true if this Port's "id" attribute has been set, otherwise false is returned.

§ isSetIdRef()

bool SBaseRef::isSetIdRef ( ) const
virtualinherited

Predicate returning true or false depending on whether this SBaseRef's "idRef" attribute has been set.

Returns
true if this SBaseRef's "idRef" attribute has been set, otherwise false is returned.

§ isSetMetaIdRef()

bool SBaseRef::isSetMetaIdRef ( ) const
virtualinherited

Predicate returning true or false depending on whether this SBaseRef's "metaIdRef" attribute has been set.

Returns
true if this SBaseRef's "metaIdRef" attribute has been set, otherwise false is returned.

§ isSetName()

bool Port::isSetName ( ) const
virtual

Predicate returning true or false depending on whether this Port's "name" attribute has been set.

Returns
true if this Port's "name" attribute has been set, otherwise false is returned.

§ isSetPortRef()

bool SBaseRef::isSetPortRef ( ) const
virtualinherited

Predicate returning true or false depending on whether this SBaseRef's "portRef" attribute has been set.

Returns
true if this SBaseRef's "portRef" attribute has been set, otherwise false is returned.

§ isSetSBaseRef()

bool SBaseRef::isSetSBaseRef ( ) const
inherited

Predicate for testing whether the sBaseRef for this SBaseRef is set.

Returns
true if the sBaseRef of this SBaseRef is set, false otherwise.

§ isSetUnitRef()

bool SBaseRef::isSetUnitRef ( ) const
virtualinherited

Predicate returning true or false depending on whether this SBaseRef's "unitRef" attribute has been set.

Returns
true if this SBaseRef's "unitRef" attribute has been set, otherwise false is returned.

§ operator=()

Port & Port::operator= ( const Port source)

Assignment operator.

§ performDeletion()

int SBaseRef::performDeletion ( )
virtualinherited

DEPRECATED FUNCTION: DO NOT USE.

Deletes the referenced object, plus any other elements that element points to through ReplacedElement or ReplacedBy children. Instead of calling this function directly, use 'CompModelPlugin::instantiateSubmodels' instead, which deals with all the intricacies of replacements and deletions, and gives you access to the non-flattened hierarchical form of the model.

§ removeFromParentAndDelete()

int SBaseRef::removeFromParentAndDelete ( )
virtualinherited

Finds this SBaseRef's parent, which can either be a List or can be another SBaseRef, and tells it to remove this.

Reimplemented in ReplacedBy.

§ renameMetaIdRefs()

void Port::renameMetaIdRefs ( const std::string &  oldid,
const std::string &  newid 
)
virtual

§ renameSIdRefs()

void Port::renameSIdRefs ( const std::string &  oldid,
const std::string &  newid 
)
virtual

Reimplemented from SBaseRef.

§ renameUnitSIdRefs()

void Port::renameUnitSIdRefs ( const std::string &  oldid,
const std::string &  newid 
)
virtual

§ saveReferencedElement()

int Port::saveReferencedElement ( )
virtual

Finds and stores the referenced object by finding its Model parent, calling 'getReferencedElementFrom()' on that model, and storing the result.

Reimplemented from SBaseRef.

§ setId()

int Port::setId ( const std::string &  id)
virtual

Sets the value of the "id" attribute of this Port.

This method fails if the id is not a valid syntax for an SId.

Parameters
idthe identifier for the port
Examples:
spec_example3.cpp, and spec_example4.cpp.

§ setIdRef()

int SBaseRef::setIdRef ( const std::string &  id)
virtualinherited

Sets the value of the "idRef" attribute of this SBaseRef.

This method fails if the id is not a valid syntax for an SIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUEendif

Examples:
spec_example2.cpp, spec_example3.cpp, and spec_example4.cpp.

§ setMetaIdRef()

int SBaseRef::setMetaIdRef ( const std::string &  id)
virtualinherited

Sets the value of the "metaIdRef" attribute of this SBaseRef.

This method fails if the id is not a valid syntax for an IDREF (LIBSBML_INVALID_ATTRIBUTE_VALUEendif

§ setName()

int Port::setName ( const std::string &  name)
virtual

Sets the value of the "name" attribute of this Port.

§ setPortRef()

int Port::setPortRef ( const std::string &  id)
virtual

Overrides SBaseRef::setPortRef to always fail, because Port objects themselves cannot refer to model elements by PortSId.

Parameters
idthe identifier to set for the port reference
Returns
integer value indicating failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible value returned by this function is:

Reimplemented from SBaseRef.

§ setSBaseRef()

int SBaseRef::setSBaseRef ( const SBaseRef sBaseRef)
inherited

Sets the sBaseRef definition of this SBaseRef to a copy of the given SBaseRef object instance.

This method fails if the added sBaseRef does not match the level/version/package of the parent object or if the added sBaseRef cannot be copied.

Parameters
sBaseRefthe SBaseRef object instance to use.

§ setUnitRef()

int SBaseRef::setUnitRef ( const std::string &  id)
virtualinherited

Sets the value of the "unitRef" attribute of this SBaseRef.

This method fails if the id is not a valid syntax for a UnitSIdRef (LIBSBML_INVALID_ATTRIBUTE_VALUEendif

§ unsetId()

int Port::unsetId ( )
virtual

Unsets the value of the "id" attribute of this Port.

§ unsetIdRef()

int SBaseRef::unsetIdRef ( )
virtualinherited

Unsets the value of the "idRef" attribute of this SBaseRef.

Examples:
spec_example3.cpp, and spec_example4.cpp.

§ unsetMetaIdRef()

int SBaseRef::unsetMetaIdRef ( )
virtualinherited

Unsets the value of the "metaIdRef" attribute of this SBaseRef.

§ unsetName()

int Port::unsetName ( )
virtual

Unsets the value of the "name" attribute of this Port.

§ unsetPortRef()

int SBaseRef::unsetPortRef ( )
virtualinherited

Unsets the value of the "portRef" attribute of this SBaseRef.

§ unsetSBaseRef()

int SBaseRef::unsetSBaseRef ( )
virtualinherited

Unsets the child SBaseRef of this SBaseRef.

Deletes the former SBaseRef child, if one existed.

§ unsetUnitRef()

int SBaseRef::unsetUnitRef ( )
virtualinherited

Unsets the value of the "unitRef" attribute of this SBaseRef.