libSBML C++ API  5.20.4
ConversionProperties Class Reference

Detailed Description

Set of configuration option values for a converter.

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.

LibSBML provides a number of converters that can perform transformations on SBML documents. The properties of SBML converters are communicated using objects of class ConversionProperties, and within such objects, individual options are encapsulated using ConversionOption objects. The ConversionProperties class provides numerous methods for setting and getting options.

ConversionProperties objects are also used to determine the target SBML namespace when an SBML converter's behavior depends on the intended Level+Version combination of SBML. In addition, it is conceivable that conversions may be affected by SBML Level 3 packages being used by an SBML document; consequently, the packages in use are also communicated by the values of the SBML namespaces set on a ConversionProperties object.

General information about the use of SBML converters

The use of all the converters follows a similar approach. First, one creates a ConversionProperties object and calls ConversionProperties::addOption() on this object with one argument: a text string that identifies the desired converter. (The text string is specific to each converter; consult the documentation for a given converter to find out how it should be enabled.)

Next, for some converters, the caller can optionally set some converter-specific properties using additional calls to ConversionProperties::addOption(). Many converters provide the ability to configure their behavior to some extent; this is realized through the use of properties that offer different options. The default property values for each converter can be interrogated using the method SBMLConverter::getDefaultProperties() on the converter class in question .

Finally, the caller should invoke the method SBMLDocument::convert() with the ConversionProperties object as an argument.

Example of invoking an SBML converter

The following code fragment illustrates an example using SBMLReactionConverter, which is invoked using the option string "replaceReactions":

props.addOption("replaceReactions");
Definition: ConversionProperties.h:84
virtual void addOption(const ConversionOption &option)
Adds a copy of the given option to this properties object.
Definition: ConversionProperties.cpp:232

In the case of SBMLReactionConverter, there are no options to affect its behavior, so the next step is simply to invoke the converter on an SBMLDocument object. Continuing the example code:

// Assume that the variable "document" has been set to an SBMLDocument object.
int status = document->convert(props);
{
cerr << "Unable to perform conversion due to the following:" << endl;
document->printErrors(cerr);
}
@ LIBSBML_OPERATION_SUCCESS
Definition: operationReturnValues.h:61

Here is an example of using a converter that offers an option. The following code invokes SBMLStripPackageConverter to remove the SBML Level 3 Layout package from a model. It sets the name of the package to be removed by adding a value for the option named "package" defined by that converter:

props.addOption("stripPackage");
props.addOption("package", "layout");
int status = document->convert(props);
{
cerr << "Unable to strip the Layout package from the model";
cerr << "Error returned: " << status;
}

Available SBML converters in libSBML

LibSBML provides a number of built-in converters; by convention, their names end in Converter. The following are the built-in converters provided by libSBML 5.20.4 :

See also
ConversionOption
SBMLNamespaces
Examples
convertCobraToFbc.cpp, convertFbcToCobra.cpp, convertLayout.cpp, flattenModel.cpp, inlineFunctionDefintions.cpp, promoteParameters.cpp, and stripPackage.cpp.

Public Member Functions

virtual void addOption (const ConversionOption &option)
 Adds a copy of the given option to this properties object. More...
 
virtual void addOption (const std::string &key, bool value, const std::string description="")
 Adds a new ConversionOption object with the given parameters. More...
 
virtual void addOption (const std::string &key, const char *value, const std::string description="")
 Adds a new ConversionOption object with the given parameters. More...
 
virtual void addOption (const std::string &key, const std::string value="", ConversionOptionType_t type=CNV_TYPE_STRING, const std::string description="")
 Adds a new ConversionOption object with the given parameters. More...
 
virtual void addOption (const std::string &key, double value, const std::string description="")
 Adds a new ConversionOption object with the given parameters. More...
 
virtual void addOption (const std::string &key, float value, const std::string description="")
 Adds a new ConversionOption object with the given parameters. More...
 
virtual void addOption (const std::string &key, int value, const std::string description="")
 Adds a new ConversionOption object with the given parameters. More...
 
virtual ConversionPropertiesclone () const
 Creates and returns a deep copy of this ConversionProperties object. More...
 
 ConversionProperties (const ConversionProperties &orig)
 Copy constructor. More...
 
 ConversionProperties (SBMLNamespaces *targetNS=NULL)
 Constructor that initializes the conversion properties with a specific SBML target namespace. More...
 
virtual bool getBoolValue (const std::string &key) const
 Returns the value of the given option as a Boolean. More...
 
virtual const std::string & getDescription (const std::string &key) const
 Returns the description string for a given option in this properties object. More...
 
virtual double getDoubleValue (const std::string &key) const
 Returns the value of the given option as a double. More...
 
virtual float getFloatValue (const std::string &key) const
 Returns the value of the given option as a float. More...
 
virtual int getIntValue (const std::string &key) const
 Returns the value of the given option as an integer. More...
 
virtual int getNumOptions () const
 Returns the number of options in this Conversion Properties object. More...
 
virtual ConversionOptiongetOption (const std::string &key) const
 Returns the ConversionOption object for a given key. More...
 
virtual ConversionOptiongetOption (int index) const
 Returns the ConversionOption object for the given index. More...
 
virtual SBMLNamespacesgetTargetNamespaces () const
 Returns the current target SBML namespace. More...
 
virtual ConversionOptionType_t getType (const std::string &key) const
 Returns the type of a given option in this properties object. More...
 
virtual const std::string & getValue (const std::string &key) const
 Returns the value of the given option as a string. More...
 
virtual bool hasOption (const std::string &key) const
 Returns true if this properties object contains an option with the given key. More...
 
virtual bool hasTargetNamespaces () const
 Returns true if the target SBML namespace has been set. More...
 
ConversionPropertiesoperator= (const ConversionProperties &rhs)
 Assignment operator for conversion properties. More...
 
virtual ConversionOptionremoveOption (const std::string &key)
 Removes the option with the given key from this properties object. More...
 
virtual void setBoolValue (const std::string &key, bool value)
 Sets the value of the given option to a Boolean. More...
 
virtual void setDoubleValue (const std::string &key, double value)
 Sets the value of the given option to a double. More...
 
virtual void setFloatValue (const std::string &key, float value)
 Sets the value of the given option to a float. More...
 
virtual void setIntValue (const std::string &key, int value)
 Sets the value of the given option to an integer. More...
 
virtual void setTargetNamespaces (SBMLNamespaces *targetNS)
 Sets the target namespace. More...
 
virtual void setValue (const std::string &key, const std::string &value)
 Sets the value of the given option to a string. More...
 
virtual ~ConversionProperties ()
 Destructor. More...
 

Constructor & Destructor Documentation

◆ ConversionProperties() [1/2]

ConversionProperties::ConversionProperties ( SBMLNamespaces targetNS = NULL)

Constructor that initializes the conversion properties with a specific SBML target namespace.

Parameters
targetNSthe target namespace to convert to.

◆ ConversionProperties() [2/2]

ConversionProperties::ConversionProperties ( const ConversionProperties orig)

Copy constructor.

Parameters
origthe object to copy.

◆ ~ConversionProperties()

ConversionProperties::~ConversionProperties ( )
virtual

Destructor.

Member Function Documentation

◆ addOption() [1/7]

void ConversionProperties::addOption ( const ConversionOption option)
virtual

Adds a copy of the given option to this properties object.

Parameters
optionthe option to add.
Examples
convertCobraToFbc.cpp, convertFbcToCobra.cpp, convertLayout.cpp, flattenModel.cpp, inlineFunctionDefintions.cpp, promoteParameters.cpp, and stripPackage.cpp.

◆ addOption() [2/7]

void ConversionProperties::addOption ( const std::string &  key,
bool  value,
const std::string  description = "" 
)
virtual

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
valuethe boolean value of that option.
description(optional) the description for the option.

◆ addOption() [3/7]

void ConversionProperties::addOption ( const std::string &  key,
const char *  value,
const std::string  description = "" 
)
virtual

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
valuethe string value of that option.
description(optional) the description for the option.

◆ addOption() [4/7]

void ConversionProperties::addOption ( const std::string &  key,
const std::string  value = "",
ConversionOptionType_t  type = CNV_TYPE_STRING,
const std::string  description = "" 
)
virtual

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
value(optional) the value of that option.
type(optional) the type of the option (see the documentation for ConversionOption for more information about the types).
description(optional) the description for the option.

◆ addOption() [5/7]

void ConversionProperties::addOption ( const std::string &  key,
double  value,
const std::string  description = "" 
)
virtual

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
valuethe double value of that option.
description(optional) the description for the option.

◆ addOption() [6/7]

void ConversionProperties::addOption ( const std::string &  key,
float  value,
const std::string  description = "" 
)
virtual

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
valuethe float value of that option.
description(optional) the description for the option.

◆ addOption() [7/7]

void ConversionProperties::addOption ( const std::string &  key,
int  value,
const std::string  description = "" 
)
virtual

Adds a new ConversionOption object with the given parameters.

Parameters
keythe key for the new option.
valuethe integer value of that option.
description(optional) the description for the option.

◆ clone()

ConversionProperties * ConversionProperties::clone ( ) const
virtual

Creates and returns a deep copy of this ConversionProperties object.

Returns
the (deep) copy of this ConversionProperties object.

◆ getBoolValue()

bool ConversionProperties::getBoolValue ( const std::string &  key) const
virtual

Returns the value of the given option as a Boolean.

Parameters
keythe key for the option.
Returns
the boolean value of the option with the given key.

◆ getDescription()

const std::string & ConversionProperties::getDescription ( const std::string &  key) const
virtual

Returns the description string for a given option in this properties object.

Parameters
keythe key for the option.
Returns
the description text of the option with the given key.

◆ getDoubleValue()

double ConversionProperties::getDoubleValue ( const std::string &  key) const
virtual

Returns the value of the given option as a double.

Parameters
keythe key for the option.
Returns
the double value of the option with the given key.

◆ getFloatValue()

float ConversionProperties::getFloatValue ( const std::string &  key) const
virtual

Returns the value of the given option as a float.

Parameters
keythe key for the option.
Returns
the float value of the option with the given key.

◆ getIntValue()

int ConversionProperties::getIntValue ( const std::string &  key) const
virtual

Returns the value of the given option as an integer.

Parameters
keythe key for the option.
Returns
the int value of the option with the given key.

◆ getNumOptions()

int ConversionProperties::getNumOptions ( ) const
virtual

Returns the number of options in this Conversion Properties object.

Returns
the number of options in this properties object.

◆ getOption() [1/2]

ConversionOption * ConversionProperties::getOption ( const std::string &  key) const
virtual

Returns the ConversionOption object for a given key.

Parameters
keythe key for the option.
Returns
the option with the given key.

◆ getOption() [2/2]

ConversionOption * ConversionProperties::getOption ( int  index) const
virtual

Returns the ConversionOption object for the given index.

Parameters
indexthe index for the option.
Returns
the option with the given index.

◆ getTargetNamespaces()

SBMLNamespaces * ConversionProperties::getTargetNamespaces ( ) const
virtual

Returns the current target SBML namespace.

Returns
the SBMLNamepaces object expressing the target namespace.

◆ getType()

ConversionOptionType_t ConversionProperties::getType ( const std::string &  key) const
virtual

Returns the type of a given option in this properties object.

Parameters
keythe key for the option.
Returns
the type of the option with the given key.

◆ getValue()

const std::string & ConversionProperties::getValue ( const std::string &  key) const
virtual

Returns the value of the given option as a string.

Parameters
keythe key for the option.
Returns
the string value of the option with the given key.

◆ hasOption()

bool ConversionProperties::hasOption ( const std::string &  key) const
virtual

Returns true if this properties object contains an option with the given key.

Parameters
keythe key of the option to find.
Returns
true if an option with the given key exists in this properties object, false otherwise.

◆ hasTargetNamespaces()

bool ConversionProperties::hasTargetNamespaces ( ) const
virtual

Returns true if the target SBML namespace has been set.

Returns
true if the target namespace has been set, false otherwise.

◆ operator=()

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

Assignment operator for conversion properties.

Parameters
rhsthe object whose values are used as the basis of the assignment.

◆ removeOption()

ConversionOption * ConversionProperties::removeOption ( const std::string &  key)
virtual

Removes the option with the given key from this properties object.

Parameters
keythe key for the new option to remove.
Returns
the removed option.

◆ setBoolValue()

void ConversionProperties::setBoolValue ( const std::string &  key,
bool  value 
)
virtual

Sets the value of the given option to a Boolean.

Parameters
keythe key for the option.
valuethe new Boolean value.

◆ setDoubleValue()

void ConversionProperties::setDoubleValue ( const std::string &  key,
double  value 
)
virtual

Sets the value of the given option to a double.

Parameters
keythe key for the option.
valuethe new double value.

◆ setFloatValue()

void ConversionProperties::setFloatValue ( const std::string &  key,
float  value 
)
virtual

Sets the value of the given option to a float.

Parameters
keythe key for the option.
valuethe new float value.

◆ setIntValue()

void ConversionProperties::setIntValue ( const std::string &  key,
int  value 
)
virtual

Sets the value of the given option to an integer.

Parameters
keythe key for the option.
valuethe new integer value.

◆ setTargetNamespaces()

void ConversionProperties::setTargetNamespaces ( SBMLNamespaces targetNS)
virtual

Sets the target namespace.

Parameters
targetNSthe target namespace to use.

◆ setValue()

void ConversionProperties::setValue ( const std::string &  key,
const std::string &  value 
)
virtual

Sets the value of the given option to a string.

Parameters
keythe key for the option.
valuethe new value.