libSBML C++ API  5.20.2
ElementFilter Class Reference

Detailed Description

Base class for filter functions.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. It is a class used in the implementation of extra functionality provided by libSBML.

Some libSBML objects provide the ability to return lists of components. To provide callers with greater control over exactly what is returned, these methods take optional arguments in the form of filters. The ElementFilter class is the parent class for these filters.

Examples
getAllElementsWithNotes.cpp.

Public Member Functions

 ElementFilter ()
 Creates a new ElementFilter object. More...
 
virtual bool filter (const SBase *element)
 Predicate to test elements. More...
 
void * getUserData ()
 Returns the user data that has been previously set via setUserData(). More...
 
void setUserData (void *userData)
 Sets the user data of this element. More...
 
virtual ~ElementFilter ()
 Destroys this ElementFilter. More...
 

Constructor & Destructor Documentation

◆ ElementFilter()

ElementFilter::ElementFilter ( )

Creates a new ElementFilter object.

◆ ~ElementFilter()

virtual ElementFilter::~ElementFilter ( )
virtual

Destroys this ElementFilter.

Member Function Documentation

◆ filter()

virtual bool ElementFilter::filter ( const SBase element)
virtual

Predicate to test elements.

This is the central predicate of the ElementFilter class. In subclasses of ElementFilter, callers should implement this method such that it returns true for element arguments that are "desirable" and false for those that are "undesirable" in whatever filtering context the ElementFilter subclass is designed to be used.

Parameters
elementthe element to be tested.
Returns
true if the element is desirable or should be kept, false otherwise.

◆ getUserData()

void* ElementFilter::getUserData ( )

Returns the user data that has been previously set via setUserData().

Callers can attach private data to ElementFilter objects using setUserData(). This user data can be used by an application to store custom information to be accessed by the ElementFilter in its work. In case of a deep copy, the data will passed as it is. The attribute will never be interpreted by libSBML.

Returns
the user data of this node, or NULL if no user data has been set.
Warning
This user data is specific to an ElementFilter object instance, and is not the same as the user data that may be attached to an SBML object using SBase::setUserData().
See also
setUserData()

◆ setUserData()

void ElementFilter::setUserData ( void *  userData)

Sets the user data of this element.

Callers can attach private data to ElementFilter objects using this method, and retrieve them using getUserData(). Such user data can be used by an application to store information to be accessed by the ElementFilter in its work. In case of a deep copy, this data will passed as it is. The attribute will never be interpreted by libSBML.

Parameters
userDataspecifies the new user data.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Warning
This user data is specific to an ElementFilter object instance, and is not the same as the user data that may be attached to an SBML object using SBase::setUserData().
See also
getUserData()