SBML.org — the global portal for all things SBML

New Attributes Type

In SBML attributes are drawn from the set of XML types {string; boolean; int; positiveInteger; double; ID} and a set of SBML specific derived types {SId, SIdRef, UnitSId, UnitSIdRef, SBOTerm}.

LibSBML uses types that reflect the closest C++ datatype and then imposes other sytax restrictions where appropriate. It names the variables to reflect the attribute. So classes that represent the SBML elements has member variables such as (for a Compartment)


  std::string   mId;
  std::string   mName;
  std::string   mCompartmentType;
  unsigned int  mSpatialDimensions;
  double        mSpatialDimensionsDouble;
  double        mSize;
  std::string   mUnits;
  std::string   mOutside;
  bool          mConstant;

However, experience has shown that it is useful and in some cases necessary to know more than just the name and value of the attribute. In fact, the Compartment class has an additional five variables that enable the code to keep track of whether a value has been set for the attribute and indeed whether that value was set explicitly by the user or taken as a default value from the relevant SBML specification.

  bool  mIsSetSize;
  bool  mIsSetSpatialDimensions;
  bool  mIsSetConstant;
  bool  mExplicitlySetSpatialDimensions;
  bool  mExplicitlySetConstant;

This introduces an inconsistency in that not all attributes have identical additional variables. You can determine if a string is set by querying to see whether it is empty; so you do not need an isSetString variable. It is impossible to know whether a boolean variable has been set by the user, because a boolean will always have a boolean value; so you need to record whether the user explicitly set the variable but you can tell a double variable is set if it is no longer NotANumber. Sarah quite likes the idea of a NotABoolean boolean type but recognises this may not translate easily to other languages Image:icon_smile.gif

So for an attribute X you cannot guarantee there will be a variable named isSetX or isExpliciltySetX and thus generic code that can be applied to any attribute is impossible to use.

It would be possible to create a new attribute type that could be applied to all attributes. This would be an STL container of some sort that kept all the necessary data associated with the variable.


attributeType = <'name', 'value', 'datatype', 'isSetBoolean', 'isExpliciltySet', 'L2defaultValue'>

mConstant = <'constant', 'true', 'boolean', 'true', 'false', 'true'>

mSize = <'size', '1.0', 'double', 'true', 'true', '1.0'>

isSet(mConstant) = true;
isSet(mSize) = true;

Again more thought and consultation will be forthcoming.

Retrieved from "http://sbml.org/SBML_Projects/libSBML/Development/New_Attributes_Type"

This page was last modified 08:46, 8 April 2014.



Please use our issue tracking system for any questions or suggestions about this website. This page was last modified 08:46, 8 April 2014.