libCombine
C++ library for working with the COMBINE Archive format
Loading...
Searching...
No Matches
CaListOf Class Reference
+ Inheritance diagram for CaListOf:

Public Member Functions

 CaListOf (unsigned int level=OMEX_DEFAULT_LEVEL, unsigned int version=OMEX_DEFAULT_VERSION)
 Creates a new CaListOf object. More...
 
 CaListOf (CaNamespaces *omexns)
 Creates a new CaListOf with a given CaNamespaces object. More...
 
virtual ~CaListOf ()
 Destroys this CaListOf and the items inside it. More...
 
 CaListOf (const CaListOf &orig)
 Copy constructor; creates a copy of this CaListOf. More...
 
CaListOfoperator= (const CaListOf &rhs)
 Assignment operator for CaListOf. More...
 
virtual CaListOfclone () const
 Creates and returns a deep copy of this CaListOf object. More...
 
int append (const CaBase *item)
 Adds an item to the end of this CaListOf's list of items. More...
 
int appendAndOwn (CaBase *disownedItem)
 Adds an item to the end of this CaListOf's list of items. More...
 
virtual int appendFrom (const CaListOf *list)
 Adds a clone of a list of items to this CaListOf's list. More...
 
int insert (int location, const CaBase *item)
 Inserts an item at a given position in this CaListOf's list of items. More...
 
int insertAndOwn (int location, CaBase *disownedItem)
 Inserts an item at a given position in this CaListOf's list of items. More...
 
virtual const CaBaseget (unsigned int n) const
 Get an item from the list. More...
 
virtual CaBaseget (unsigned int n)
 Get an item from the list. More...
 
virtual CaBasegetElementBySId (const std::string &id)
 Returns the first child element it can find with a specific "id" attribute value, or NULL if no such object is found. More...
 
virtual CaBasegetElementByMetaId (const std::string &metaid)
 Returns the first child element found with the given meta-identifier. More...
 
virtual List * getAllElements ()
 Returns a List of all child CaBase objects. More...
 
void clear (bool doDelete=true)
 Removes all items in this CaListOf object. More...
 
virtual int removeFromParentAndDelete ()
 Removes all items in this CaListOf object and deletes its properties too. More...
 
virtual CaBaseremove (unsigned int n)
 Removes the nth item from this CaListOf list of items and returns it. More...
 
unsigned int size () const
 Returns number of items in this CaListOf list. More...
 
virtual int getTypeCode () const
 Returns the libCombine type code for this object, namely, @omexconstant{OMEX_LIST_OF, CaTypeCode_t}. More...
 
virtual int getItemTypeCode () const
 Get the type code of the objects contained in this CaListOf. More...
 
virtual const std::string & getElementName () const
 Returns the XML element name of this object, which for CaListOf, is always "listOf". More...
 
- Public Member Functions inherited from CaBase
virtual ~CaBase ()
 Destroys this object. More...
 
CaBaseoperator= (const CaBase &rhs)
 Assignment operator for CaBase. More...
 
virtual CaBaseclone () const =0
 Creates and returns a deep copy of this CaBase object. More...
 
virtual CaBasegetElementBySId (const std::string &id)
 Returns the first child element it can find with a specific "id" attribute value, or NULL if no such object is found. More...
 
virtual const CaBasegetElementBySId (const std::string &metaid) const
 Returns the first child element it can find with a specific "id" attribute value, or NULL if no such object is found. More...
 
virtual CaBasegetElementByMetaId (const std::string &metaid)
 Returns the first child element it can find with a specific "metaid" attribute value, or NULL if no such object is found. More...
 
virtual const CaBasegetElementByMetaId (const std::string &metaid) const
 Returns the first child element it can find with a specific "metaid" attribute value, or NULL if no such object is found. More...
 
virtual List * getAllElements ()
 Returns a List of all child CaBase objects, including those nested to an arbitrary depth. More...
 
const std::string & getMetaId () const
 Returns the value of the "metaid" attribute of this object. More...
 
std::string & getMetaId ()
 Returns the value of the "metaid" attribute of this object. More...
 
virtual const std::string & getId () const
 
LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode * getNotes ()
 Returns the content of the "notes" subelement of this object as a tree of XMLNode objects. More...
 
const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode * getNotes () const
 Returns the content of the "notes" subelement of this object as a tree of XMLNode objects. More...
 
std::string getNotesString ()
 Returns the content of the "notes" subelement of this object as a string. More...
 
std::string getNotesString () const
 Returns the content of the "notes" subelement of this object as a string. More...
 
LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode * getAnnotation ()
 Returns the content of the "annotation" subelement of this object as a tree of XMLNode objects. More...
 
const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode * getAnnotation () const
 Returns the content of the "annotation" subelement of this object as a tree of XMLNode objects. More...
 
std::string getAnnotationString ()
 Returns the content of the "annotation" subelement of this object as a character string. More...
 
std::string getAnnotationString () const
 Returns the content of the "annotation" subelement of this object as a character string. More...
 
virtual const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces * getNamespaces () const
 Returns a list of the XML Namespaces declared on the OMEX document owning this object. More...
 
virtual LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces * getNamespaces ()
 Returns a list of the XML Namespaces declared on the OMEX document owning this object. More...
 
const CaOmexManifestgetCaOmexManifest () const
 Returns the CaOmexManifest object containing this object instance. More...
 
CaOmexManifestgetCaOmexManifest ()
 Returns the CaOmexManifest object containing this object instance. More...
 
CaBasegetParentCaObject ()
 Returns the parent OMEX object containing this object. More...
 
const CaBasegetParentCaObject () const
 Returns the parent OMEX object containing this object. More...
 
CaBasegetAncestorOfType (int type)
 Returns the first ancestor object that has the given OMEX type code. More...
 
const CaBasegetAncestorOfType (int type) const
 Returns the first ancestor object that has the given OMEX type code. More...
 
unsigned int getLine () const
 Returns the line number on which this object first appears in the XML representation of the OMEX document, or '0' if the object was created, not read from a file. More...
 
unsigned int getColumn () const
 Returns the column number on which this object first appears in the XML representation of the OMEX document, or '0' if the object was created, not read from a file. More...
 
bool isSetMetaId () const
 Predicate returning true if this object's "metaid" attribute is set. More...
 
virtual bool isSetId () const
 Predicate returning true if this object's "id" attribute is set. More...
 
bool isSetNotes () const
 Predicate returning true if this object's "notes" subelement exists and has content. More...
 
bool isSetAnnotation () const
 Predicate returning true if this object's "annotation" subelement exists and has content. More...
 
int setMetaId (const std::string &metaid)
 Sets the value of the meta-identifier attribute of this object. More...
 
virtual int setId (const std::string &sid)
 Sets the value of the "id" attribute of this OMEX object. More...
 
virtual int setAnnotation (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode *annotation)
 Sets the value of the "annotation" subelement of this OMEX object. More...
 
virtual int setAnnotation (const std::string &annotation)
 Sets the value of the "annotation" subelement of this OMEX object. More...
 
virtual int appendAnnotation (const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode *annotation)
 Appends the given annotation to the "annotation" subelement of this object. More...
 
virtual int appendAnnotation (const std::string &annotation)
 Appends the given annotation to the "annotation" subelement of this object. More...
 
int removeTopLevelAnnotationElement (const std::string elementName, const std::string elementURI="")
 Removes the top-level element within the "annotation" subelement of this OMEX object with the given name and optional URI. More...
 
int replaceTopLevelAnnotationElement (const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode *annotation)
 Replaces the given top-level element within the "annotation" subelement of this OMEX object and with the annotation element supplied. More...
 
int replaceTopLevelAnnotationElement (const std::string &annotation)
 Replaces the given top-level element within the "annotation" subelement of this OMEX object and with the annotation element supplied. More...
 
int setNotes (const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode *notes)
 Sets the value of the "notes" subelement of this OMEX object. More...
 
int setNotes (const std::string &notes, bool addXHTMLMarkup=false)
 Sets the value of the "notes" subelement of this OMEX object to a copy of the string notes. More...
 
int appendNotes (const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNode *notes)
 Appends the given notes to the "notes" subelement of this object. More...
 
int appendNotes (const std::string &notes)
 Appends the given notes to the "notes" subelement of this object. More...
 
int setNamespaces (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces *xmlns)
 Sets the namespaces relevant of this OMEX object. More...
 
int unsetMetaId ()
 Unsets the value of the "metaid" attribute of this OMEX object. More...
 
virtual int unsetId ()
 Unsets the value of the "id" attribute of this OMEX object. More...
 
int unsetNotes ()
 Unsets the value of the "notes" subelement of this OMEX object. More...
 
int unsetAnnotation ()
 Unsets the value of the "annotation" subelement of this OMEX object. More...
 
unsigned int getLevel () const
 Returns the OMEX Level of the CaOmexManifest object containing this object. More...
 
unsigned int getVersion () const
 Returns the Version within the OMEX Level of the CaOmexManifest object containing this object. More...
 
virtual int getTypeCode () const
 Returns the libCombine type code for this object. More...
 
bool hasValidLevelVersionNamespaceCombination ()
 Predicate returning true if this object's level/version and namespace values correspond to a valid OMEX specification. More...
 
virtual const std::string & getElementName () const =0
 Returns the XML element name of this object. More...
 
char * toCa ()
 Returns a string consisting of a partial OMEX corresponding to just this object. More...
 
virtual bool isSetAttribute (const std::string &attributeName) const
 
virtual int removeFromParentAndDelete ()
 Removes this object from its parent. More...
 
bool matchesCaNamespaces (const CaBase *sb)
 Returns true if this object's set of XML namespaces are the same as the given object's XML namespaces. More...
 
bool matchesCaNamespaces (const CaBase *sb) const
 Returns true if this object's set of XML namespaces are the same as the given object's XML namespaces. More...
 
bool matchesRequiredCaNamespacesForAddition (const CaBase *sb)
 Returns true if this object's set of XML namespaces are a subset of the given object's XML namespaces. More...
 
bool matchesRequiredCaNamespacesForAddition (const CaBase *sb) const
 Returns true if this object's set of XML namespaces are a subset of the given object's XML namespaces. More...
 
int setUserData (void *userData)
 Sets the user data of this element. More...
 
void * getUserData () const
 Returns the user data that has been previously set via setUserData(). More...
 
bool isSetUserData () const
 Predicate returning true or false depending on whether the user data of this element has been set. More...
 
int unsetUserData ()
 Unsets the user data of this element. More...
 
CaErrorLoggetErrorLog ()
 Returns the CaErrorLog used to log errors while reading and validating OMEX. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CaBase
bool getHasBeenDeleted () const
 
virtual void setElementText (const std::string &text)
 When overridden allows CaBase elements to use the text included in between the elements tags. More...
 

Constructor & Destructor Documentation

◆ CaListOf() [1/3]

CaListOf::CaListOf ( unsigned int  level = OMEX_DEFAULT_LEVEL,
unsigned int  version = OMEX_DEFAULT_VERSION 
)

Creates a new CaListOf object.

Parameters
levelthe OMEX Level; if not assigned, defaults to the value of OMEX_DEFAULT_LEVEL.
versionthe Version within the OMEX Level; if not assigned, defaults to the value of OMEX_DEFAULT_VERSION.

◆ CaListOf() [2/3]

CaListOf::CaListOf ( CaNamespaces omexns)

Creates a new CaListOf with a given CaNamespaces object.

Parameters
omexnsthe set of OMEX namespaces that this CaListOf should contain.

◆ ~CaListOf()

virtual CaListOf::~CaListOf ( )
virtual

Destroys this CaListOf and the items inside it.

◆ CaListOf() [3/3]

CaListOf::CaListOf ( const CaListOf orig)

Copy constructor; creates a copy of this CaListOf.

Parameters
origthe CaListOf instance to copy.

Member Function Documentation

◆ append()

int CaListOf::append ( const CaBase item)

Adds an item to the end of this CaListOf's list of items.

This method makes a clone of the item handed to it. This means that when the CaListOf object is destroyed, the original items will not be destroyed. For a method with an alternative ownership behavior, see the CaListOf::appendAndOwn( ) method.

Parameters
itemthe item to be added to the list.
  • @omexconstant{LIBCOMBINE_OPERATION_SUCCESS, OperationReturnValues_t}
  • @omexconstant{LIBCOMBINE_INVALID_OBJECT, OperationReturnValues_t}
See also
appendAndOwn(CaBase* disownedItem)
appendFrom(const CaListOf* list)

◆ appendAndOwn()

int CaListOf::appendAndOwn ( CaBase disownedItem)

Adds an item to the end of this CaListOf's list of items.

This method does not clone the disownedItem handed to it; instead, it assumes ownership of it. This means that when the CaListOf is destroyed, the item will be destroyed along with it. For a method with an alternative ownership behavior, see the CaListOf::append(CaBase* item) method.

Parameters
disownedItemthe item to be added to the list.
  • @omexconstant{LIBCOMBINE_OPERATION_SUCCESS, OperationReturnValues_t}
  • @omexconstant{LIBCOMBINE_INVALID_OBJECT, OperationReturnValues_t}
See also
append(const CaBase* item)
appendFrom(const CaListOf* list)

◆ appendFrom()

virtual int CaListOf::appendFrom ( const CaListOf list)
virtual

Adds a clone of a list of items to this CaListOf's list.

Note that because this clones the objects handed to it, the original items will not be destroyed when this CaListOf object is destroyed.

Parameters
lista list of items to be added.
  • @omexconstant{LIBCOMBINE_OPERATION_SUCCESS, OperationReturnValues_t}
  • @omexconstant{LIBCOMBINE_INVALID_OBJECT, OperationReturnValues_t}
See also
append(const CaBase* item)
appendAndOwn(CaBase* disownedItem)

◆ clear()

void CaListOf::clear ( bool  doDelete = true)

Removes all items in this CaListOf object.

If parameter doDelete is true (default), all items in this CaListOf object are deleted and cleared, and thus the caller doesn't have to delete those items. Otherwise, all items are cleared only from this CaListOf object; the caller is still responsible for deleting the actual items. (In the latter case, callers are advised to store pointers to all items elsewhere before calling this function.)

Parameters
doDeleteif true (default), all items are deleted and cleared. Otherwise, all items are just cleared and not deleted.

◆ clone()

virtual CaListOf * CaListOf::clone ( ) const
virtual

Creates and returns a deep copy of this CaListOf object.

Returns
the (deep) copy of this CaListOf object.

Implements CaBase.

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ get() [1/2]

virtual CaBase * CaListOf::get ( unsigned int  n)
virtual

Get an item from the list.

Parameters
nthe index number of the item to get.
Returns
the nth item in this CaListOf items, or a null pointer if the index number n refers to a nonexistent position in this list.
See also
size()

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ get() [2/2]

virtual const CaBase * CaListOf::get ( unsigned int  n) const
virtual

Get an item from the list.

Parameters
nthe index number of the item to get.
Returns
the nth item in this CaListOf items, or a null pointer if the index number n refers to a nonexistent position in this list.
See also
size()

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ getAllElements()

virtual List * CaListOf::getAllElements ( )
virtual

Returns a List of all child CaBase objects.

The values returned include all children of the objects in this CaListOf list, nested to an arbitrary depth.

Returns
a List of pointers to all child objects.

Reimplemented from CaBase.

◆ getElementByMetaId()

virtual CaBase * CaListOf::getElementByMetaId ( const std::string &  metaid)
virtual

Returns the first child element found with the given meta-identifier.

Parameters
metaidstring representing the "metaid" attribute of the object to find.
Returns
the first element found with the given metaid, or NULL if no such object is found.

Reimplemented from CaBase.

◆ getElementBySId()

virtual CaBase * CaListOf::getElementBySId ( const std::string &  id)
virtual

Returns the first child element it can find with a specific "id" attribute value, or NULL if no such object is found.

Parameters
idstring representing the "id" attribute value of the object to find.
Returns
pointer to the first element found with the given identifier.

Reimplemented from CaBase.

◆ getElementName()

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

Returns the XML element name of this object, which for CaListOf, is always "listOf".

Returns
the XML name of this element.

Implements CaBase.

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ getItemTypeCode()

virtual int CaListOf::getItemTypeCode ( ) const
virtual

Get the type code of the objects contained in this CaListOf.

Classes that inherit from the CaListOf class should override this method to return the OMEX type code for the objects contained in this CaListOf. If they do not, this method will return @omexconstant{OMEX_UNKNOWN, CaTypeCode_t}

Returns
The CaListOf base class contains no OMEX objects, and therefore this method returns @omexconstant{OMEX_UNKNOWN, CaTypeCode_t}.
See also
getElementName()
getPackageName()

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ getTypeCode()

virtual int CaListOf::getTypeCode ( ) const
virtual

Returns the libCombine type code for this object, namely, @omexconstant{OMEX_LIST_OF, CaTypeCode_t}.

Returns
the OMEX type code for this object: @omexconstant{OMEX_LIST_OF, CaTypeCode_t} (default).
Note
The various CaListOf classes mostly differ from each other in what they contain. Hence, one must call getItemTypeCode() to fully determine the class of this OMEX object.
See also
getItemTypeCode()
getElementName()

Reimplemented from CaBase.

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ insert()

int CaListOf::insert ( int  location,
const CaBase item 
)

Inserts an item at a given position in this CaListOf's list of items.

This variant of the method makes a clone of the item handed to it. This means that when the CaListOf is destroyed, the original item will not be destroyed.

Parameters
locationthe location in the list where to insert the item.
itemthe item to be inserted to the list.
  • @omexconstant{LIBCOMBINE_OPERATION_SUCCESS, OperationReturnValues_t}
  • @omexconstant{LIBCOMBINE_INVALID_OBJECT, OperationReturnValues_t}
See also
insertAndOwn(int location, CaBase* item)

◆ insertAndOwn()

int CaListOf::insertAndOwn ( int  location,
CaBase disownedItem 
)

Inserts an item at a given position in this CaListOf's list of items.

This variant of the method does not make a clone of the disownedItem handed to it. This means that when the CaListOf is destroyed, the original item will be destroyed.

Parameters
locationthe location where to insert the item
disownedItemthe item to be inserted to the list
  • @omexconstant{LIBCOMBINE_OPERATION_SUCCESS, OperationReturnValues_t}
  • @omexconstant{LIBCOMBINE_INVALID_OBJECT, OperationReturnValues_t}
See also
insert(int location, const CaBase* item)

◆ operator=()

CaListOf & CaListOf::operator= ( const CaListOf rhs)

Assignment operator for CaListOf.

◆ remove()

virtual CaBase * CaListOf::remove ( unsigned int  n)
virtual

Removes the nth item from this CaListOf list of items and returns it.

The caller owns the returned item and is responsible for deleting it.

Parameters
nthe index of the item to remove
See also
size()

Reimplemented in CaListOfContents, and CaListOfCrossRefs.

◆ removeFromParentAndDelete()

virtual int CaListOf::removeFromParentAndDelete ( )
virtual

Removes all items in this CaListOf object and deletes its properties too.

This performs a call to clear() with an argument of true (thus removing all the child objects in the list), followed by calls to various libCombine unsetFoo methods to delete everything else: CVTerm objects, model history objects, etc.

  • @omexconstant{LIBCOMBINE_OPERATION_SUCCESS, OperationReturnValues_t}

Reimplemented from CaBase.

◆ size()

unsigned int CaListOf::size ( ) const

Returns number of items in this CaListOf list.

Returns
the number of items in this CaListOf items.