|
From: <sar...@us...> - 2014-09-23 08:51:39
|
Revision: 21152
http://sourceforge.net/p/sbml/code/21152
Author: sarahkeating
Date: 2014-09-23 08:51:23 +0000 (Tue, 23 Sep 2014)
Log Message:
-----------
Merged revision(s) 21137-21151 from trunk/libsbml:
Modified Paths:
--------------
branches/libsbml-experimental/examples/c++/comp/flattenModelAdvanced.cpp
branches/libsbml-experimental/src/sbml/Model.cpp
branches/libsbml-experimental/src/sbml/SBMLDocument.cpp
branches/libsbml-experimental/src/sbml/SBMLDocument.h
branches/libsbml-experimental/src/sbml/SBase.cpp
branches/libsbml-experimental/src/sbml/SBase.h
branches/libsbml-experimental/src/sbml/annotation/CVTerm.cpp
branches/libsbml-experimental/src/sbml/annotation/CVTerm.h
branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms.c
branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms_newSetters.c
branches/libsbml-experimental/src/sbml/annotation/test/TestL3ModelHistory.cpp
branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation.cpp
branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation2.cpp
branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationC.c
branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationMetaid.cpp
branches/libsbml-experimental/src/sbml/annotation/test/TestRunner.c
branches/libsbml-experimental/src/sbml/annotation/test/TestSyncAnnotation.cpp
branches/libsbml-experimental/src/sbml/annotation/test/TestValidation.cpp
branches/libsbml-experimental/src/sbml/extension/test/TestPackage.cpp
branches/libsbml-experimental/src/sbml/extension/test/TestPackage.h
branches/libsbml-experimental/src/sbml/extension/test/TestSBMLExtension.cpp
branches/libsbml-experimental/src/sbml/packages/comp/extension/CompModelPlugin.cpp
branches/libsbml-experimental/src/sbml/packages/comp/extension/CompSBMLDocumentPlugin.cpp
branches/libsbml-experimental/src/sbml/packages/comp/extension/test/TestExtensionObjects.cpp
branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestDeletion.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestExternalModelDefinition.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestModelDefinition.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestPort.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestReadWriteSBase.cpp
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestReplacedBy.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestReplacedElement.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestSBaseObjects.cpp
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestSBaseRef.c
branches/libsbml-experimental/src/sbml/packages/comp/sbml/test/TestSubmodel.c
branches/libsbml-experimental/src/sbml/packages/comp/util/SBMLResolverRegistry.cpp
branches/libsbml-experimental/src/sbml/packages/comp/util/SBMLResolverRegistry.h
branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestCompFlatteningConverter.cpp
branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestCompFlatteningUnknownPackageRefs.cpp
branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestURIResolvers.cpp
branches/libsbml-experimental/src/sbml/packages/comp/validator/CompValidator.cpp
branches/libsbml-experimental/src/sbml/packages/comp/validator/constraints/CompConsistencyConstraints.cpp
branches/libsbml-experimental/src/sbml/packages/comp/validator/constraints/ExtModelReferenceCycles.cpp
branches/libsbml-experimental/src/sbml/packages/comp/validator/constraints/SubmodelReferenceCycles.cpp
branches/libsbml-experimental/src/sbml/packages/comp/validator/constraints/UnitReplacementCheck.cpp
branches/libsbml-experimental/src/sbml/xml/XMLOutputStream.cpp
branches/libsbml-experimental/src/sbml/xml/test/TestCopyAndClone.cpp
branches/libsbml-experimental/src/sbml/xml/test/TestXMLAttributes.cpp
branches/libsbml-experimental/src/sbml/xml/test/TestXMLAttributesC.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLErrorLog.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLInputStream.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLNamespaces.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLNode.cpp
branches/libsbml-experimental/src/sbml/xml/test/TestXMLNode_newSetters.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLOutputStream.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLToken.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLToken_newSetters.c
branches/libsbml-experimental/src/sbml/xml/test/TestXMLTriple.c
Property Changed:
----------------
branches/libsbml-experimental/
branches/libsbml-experimental/examples/c++/
Index: branches/libsbml-experimental
===================================================================
--- branches/libsbml-experimental 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental 2014-09-23 08:51:23 UTC (rev 21152)
Property changes on: branches/libsbml-experimental
___________________________________________________________________
Modified: svn:mergeinfo
## -2,4 +2,4 ##
/branches/libsbml-4:9056-10118
/branches/libsbml-5-conversion:14155-14227
/branches/libsbml-ast-plugin:16251-19654
-/trunk/libsbml:18168-18171,18174-18194,18196-18201,18204,18207-18209,18211-18213,18215-18216,18226,18228-18292,18294-18388,18390-18443,18450-18454,18456-18458,18460-18462,18464,18466,18469-18520,18523-18561,18563,18565-18584,18586-18638,18640-18641,18644-18715,18717-18844,18846-19128,19130-19829,19831-21136
+/trunk/libsbml:18168-18171,18174-18194,18196-18201,18204,18207-18209,18211-18213,18215-18216,18226,18228-18292,18294-18388,18390-18443,18450-18454,18456-18458,18460-18462,18464,18466,18469-18520,18523-18561,18563,18565-18584,18586-18638,18640-18641,18644-18715,18717-18844,18846-19128,19130-19829,19831-21151
\ No newline at end of property
Index: branches/libsbml-experimental/examples/c++
===================================================================
--- branches/libsbml-experimental/examples/c++ 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/examples/c++ 2014-09-23 08:51:23 UTC (rev 21152)
Property changes on: branches/libsbml-experimental/examples/c++
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
/branches/L3Parser/examples/c++:15528-15625,15656-15673
/branches/libsbml-5-conversion/examples/c++:14155-14227
-/trunk/libsbml/examples/c++:2142-12017,18174-18194,18196-18201,18204,18207-18209,18211-18213,18215-18216,18226,18294-18310,18312-18353,18390-18443,18450-18454,18456-18458,18586-18638,18644-18715,18921-18944,18976-19112,19193-19195,19538-19551,19709-19749,19765-19793,19797-19821,19851-19866,19881-19905,19927-19949
+/trunk/libsbml/examples/c++:2142-12017,18174-18194,18196-18201,18204,18207-18209,18211-18213,18215-18216,18226,18294-18310,18312-18353,18390-18443,18450-18454,18456-18458,18586-18638,18644-18715,18921-18944,18976-19112,19193-19195,19538-19551,19709-19749,19765-19793,19797-19821,19851-19866,19881-19905,19927-19949,21137-21151
\ No newline at end of property
Modified: branches/libsbml-experimental/examples/c++/comp/flattenModelAdvanced.cpp
===================================================================
--- branches/libsbml-experimental/examples/c++/comp/flattenModelAdvanced.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/examples/c++/comp/flattenModelAdvanced.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -67,155 +67,151 @@
class CPrefixNameTransformer : public PrefixTransformer
{
public:
- CPrefixNameTransformer() {}
+ CPrefixNameTransformer() {}
- static void replaceStringInPlace(std::string& subject, const std::string& search,
- const std::string& replace)
- {
- size_t pos = 0;
+ static void replaceStringInPlace(std::string& subject, const std::string& search,
+ const std::string& replace)
+ {
+ size_t pos = 0;
- while ((pos = subject.find(search, pos)) != std::string::npos)
- {
- subject.replace(pos, search.length(), replace);
- pos += replace.length();
- }
- }
+ while ((pos = subject.find(search, pos)) != std::string::npos)
+ {
+ subject.replace(pos, search.length(), replace);
+ pos += replace.length();
+ }
+ }
- static inline std::string &rtrim(std::string &str)
- {
- size_t endpos = str.find_last_not_of(" \t");
+ static inline std::string &rtrim(std::string &str)
+ {
+ size_t endpos = str.find_last_not_of(" \t");
- if (string::npos != endpos)
- {
- str = str.substr(0, endpos + 1);
- }
+ if (string::npos != endpos)
+ {
+ str = str.substr(0, endpos + 1);
+ }
- return str;
- }
+ return str;
+ }
- const std::string& cleanName(std::string& prefix)
- {
- std::replace(prefix.begin(), prefix.end(), '_', ' ');
- replaceStringInPlace(prefix, " ", " ");
- rtrim(prefix);
- return prefix;
- }
+ const std::string& cleanName(std::string& prefix)
+ {
+ std::replace(prefix.begin(), prefix.end(), '_', ' ');
+ replaceStringInPlace(prefix, " ", " ");
+ rtrim(prefix);
+ return prefix;
+ }
- virtual int transform(SBase* element)
- {
- if (element == NULL || getPrefix().empty())
- return LIBSBML_OPERATION_SUCCESS;
+ virtual int transform(SBase* element)
+ {
+ if (element == NULL || getPrefix().empty())
+ return LIBSBML_OPERATION_SUCCESS;
- // set up ids
+ // set up ids
// this will rename the SIds and SIdRefs as
// the comp flattening routine does by default
- PrefixTransformer::transform(element);
+ PrefixTransformer::transform(element);
- // skip local parameters, as they are not renamed
- if (element->getTypeCode() == SBML_LOCAL_PARAMETER)
- return LIBSBML_OPERATION_SUCCESS;
+ // skip local parameters, as they are not renamed
+ if (element->getTypeCode() == SBML_LOCAL_PARAMETER)
+ return LIBSBML_OPERATION_SUCCESS;
- // setup names
+ // setup names
// here we want to rename the name attribute to also indicate if
// the element came from a subModel
- if (element->isSetName())
- {
- std::stringstream newName;
- std::string prefix = getPrefix();
- newName << element->getName() << " (" << cleanName(prefix) << ")";
- element->setName(newName.str());
- }
+ if (element->isSetName())
+ {
+ std::stringstream newName;
+ std::string prefix = getPrefix();
+ newName << element->getName() << " (" << cleanName(prefix) << ")";
+ element->setName(newName.str());
+ }
- return LIBSBML_OPERATION_SUCCESS;
- }
+ return LIBSBML_OPERATION_SUCCESS;
+ }
};
int main(int argc,char** argv)
{
- bool leavePorts = false;
- if (argc < 3)
- {
- cout << usage << endl;
- return 1;
- }
- else if (argc == 3)
- {
- if ( string("-p") == string(argv[1]) )
- {
- cout << usage << endl;
- return 1;
- }
- }
+ bool leavePorts = false;
+ if (argc < 3)
+ {
+ cout << usage << endl;
+ return 1;
+ }
+ else if (argc == 3)
+ {
+ if ( string("-p") == string(argv[1]) )
+ {
+ cout << usage << endl;
+ return 1;
+ }
+ }
- int argIndex = 1;
+ int argIndex = 1;
- if ( string("-p") == string(argv[1]) )
- {
- leavePorts = true;
- ++argIndex;
- }
+ if ( string("-p") == string(argv[1]) )
+ {
+ leavePorts = true;
+ ++argIndex;
+ }
- if (SBMLExtensionRegistry::isPackageEnabled("comp") == false)
- {
- cerr << "The version of libsbml being used does not have the comp"
- << " package code enabled" << endl;
- return 1;
- }
+ if (SBMLExtensionRegistry::isPackageEnabled("comp") == false)
+ {
+ cerr << "The version of libsbml being used does not have the comp"
+ << " package code enabled" << endl;
+ return 1;
+ }
- const char* inputFile = argv[argIndex];
- const char* outputFile = argv[argIndex+1];
+ const char* inputFile = argv[argIndex];
+ const char* outputFile = argv[argIndex+1];
- SBMLDocument* document = readSBML(inputFile);
+ SBMLDocument* document = readSBML(inputFile);
- if (document->getNumErrors() > 0)
- {
- cerr << "Encountered the following SBML errors:" << endl;
- document->printErrors(cerr);
- return 1;
- }
+ if (document->getNumErrors() > 0)
+ {
+ cerr << "Encountered the following SBML errors:" << endl;
+ document->printErrors(cerr);
+ return 1;
+ }
- // add the advanced prefix transformer to the comp plugin
+ // add the advanced prefix transformer to the comp plugin
// this transformer will be used during the flattening process
// to rename SIds and SIdRefs (as would happen by default)
// but allows the user to specify other changes that they
- // may wsh to be made (e.g. rename the name attribute)
- CompModelPlugin* mPlug = dynamic_cast<CompModelPlugin*>(document->getModel()->getPlugin("comp"));
- CPrefixNameTransformer trans;
+ // may wish to be made (e.g. rename the name attribute)
+ CompModelPlugin* mPlug = dynamic_cast<CompModelPlugin*>(document->getModel()->getPlugin("comp"));
+ CPrefixNameTransformer trans;
- if (mPlug != NULL)
- {
- mPlug->setTransformer(&trans);
- }
+ if (mPlug != NULL)
+ {
+ mPlug->setTransformer(&trans);
+ }
- ConversionProperties* props = new ConversionProperties();
+ ConversionProperties* props = new ConversionProperties();
- props->addOption("flatten comp");
- props->addOption("leavePorts", leavePorts);
+ props->addOption("flatten comp");
+ props->addOption("leavePorts", leavePorts);
- SBMLConverter* converter =
- SBMLConverterRegistry::getInstance().getConverterFor(*props);
+ SBMLConverter* converter =
+ SBMLConverterRegistry::getInstance().getConverterFor(*props);
- converter->setDocument(document);
+ converter->setDocument(document);
- int result = converter->convert();
+ // NOTE: after a call to convert, the comp model plugin pointer
+ // is no longer valid and has to be retrieved again.
+ int result = converter->convert();
- if (result != LIBSBML_OPERATION_SUCCESS)
- {
- cerr << "Conversion failed\n";
- document->printErrors();
- }
+ if (result != LIBSBML_OPERATION_SUCCESS)
+ {
+ cerr << "Conversion failed\n";
+ document->printErrors();
+ }
+
+ writeSBML(document, outputFile);
- // unset the transformer before it goes out of scope
- if (mPlug != NULL)
- {
- mPlug->setTransformer(NULL);
- }
+ delete converter;
+ delete document;
- writeSBML(document, outputFile);
-
- delete converter;
- delete document;
-
}
Modified: branches/libsbml-experimental/src/sbml/Model.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/Model.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/Model.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -4778,7 +4778,7 @@
Unit* uFromModel = getUnitDefinition("substance")->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -4823,7 +4823,7 @@
Unit* uFromModel = getUnitDefinition(substanceUnits)->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -4881,7 +4881,7 @@
Unit* uFromModel = getUnitDefinition("time")->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -4926,7 +4926,7 @@
Unit* uFromModel = getUnitDefinition(timeUnits)->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -4984,7 +4984,7 @@
Unit* uFromModel = getUnitDefinition("volume")->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -5029,7 +5029,7 @@
Unit* uFromModel = getUnitDefinition(volumeUnits)->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -5087,7 +5087,7 @@
Unit* uFromModel = getUnitDefinition("area")->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -5133,7 +5133,7 @@
Unit* uFromModel = getUnitDefinition(areaUnits)->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -5191,7 +5191,7 @@
Unit* uFromModel = getUnitDefinition("length")->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
@@ -5236,7 +5236,7 @@
Unit* uFromModel = getUnitDefinition(lengthUnits)->getUnit(n);
if (uFromModel != NULL)
{
- ud->addUnit(uFromModel->clone());
+ ud->addUnit(uFromModel);
}
}
}
Modified: branches/libsbml-experimental/src/sbml/SBMLDocument.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/SBMLDocument.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/SBMLDocument.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -353,6 +353,13 @@
}
+bool
+SBMLDocument::isSetModel() const
+{
+ return mModel != NULL;
+}
+
+
/*
* @return the Model contained in this SBMLDocument.
*/
@@ -1939,6 +1946,14 @@
LIBSBML_EXTERN
+int
+SBMLDocument_isSetModel(const SBMLDocument_t *d)
+{
+ return (d != NULL) ? (int)d->isSetModel() : 0;
+}
+
+
+LIBSBML_EXTERN
Model_t *
SBMLDocument_getModel (SBMLDocument_t *d)
{
Modified: branches/libsbml-experimental/src/sbml/SBMLDocument.h
===================================================================
--- branches/libsbml-experimental/src/sbml/SBMLDocument.h 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/SBMLDocument.h 2014-09-23 08:51:23 UTC (rev 21152)
@@ -464,7 +464,16 @@
virtual SBMLDocument* clone () const;
+
/**
+ * Returns @c true if the Model object has been set, otherwise
+ * returns @c false.
+ *
+ * @return @c true if the Model object has been set
+ */
+ bool isSetModel () const;
+
+ /**
* Returns the Model object stored in this SBMLDocument.
*
* It is important to note that this method <em>does not create</em> a
@@ -1728,6 +1737,22 @@
/**
+ * Predicate for testing whether the identifier of a given SBMLDocument_t
+ * structure is assigned.
+ *
+ * @param d the SBMLDocument_t structure
+ *
+ * @return nonzero if the model object of this SBMLDocument_t structure is
+ * set, zero (0) otherwise.
+ *
+ * @memberof SBMLDocument_t
+ */
+LIBSBML_EXTERN
+int
+SBMLDocument_isSetModel(const SBMLDocument_t *d);
+
+
+/**
* Returns the Model_t structure stored in this SBMLDocument_t structure.
*
* @param d the SBMLDocument_t structure
Modified: branches/libsbml-experimental/src/sbml/SBase.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/SBase.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/SBase.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -86,7 +86,7 @@
struct ClonePluginEntity : public unary_function<SBasePlugin*, SBasePlugin*>
{
SBasePlugin* operator() (SBasePlugin* sb) {
- if (!sb) return 0;
+ if (!sb) return NULL;
return sb->clone();
}
};
@@ -281,8 +281,9 @@
* Creates a new SBase object with the given level and version.
* Only subclasses may create SBase objects.
*/
-SBase::SBase (unsigned int level, unsigned int version) :
- mNotes ( NULL )
+SBase::SBase (unsigned int level, unsigned int version)
+ : mMetaId ("")
+ , mNotes(NULL)
, mAnnotation( NULL )
, mSBML ( NULL )
, mSBMLNamespaces (NULL)
@@ -324,8 +325,9 @@
* Creates a new SBase object with the given SBMLNamespaces.
* Only subclasses may create SBase objects.
*/
-SBase::SBase (SBMLNamespaces *sbmlns) :
- mNotes ( NULL )
+SBase::SBase (SBMLNamespaces *sbmlns)
+ : mMetaId("")
+ , mNotes(NULL)
, mAnnotation( NULL )
, mSBML ( NULL )
, mSBMLNamespaces (NULL)
@@ -482,6 +484,7 @@
mHasBeenDeleted = true;
for_each( mPlugins.begin(), mPlugins.end(), DeletePluginEntity() );
+ deleteDisabledPlugins(false);
}
/*
@@ -1473,7 +1476,9 @@
}
else
{
- success = setAnnotation(mAnnotation->clone());
+ XMLNode *copy = mAnnotation->clone();
+ success = setAnnotation(copy);
+ delete copy;
}
@@ -1652,9 +1657,10 @@
if(annt_xmln != NULL)
{
success = replaceTopLevelAnnotationElement(annt_xmln);
- delete annt_xmln;
}
+ delete annt_xmln;
+
return success;
}
@@ -3041,6 +3047,27 @@
return (int)mPlugins.size();
}
+unsigned int
+SBase::getNumDisabledPlugins() const
+{
+ return (int)mDisabledPlugins.size();
+}
+
+void
+SBase::deleteDisabledPlugins(bool recursive /*= true*/)
+{
+ for_each(mDisabledPlugins.begin(), mDisabledPlugins.end(), DeletePluginEntity());
+ mDisabledPlugins.clear();
+
+ if (recursive)
+ {
+ List* list = getAllElements();
+ for (unsigned int i = 0; i < list->getSize(); ++i)
+ ((SBase*)list->get(i))->deleteDisabledPlugins();
+ }
+
+}
+
int
SBase::disablePackage(const std::string& pkgURI, const std::string& prefix)
{
@@ -3163,27 +3190,51 @@
{
#if 0
cout << "[DEBUG] SBase::enablePackageInternal() (uri) " << pkgURI
- << " (prefix) " << pkgPrefix << " (element) " << getElementName() << endl;
+ << " (prefix) " << pkgPrefix << " (element) " << getElementName() << endl;
#endif
- mSBMLNamespaces->addNamespace(pkgURI,pkgPrefix);
+ mSBMLNamespaces->addNamespace(pkgURI, pkgPrefix);
}
//
- // enable the given package
+ // go through disabled plugins, and if we have one re-enable that one, rather
+ // than creating a new one
//
- const SBMLExtension* sbmlext = SBMLExtensionRegistry::getInstance().getExtensionInternal(pkgURI);
- if (sbmlext)
+ bool wasDisabled = false;
+ int numDisabledPlugins = (int)mDisabledPlugins.size();
+ for (int i = numDisabledPlugins - 1; i >= 0; --i)
{
- SBaseExtensionPoint extPoint(getPackageName(),getTypeCode());
- const SBasePluginCreatorBase* sbPluginCreator = sbmlext->getSBasePluginCreator(extPoint);
- if (sbPluginCreator)
+ SBasePlugin *current = mDisabledPlugins[i];
+ std::string uri = current->getURI();
+ if (pkgURI == uri)
{
- SBasePlugin* entity = sbPluginCreator->createPlugin(pkgURI,pkgPrefix,getNamespaces());
- entity->connectToParent(this);
- mPlugins.push_back(entity);
+ mDisabledPlugins.erase(mDisabledPlugins.begin() + i);
+ current->connectToParent(this);
+ mPlugins.push_back(current);
+ wasDisabled = true;
}
+ }
+
+ if (!wasDisabled)
+ {
+ //
+ // enable the given package
+ //
+ const SBMLExtension* sbmlext = SBMLExtensionRegistry::getInstance().getExtensionInternal(pkgURI);
+
+ if (sbmlext)
+ {
+ SBaseExtensionPoint extPoint(getPackageName(), getTypeCode());
+ const SBasePluginCreatorBase* sbPluginCreator = sbmlext->getSBasePluginCreator(extPoint);
+ if (sbPluginCreator)
+ {
+ SBasePlugin* entity = sbPluginCreator->createPlugin(pkgURI, pkgPrefix, getNamespaces());
+ entity->connectToParent(this);
+ mPlugins.push_back(entity);
+ }
+ }
+
}
/* check whether we are trying to reenable an unknown package
* that we previously disabled
@@ -3221,12 +3272,15 @@
//
// disable the given package
//
- for (size_t i=0; i < mPlugins.size(); i++)
+ int numPlugins = (int)mPlugins.size();
+ for (int i=numPlugins-1; i >= 0; --i)
{
- std::string uri = mPlugins[i]->getURI();
+ SBasePlugin *current = mPlugins[i];
+ std::string uri = current->getURI();
if (pkgURI == uri)
- {
+ {
mPlugins.erase( mPlugins.begin() + i );
+ mDisabledPlugins.push_back(current);
}
}
Modified: branches/libsbml-experimental/src/sbml/SBase.h
===================================================================
--- branches/libsbml-experimental/src/sbml/SBase.h 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/SBase.h 2014-09-23 08:51:23 UTC (rev 21152)
@@ -2672,6 +2672,28 @@
/**
+ * Returns the number of disabled plug-in objects (extenstion interfaces)
+ * for SBML Level 3 package extensions known.
+ *
+ * @copydetails doc_what_are_plugins
+ *
+ * @return the number of disabled plug-in objects (extension interfaces)
+ * of package extensions known by this instance of libSBML.
+ *
+ */
+ unsigned int getNumDisabledPlugins() const;
+
+ /**
+ * Deletes all information stored in disabled plugins.
+ *
+ * @param recursive if @c true, the disabled information will be deleted
+ * also from all child elements, otherwise only from this SBase element.
+ *
+ * @see getNumDisabledPlugins()
+ */
+ void deleteDisabledPlugins(bool recursive=true);
+
+ /**
* Enables or disables the given SBML Level 3 package on this object.
*
* This method enables the specified package on this object and other
@@ -3644,7 +3666,13 @@
//
std::vector<SBasePlugin*> mPlugins;
+ //
+ // In case an SBasePlugin is disabled, we still store it here in case it
+ // will be re-enabled later on.
+ //
+ std::vector<SBasePlugin*> mDisabledPlugins;
+
//
// namespace to which this SBase object belongs.
// This variable can be publicly accessible by getElementNamespace function.
Modified: branches/libsbml-experimental/src/sbml/annotation/CVTerm.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/CVTerm.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/CVTerm.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -287,6 +287,13 @@
}
+QualifierType_t
+CVTerm::getQualifierType() const
+{
+ return mQualifier;
+}
+
+
/*
* gets the Model Qualifier type
*/
@@ -297,6 +304,13 @@
}
+ModelQualifierType_t
+CVTerm::getModelQualifierType() const
+{
+ return mModelQualifier;
+}
+
+
/*
* gets the biological Qualifier type
*/
@@ -307,6 +321,13 @@
}
+BiolQualifierType_t
+CVTerm::getBiologicalQualifierType() const
+{
+ return mBiolQualifier;
+}
+
+
/*
* gets the resources
*/
@@ -336,6 +357,13 @@
}
+unsigned int
+CVTerm::getNumResources() const
+{
+ return mResources->getLength();
+}
+
+
/*
* Returns the value of the nth resource for this %CVTerm.
*/
@@ -347,6 +375,16 @@
/*
+ * Returns the value of the nth resource for this %CVTerm.
+ */
+std::string
+CVTerm::getResourceURI(unsigned int n) const
+{
+ return mResources->getValue(n);
+}
+
+
+/*
* adds a resource to the term
*/
int
@@ -433,6 +471,41 @@
return valid;
}
+bool
+CVTerm::hasRequiredAttributes() const
+{
+ bool valid = true;
+
+ if (getQualifierType() == UNKNOWN_QUALIFIER)
+ {
+ valid = false;
+ }
+ else if (getQualifierType() == MODEL_QUALIFIER)
+ {
+ if (getModelQualifierType() == BQM_UNKNOWN)
+ {
+ valid = false;
+ }
+ }
+ else
+ {
+ if (getBiologicalQualifierType() == BQB_UNKNOWN)
+ {
+ valid = false;
+ }
+ }
+
+ if (valid)
+ {
+ if (getResources()->isEmpty())
+ {
+ valid = false;
+ }
+ }
+
+ return valid;
+}
+
bool
CVTerm::hasBeenModified()
{
Modified: branches/libsbml-experimental/src/sbml/annotation/CVTerm.h
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/CVTerm.h 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/CVTerm.h 2014-09-23 08:51:23 UTC (rev 21152)
@@ -525,7 +525,12 @@
*/
QualifierType_t getQualifierType();
+ /** @cond doxygenLibsbmlInternal */
+ QualifierType_t getQualifierType() const;
+
+ /** @endcond */
+
/**
* Returns the model qualifier type of this CVTerm object.
*
@@ -567,6 +572,12 @@
ModelQualifierType_t getModelQualifierType();
+ /** @cond doxygenLibsbmlInternal */
+
+ ModelQualifierType_t getModelQualifierType() const;
+
+ /** @endcond */
+
/**
* Returns the biological qualifier type of this CVTerm object.
*
@@ -617,6 +628,12 @@
BiolQualifierType_t getBiologicalQualifierType();
+ /** @cond doxygenLibsbmlInternal */
+
+ BiolQualifierType_t getBiologicalQualifierType() const;
+
+ /** @endcond */
+
/**
* Returns the resource references for this CVTerm object.
*
@@ -687,6 +704,27 @@
*/
unsigned int getNumResources();
+
+ /**
+ * Returns the number of resources for this CVTerm object.
+ *
+ * @copydetails doc_cvterm_common_description
+ *
+ * The fragment above illustrates that there can be more than one
+ * resource referenced by a given relationship annotation (i.e., the
+ * <span class="code" style="background-color: #d0d0ee">resource
+ * URI</span> values associated with a particular <span class="code"
+ * style="background-color: #bbb">RELATION_ELEMENT</span>). The present
+ * method returns a count of the resources stored in this CVTerm object.
+ *
+ * @return the number of resources in the set of XMLAttributes
+ * of this CVTerm.
+ *
+ * @see getResources()
+ * @see getResourceURI(unsigned int n)
+ */
+ unsigned int getNumResources() const;
+
/**
* Returns the value of the <em>n</em>th resource for this CVTerm object.
@@ -715,6 +753,32 @@
/**
+ * Returns the value of the <em>n</em>th resource for this CVTerm object.
+ *
+ * @copydetails doc_cvterm_common_description
+ *
+ * The fragment above illustrates that there can be more than one
+ * resource referenced by a given relationship annotation (i.e., the
+ * <span class="code" style="background-color: #d0d0ee">resource
+ * URI</span> values associated with a particular <span class="code"
+ * style="background-color: #bbb">RELATION_ELEMENT</span>). LibSBML
+ * stores all resource URIs in a single CVTerm object for a given
+ * relationship. Callers can use getNumResources() to find out how many
+ * resources are stored in this CVTerm object, then call this method to
+ * retrieve the <em>n</em>th resource URI.
+ *
+ * @param n the index of the resource to query
+ *
+ * @return string representing the value of the nth resource
+ * in the set of XMLAttributes of this CVTerm.
+ *
+ * @see getNumResources()
+ * @see getQualifierType()
+ */
+ std::string getResourceURI(unsigned int n) const;
+
+
+ /**
* Sets the @if clike #QualifierType_t@else qualifier code@endif@~ of this
* CVTerm object.
*
@@ -923,6 +987,7 @@
void resetModifiedFlags();
+ bool hasRequiredAttributes() const;
/** @endcond */
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms.c
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms.c 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms.c 2014-09-23 08:51:23 UTC (rev 21152)
@@ -118,7 +118,6 @@
XMLNode_addChild(bag, li);
XMLNode_addChild(node, bag);
-
CVTerm_t *term = CVTerm_createFromNode(node);
fail_unless(term != NULL);
@@ -128,9 +127,16 @@
xa = CVTerm_getResources(term);
fail_unless(XMLAttributes_getLength(xa) == 1);
- fail_unless(!strcmp(XMLAttributes_getName(xa, 0), "rdf:resource"));
- fail_unless(!strcmp(XMLAttributes_getValue(xa, 0), "This is my resource"));
+
+ char * name = XMLAttributes_getName(xa, 0);
+ char * value = XMLAttributes_getValue(xa, 0);
+
+ fail_unless(!strcmp(name, "rdf:resource"));
+ fail_unless(!strcmp(value, "This is my resource"));
+ free(name);
+ free(value);
+
XMLTriple_free(qual_triple);
XMLTriple_free(bag_triple);
XMLTriple_free(li_triple);
@@ -143,8 +149,6 @@
XMLNode_free(node);
XMLNode_free(bag);
XMLNode_free(li);
-
-
}
END_TEST
@@ -162,13 +166,17 @@
xa = CVTerm_getResources(term);
fail_unless(XMLAttributes_getLength(xa) == 1);
- fail_unless(!strcmp(XMLAttributes_getName(xa, 0), "rdf:resource"));
- fail_unless(!strcmp(XMLAttributes_getValue(xa, 0), "GO6666"));
+ char * name = XMLAttributes_getName(xa, 0);
+ char * value = XMLAttributes_getValue(xa, 0);
+
+ fail_unless(!strcmp(name, "rdf:resource"));
+ fail_unless(!strcmp(value, "GO6666"));
+ free(name);
+ free(value);
CVTerm_free(term);
-
}
END_TEST
@@ -186,13 +194,17 @@
number = CVTerm_getNumResources(term);
fail_unless(number == 2);
- fail_unless(!strcmp(CVTerm_getResourceURI(term, 0), "GO6666"));
- fail_unless(!strcmp(CVTerm_getResourceURI(term, 1), "OtherURI"));
+ char * res1 = CVTerm_getResourceURI(term, 0);
+ char * res2 = CVTerm_getResourceURI(term, 1);
+ fail_unless(!strcmp(res1, "GO6666"));
+ fail_unless(!strcmp(res2, "OtherURI"));
+
+ free(res1);
+ free(res2);
CVTerm_free(term);
-
}
END_TEST
@@ -221,13 +233,11 @@
fail_unless (ModelQualifierType_fromString(NULL) == BQM_UNKNOWN);
fail_unless (BiolQualifierType_fromString(NULL) == BQB_UNKNOWN);
-
}
END_TEST
START_TEST (test_CVTerm_get_biol_qualifiers)
{
-
fail_unless (BiolQualifierType_fromString("is") == BQB_IS);
fail_unless (BiolQualifierType_fromString("hasPart") == BQB_HAS_PART);
fail_unless (BiolQualifierType_fromString("isPartOf") == BQB_IS_PART_OF);
@@ -256,7 +266,6 @@
fail_unless (strcmp(BiolQualifierType_toString(BQB_HAS_PROPERTY), "hasProperty") == 0);
fail_unless (strcmp(BiolQualifierType_toString(BQB_IS_PROPERTY_OF), "isPropertyOf") == 0);
fail_unless (BiolQualifierType_toString(BQB_UNKNOWN) == NULL);
-
}
END_TEST
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms_newSetters.c
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms_newSetters.c 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestCVTerms_newSetters.c 2014-09-23 08:51:23 UTC (rev 21152)
@@ -137,9 +137,16 @@
xa = CVTerm_getResources(term);
fail_unless(XMLAttributes_getLength(xa) == 1);
- fail_unless(!strcmp(XMLAttributes_getName(xa, 0), "rdf:resource"));
- fail_unless(!strcmp(XMLAttributes_getValue(xa, 0), "GO6666"));
+
+ char * name = XMLAttributes_getName(xa, 0);
+ char * value = XMLAttributes_getValue(xa, 0);
+
+ fail_unless(!strcmp(name, "rdf:resource"));
+ fail_unless(!strcmp(value, "GO6666"));
+ free(name);
+ free(value);
+
CVTerm_free(term);
}
END_TEST
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestL3ModelHistory.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestL3ModelHistory.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestL3ModelHistory.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -69,6 +69,8 @@
d = readSBML(filename);
m = d->getModel();
c = m->getCompartment(0);
+
+ delete filename;
}
@@ -255,6 +257,7 @@
fail_unless( equals(expected, n1->toXMLString().c_str()) );
delete node;
+ delete n1;
}
END_TEST
@@ -418,9 +421,11 @@
" </annotation>\n"
"</compartment>";
+ char * sbml = c->toSBML();
- fail_unless( equals(expected, c->toSBML()) );
+ fail_unless( equals(expected, sbml) );
+ delete sbml;
}
END_TEST
@@ -657,18 +662,22 @@
L3ModelHistory_setup,
L3ModelHistory_teardown);
+ // libxml leaks these but expat does not
tcase_add_test(tcase, test_L3ModelHistory_getModelHistory );
tcase_add_test(tcase, test_L3ModelHistory_parseModelHistory );
- tcase_add_test(tcase, test_L3ModelHistory_delete );
- tcase_add_test(tcase, test_L3ModelHistory_deleteWithOther );
-// tcase_add_test(tcase, test_L3ModelHistory_recreate );
-// tcase_add_test(tcase, test_L3ModelHistory_recreateFromEmpty );
tcase_add_test(tcase, test_L3ModelHistory_deleteWithOutOther );
tcase_add_test(tcase, test_L3ModelHistory_recreateWithOutOther );
tcase_add_test(tcase, test_L3ModelHistory_getModelHistory_Model );
tcase_add_test(tcase, test_L3ModelHistory_parseModelHistory_Model );
+
+ // // memory leaks unresolved
+ // leaks XMLNodes removeChild
+ tcase_add_test(tcase, test_L3ModelHistory_delete );
+ tcase_add_test(tcase, test_L3ModelHistory_deleteWithOther );
tcase_add_test(tcase, test_L3ModelHistory_delete_Model );
-// tcase_add_test(tcase, test_L3ModelHistory_recreateFromEmpty_Model );
+
+
+
suite_add_tcase(suite, tcase);
return suite;
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -69,6 +69,8 @@
// The following will return a pointer to a new SBMLDocument.
d = readSBML(filename);
m = d->getModel();
+
+ free(filename);
}
@@ -519,11 +521,12 @@
// unset metaid ... now we have potentially dangling RDF
model->setMetaId("");
- std::string test = model->toSBML();
+ char * test = model->toSBML();
// this should be the test
- fail_unless(test == "<model id=\"test1\"/>");
+ fail_unless(!strcmp(test, "<model id=\"test1\"/>"));
+ free(test);
}
END_TEST
@@ -633,11 +636,13 @@
// unset metaid ... now we have potentially dangling RDF
model->setMetaId("");
- std::string test = model->toSBML();
+ char * test = model->toSBML();
// this should be the test
- fail_unless(test == "<model id=\"test1\"/>");
+ fail_unless(!strcmp(test, "<model id=\"test1\"/>"));
+ free(test);
+
}
END_TEST
@@ -2060,16 +2065,9 @@
tcase_add_test(tcase, test_invalid_user_annotation );
tcase_add_test(tcase, test_RDFAnnotation_getModelHistory );
tcase_add_test(tcase, test_RDFAnnotation_parseModelHistory );
- tcase_add_test(tcase, test_RDFAnnotation_parseCVTerms );
- tcase_add_test(tcase, test_RDFAnnotation_delete );
- tcase_add_test(tcase, test_RDFAnnotation_deleteWithOther );
-// tcase_add_test(tcase, test_RDFAnnotation_recreate );
-// tcase_add_test(tcase, test_RDFAnnotation_recreateFromEmpty );
tcase_add_test(tcase, test_RDFAnnotation_deleteWithOutOther );
tcase_add_test(tcase, test_RDFAnnotation_deleteWithOtherRDF );
-// tcase_add_test(tcase, test_RDFAnnotation_recreateWithOutOther );
tcase_add_test(tcase, test_RDFAnnotation_testMissingMetaId );
- tcase_add_test(tcase, test_RDFAnnotation_testMissingAbout );
tcase_add_test(tcase, test_RDFAnnotation_testAnnotationForMetaId );
tcase_add_test(tcase, test_RDFAnnotation_testHasRDFAnnotation );
tcase_add_test(tcase, test_RDFAnnotation_testHasAdditionalRDFAnnotation );
@@ -2078,13 +2076,21 @@
tcase_add_test(tcase, test_RDFAnnotation_testHasCVTermRDFAnnotationBadAbout );
tcase_add_test(tcase, test_RDFAnnotation_testHasHistoryRDFAnnotationBadAbout );
tcase_add_test(tcase, test_RDFAnnotation_testCreateAnnotations );
- tcase_add_test(tcase, test_RDFAnnotation_deleteCVTerms );
tcase_add_test(tcase, test_RDFAnnotation_removeSingleAnnotation );
tcase_add_test(tcase, test_RDFAnnotation_removeSingleAnnotation1 );
tcase_add_test(tcase, test_RDFAnnotation_removeAnnotation );
+
+ // // memory leaks unresolved
+ tcase_add_test(tcase, test_RDFAnnotation_parseCVTerms );
+ tcase_add_test(tcase, test_RDFAnnotation_delete );
+ tcase_add_test(tcase, test_RDFAnnotation_deleteWithOther );
+ tcase_add_test(tcase, test_RDFAnnotation_testMissingAbout );
+ tcase_add_test(tcase, test_RDFAnnotation_deleteCVTerms );
tcase_add_test(tcase, test_RDFAnnotation_replaceAnnotation );
tcase_add_test(tcase, test_RDFAnnotation_replaceAnnotation1 );
tcase_add_test(tcase, test_RDFAnnotation_replaceAnnotation2 );
+
+
suite_add_tcase(suite, tcase);
return suite;
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation2.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation2.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotation2.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -66,6 +66,8 @@
// The following will return a pointer to a new SBMLDocument.
d2 = readSBML(filename);
m2 = d2->getModel();
+
+ free(filename);
}
@@ -325,9 +327,12 @@
RDFAnnotation2_teardown);
tcase_add_test(tcase, test_RDFAnnotation2_getModelHistory );
+
+ // // memory leaks unresolved
tcase_add_test(tcase, test_RDFAnnotation2_modelWithHistoryAndCVTerms );
tcase_add_test(tcase, test_RDFAnnotation2_modelWithHistoryAndMultipleModifiedDates );
tcase_add_test(tcase, test_RDFAnnotation2_modelWithHistoryWithCharacterReference);
+
suite_add_tcase(suite, tcase);
return suite;
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationC.c
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationC.c 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationC.c 2014-09-23 08:51:23 UTC (rev 21152)
@@ -67,6 +67,8 @@
// The following will return a pointer to a new SBMLDocument.
d = readSBML(filename);
m = SBMLDocument_getModel(d);
+
+ free(filename);
}
@@ -329,8 +331,11 @@
tcase_add_test(tcase, test_RDFAnnotation_C_getModelHistory );
tcase_add_test(tcase, test_RDFAnnotation_C_parseModelHistory );
tcase_add_test(tcase, test_RDFAnnotation_C_parseCVTerms );
+ tcase_add_test(tcase, test_RDFAnnotation_C_accessWithNULL );
+
+ // // memory leaks unresolved
tcase_add_test(tcase, test_RDFAnnotation_C_delete );
- tcase_add_test(tcase, test_RDFAnnotation_C_accessWithNULL );
+
suite_add_tcase(suite, tcase);
return suite;
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationMetaid.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationMetaid.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestRDFAnnotationMetaid.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -69,6 +69,8 @@
// The following will return a pointer to a new SBMLDocument.
d = readSBML(filename);
m = d->getModel();
+
+ free(filename);
}
@@ -263,6 +265,7 @@
RDFAnnotationMetaid_setup,
RDFAnnotationMetaid_teardown);
+ // // memory leaks unresolved
tcase_add_test(tcase, test_RDFAnnotationMetaid_setAnnotation1 );
tcase_add_test(tcase, test_RDFAnnotationMetaid_setAnnotation2 );
tcase_add_test(tcase, test_RDFAnnotationMetaid_setAnnotation3 );
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestRunner.c
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestRunner.c 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestRunner.c 2014-09-23 08:51:23 UTC (rev 21152)
@@ -83,7 +83,7 @@
setTestDataDirectory (void)
{
char *srcdir = getenv("srcdir");
- int length = (srcdir == NULL) ? 0 : strlen(srcdir);
+ size_t length = (srcdir == NULL) ? 0 : strlen(srcdir);
/**
@@ -133,6 +133,8 @@
srunner_free(runner);
+ free(TestDataDirectory);
+
return num_failed;
}
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestSyncAnnotation.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestSyncAnnotation.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestSyncAnnotation.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -69,6 +69,8 @@
// The following will return a pointer to a new SBMLDocument.
d = readSBML(filename);
m = d->getModel();
+
+ free(filename);
}
@@ -141,8 +143,11 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -342,8 +347,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -453,8 +462,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -497,8 +510,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -525,8 +542,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -638,8 +659,12 @@
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -667,8 +692,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -715,8 +744,12 @@
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
c->unsetModelHistory();
c->addCVTerm(cv);
const char * expected1 =
@@ -735,8 +768,12 @@
"</compartment>";
- fail_unless( equals(expected1, c->toSBML()) );
+ sbml = c->toSBML();
+ fail_unless( equals(expected1, sbml) );
+
+ free(sbml);
+
c->setModelHistory(mh);
c->unsetCVTerms();
c->addCVTerm(cv);
@@ -777,8 +814,12 @@
"</compartment>";
- fail_unless( equals(expected2, c->toSBML()) );
+ sbml = c->toSBML();
+ fail_unless( equals(expected2, sbml) );
+
+ free(sbml);
+
}
END_TEST
@@ -810,8 +851,11 @@
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -862,8 +906,11 @@
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -895,8 +942,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
+
c->setModelHistory(mh);
c->addCVTerm(cv);
c->unsetCVTerms();
@@ -941,8 +992,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected1, c->toSBML()) );
+ sbml = c->toSBML();
+ fail_unless( equals(expected1, sbml) );
+
+ free(sbml);
+
c->unsetModelHistory();
c->unsetCVTerms();
c->addCVTerm(cv);
@@ -972,8 +1027,12 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected2, c->toSBML()) );
+ sbml = c->toSBML();
+ fail_unless( equals(expected2, sbml) );
+
+ free(sbml);
+
c->unsetModelHistory();
c->unsetCVTerms();
c->addCVTerm(cv);
@@ -1024,7 +1083,11 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected3, c->toSBML()) );
+ sbml = c->toSBML();
+
+ fail_unless( equals(expected3, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -1107,7 +1170,11 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -1188,7 +1255,11 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -1269,7 +1340,11 @@
" </annotation>\n"
"</model>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -1310,7 +1385,11 @@
" </annotation>\n"
"</compartment>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -1391,7 +1470,11 @@
" </annotation>\n"
"</model>";
- fail_unless( equals(expected, c->toSBML()) );
+ char * sbml = c->toSBML();
+
+ fail_unless( equals(expected, sbml) );
+
+ free(sbml);
}
END_TEST
@@ -1408,6 +1491,9 @@
tcase_add_test(tcase, test_SyncAnnotation_noChanges_1 );
tcase_add_test(tcase, test_SyncAnnotation_noChanges_2 );
+
+ // // memory leaks unresolved
+
tcase_add_test(tcase, test_SyncAnnotation_deleteModelOnly );
tcase_add_test(tcase, test_SyncAnnotation_deleteModelOnly_1 );
tcase_add_test(tcase, test_SyncAnnotation_deleteCVTerms );
Modified: branches/libsbml-experimental/src/sbml/annotation/test/TestValidation.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/annotation/test/TestValidation.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/annotation/test/TestValidation.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -147,6 +147,8 @@
fail_unless (mh->hasRequiredAttributes());
delete mh;
+ delete mc;
+ delete date;
}
END_TEST
@@ -176,6 +178,8 @@
fail_unless (!(mh->hasRequiredAttributes()));
delete mh;
+ delete mc;
+ delete date;
}
END_TEST
@@ -204,6 +208,8 @@
fail_unless (!(mh->hasRequiredAttributes()));
delete mh;
+ delete mc;
+ delete date;
}
END_TEST
Modified: branches/libsbml-experimental/src/sbml/extension/test/TestPackage.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/extension/test/TestPackage.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/extension/test/TestPackage.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -226,11 +226,13 @@
const std::string &prefix,
TestPkgNamespaces *groupsns)
: SBasePlugin(uri,prefix, groupsns)
+ , mValue()
{
}
TestModelPlugin::TestModelPlugin(const TestModelPlugin& orig)
: SBasePlugin(orig)
+ , mValue(orig.mValue)
{
}
@@ -241,6 +243,7 @@
{
if(&orig!=this)
{
+ this->mValue = orig.mValue;
this->SBasePlugin::operator =(orig);
}
return *this;
@@ -252,6 +255,18 @@
return new TestModelPlugin(*this);
}
+const std::string&
+TestModelPlugin::getValue() const
+{
+ return mValue;
+}
+void
+TestModelPlugin::setValue(const std::string& value)
+{
+ mValue = value;
+}
+
+
SBase*
TestModelPlugin::createObject(XMLInputStream& stream)
{
Modified: branches/libsbml-experimental/src/sbml/extension/test/TestPackage.h
===================================================================
--- branches/libsbml-experimental/src/sbml/extension/test/TestPackage.h 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/extension/test/TestPackage.h 2014-09-23 08:51:23 UTC (rev 21152)
@@ -95,23 +95,26 @@
class TestModelPlugin : public SBasePlugin
{
public:
+ TestModelPlugin(const std::string &uri, const std::string &prefix,
+ TestPkgNamespaces *groupsns);
+ TestModelPlugin(const TestModelPlugin& orig);
+ virtual ~TestModelPlugin();
+ TestModelPlugin& operator=(const TestModelPlugin& orig);
+ virtual TestModelPlugin* clone() const;
+ virtual SBase* createObject(XMLInputStream& stream);
+ virtual void writeElements(XMLOutputStream& stream) const;
+ virtual bool hasRequiredElements() const;
- TestModelPlugin (const std::string &uri, const std::string &prefix,
- TestPkgNamespaces *groupsns);
- TestModelPlugin(const TestModelPlugin& orig);
- virtual ~TestModelPlugin ();
- TestModelPlugin& operator=(const TestModelPlugin& orig);
- virtual TestModelPlugin* clone () const;
- virtual SBase* createObject (XMLInputStream& stream);
- virtual void writeElements (XMLOutputStream& stream) const;
- virtual bool hasRequiredElements() const ;
+ virtual void setSBMLDocument(SBMLDocument* d);
+ virtual void connectToParent(SBase *sbase);
- virtual void setSBMLDocument (SBMLDocument* d);
- virtual void connectToParent (SBase *sbase);
+ virtual void enablePackageInternal(const std::string& pkgURI,
+ const std::string& pkgPrefix, bool flag);
+ const std::string& getValue() const;
+ void setValue(const std::string& value);
- virtual void enablePackageInternal(const std::string& pkgURI,
- const std::string& pkgPrefix, bool flag);
-
+protected:
+ std::string mValue;
};
LIBSBML_CPP_NAMESPACE_END
#endif //__cplusplus
Modified: branches/libsbml-experimental/src/sbml/extension/test/TestSBMLExtension.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/extension/test/TestSBMLExtension.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/extension/test/TestSBMLExtension.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -136,7 +136,45 @@
}
END_TEST
+START_TEST(test_SBMLExtension_reenable)
+{
+ TestPkgNamespaces ns(3, 1, 1);
+ SBMLDocument doc(&ns);
+ Model* model = doc.createModel();
+ TestModelPlugin* mPlugin = dynamic_cast<TestModelPlugin*>( model->getPlugin("test") );
+ fail_unless(mPlugin != NULL);
+ mPlugin->setValue("foo");
+ fail_unless(mPlugin->getValue() == "foo");
+ fail_unless(doc.getNumDisabledPlugins() == 0);
+ // disable plugin
+ doc.disablePackage(TestExtension::getXmlnsL3V1V1(), "test");
+ fail_unless(doc.getNumDisabledPlugins() == 1);
+ mPlugin = dynamic_cast<TestModelPlugin*>(model->getPlugin("test"));
+ fail_unless(mPlugin == NULL);
+
+ // re-enable plugin
+ doc.enablePackage(TestExtension::getXmlnsL3V1V1(), "test", true);
+ fail_unless(doc.getNumDisabledPlugins() == 0);
+ mPlugin = dynamic_cast<TestModelPlugin*>(model->getPlugin("test"));
+ fail_unless(mPlugin != NULL);
+ fail_unless(mPlugin->getValue() == "foo");
+
+ // disable again
+ doc.disablePackage(TestExtension::getXmlnsL3V1V1(), "test");
+ fail_unless(doc.getNumDisabledPlugins() == 1);
+ doc.deleteDisabledPlugins();
+ fail_unless(doc.getNumDisabledPlugins() == 0);
+
+ // enable plugin
+ doc.enablePackage(TestExtension::getXmlnsL3V1V1(), "test", true);
+ mPlugin = dynamic_cast<TestModelPlugin*>(model->getPlugin("test"));
+ fail_unless(mPlugin != NULL);
+ fail_unless(mPlugin->getValue().empty());
+
+}
+END_TEST
+
Suite *
create_suite_SBMLExtension (void)
{
@@ -145,6 +183,7 @@
tcase_add_test( tcase, test_SBMLExtension );
tcase_add_test( tcase, test_SBMLExtension_c_api );
+ tcase_add_test( tcase, test_SBMLExtension_reenable );
suite_add_tcase(suite, tcase);
Modified: branches/libsbml-experimental/src/sbml/packages/comp/extension/CompModelPlugin.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/extension/CompModelPlugin.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/packages/comp/extension/CompModelPlugin.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -693,14 +693,17 @@
return LIBSBML_OPERATION_FAILED;
}
- // if we have a transformer specified, then we need to propagate it, so it can
- // be used
- if (isSetTransformer())
- {
- CompModelPlugin* other = dynamic_cast<CompModelPlugin*>(submodinst->getPlugin("comp"));
- if (other != NULL)
- other->setTransformer(getTransformer());
- }
+ //// if we have a transformer specified, then we need to propagate it, so it can
+ //// be used
+
+ // this needs to happen in Submodel:instantiate
+
+ //if (isSetTransformer())
+ //{
+ // CompModelPlugin* other = dynamic_cast<CompModelPlugin*>(submodinst->getPlugin("comp"));
+ // if (other != NULL)
+ // other->setTransformer(getTransformer());
+ //}
}
// Next, recursively find all the targets of SBaseRef elements
Modified: branches/libsbml-experimental/src/sbml/packages/comp/extension/CompSBMLDocumentPlugin.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/extension/CompSBMLDocumentPlugin.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/packages/comp/extension/CompSBMLDocumentPlugin.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -950,6 +950,7 @@
converter->setDocument(&dummyDoc);
int result = converter->convert();
+ delete converter;
if (result == LIBSBML_OPERATION_SUCCESS)
{
Modified: branches/libsbml-experimental/src/sbml/packages/comp/extension/test/TestExtensionObjects.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/extension/test/TestExtensionObjects.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/packages/comp/extension/test/TestExtensionObjects.cpp 2014-09-23 08:51:23 UTC (rev 21152)
@@ -63,7 +63,7 @@
fail_unless(doc->isPackageEnabled("comp") == true);
fail_unless(doc->getModel()->isPackageEnabled("comp") == true);
fail_unless(doc->getModel()->getCompartment(0)->isPackageEnabled("comp") == true);
-
+ delete doc;
}
END_TEST
@@ -91,6 +91,7 @@
fail_unless(submodref->getModelRef()=="ID1");
fail_unless(mplugin->removeSubmodel(3)==NULL);
fail_unless(mplugin->removeSubmodel(0)==submod);
+ delete submod;
fail_unless(mplugin->getSubmodel("submod1")==NULL);
fail_unless(mplugin->getNumPorts()==0);
@@ -111,6 +112,7 @@
fail_unless(portref->getIdRef()=="ID1");
fail_unless(mplugin->removePort(3)==NULL);
fail_unless(mplugin->removePort(0)==port);
+ delete port;
fail_unless(mplugin->getPort("port1")==NULL);
}
END_TEST
@@ -143,6 +145,7 @@
fail_unless(reref->getDeletion()=="ID1");
fail_unless(pplugin->removeReplacedElement(3)==NULL);
fail_unless(pplugin->removeReplacedElement(0)==re);
+ delete re;
fail_unless(pplugin->getReplacedElement(1)==NULL);
fail_unless(pplugin->isSetReplacedBy()==false);
@@ -185,6 +188,7 @@
fail_unless(moddefref->getId()=="ID1");
fail_unless(docplugin->removeModelDefinition(3)==NULL);
fail_unless(docplugin->removeModelDefinition(0)==moddef);
+ delete moddef;
fail_unless(docplugin->getModelDefinition("moddef1")==NULL);
fail_unless(docplugin->getNumExternalModelDefinitions()==0);
@@ -205,6 +209,7 @@
fail_unless(exmoddefref->getModelRef()=="ID1");
fail_unless(docplugin->removeExternalModelDefinition(3)==NULL);
fail_unless(docplugin->removeExternalModelDefinition(0)==exmoddef);
+ delete exmoddef;
fail_unless(docplugin->getExternalModelDefinition("exmoddef1")==NULL);
}
Modified: branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp 2014-09-22 14:37:22 UTC (rev 21151)
+++ branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp ...
[truncated message content] |