Skip to content

Commit

Permalink
Allow FBC objects to be used in both L3v1 and L3v2 core documents.
Browse files Browse the repository at this point in the history
Fixes #360
  • Loading branch information
luciansmith authored and fbergmann committed Aug 5, 2024
1 parent 927ed06 commit 94fa3fb
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 188 deletions.
20 changes: 0 additions & 20 deletions src/sbml/packages/fbc/extension/FbcModelPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,6 @@ int
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != bound->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != bound->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down Expand Up @@ -907,10 +903,6 @@ FbcModelPlugin::addObjective(const Objective* o)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != o->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != o->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down Expand Up @@ -1087,10 +1079,6 @@ FbcModelPlugin::addGeneProduct(const GeneProduct* gp)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != gp->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != gp->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down Expand Up @@ -1309,10 +1297,6 @@ int
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != association->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != association->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down Expand Up @@ -1534,10 +1518,6 @@ FbcModelPlugin::addUserDefinedConstraint(const UserDefinedConstraint* udc)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != udc->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != udc->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/extension/FbcReactionPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ FbcReactionPlugin::setGeneProductAssociation(const GeneProductAssociation* geneP
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != geneProductAssociation->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != geneProductAssociation->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/extension/FbcSBasePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ FbcSBasePlugin::addKeyValuePair(const KeyValuePair* kvp)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != kvp->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != kvp->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down
2 changes: 1 addition & 1 deletion src/sbml/packages/fbc/sbml/Association.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ Association::readAttributes (const XMLAttributes& attributes,
logEmptyString(mReference, sbmlLevel, sbmlVersion, "<gene>");
}
if (!SyntaxChecker::isValidSBMLSId(mReference))
logError(InvalidIdSyntax, getLevel(), getVersion(),
logError(InvalidIdSyntax, sbmlLevel, sbmlVersion,
"The syntax of the attribute reference='" + mReference + "' does not conform.");

}
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/sbml/FbcAnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ FbcAnd::addAssociation(const FbcAssociation* fa)
{
return LIBSBML_PKG_VERSION_MISMATCH;
}
else if (getVersion() != fa->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>(fa)) == false)
{
return LIBSBML_NAMESPACES_MISMATCH;
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/sbml/FbcAssociation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,6 @@ ListOfFbcAssociations::addFbcAssociation(const FbcAssociation* fa)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != fa->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>(fa)) == false)
{
return LIBSBML_NAMESPACES_MISMATCH;
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/sbml/FbcOr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ FbcOr::addAssociation(const FbcAssociation* fa)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != fa->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (getPackageVersion() != fa->getPackageVersion())
{
return LIBSBML_PKG_VERSION_MISMATCH;
Expand Down
22 changes: 5 additions & 17 deletions src/sbml/packages/fbc/sbml/FluxObjective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,9 @@ FluxObjective::setCoefficient(double coefficient)
int
FluxObjective::setVariableType(const FbcVariableType_t variableType)
{
unsigned int coreLevel = getLevel();
unsigned int coreVersion = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3)
if (pkgVersion >= 3)
{
if (FbcVariableType_isValid(variableType) == 0)
{
Expand All @@ -373,11 +371,9 @@ FluxObjective::setVariableType(const FbcVariableType_t variableType)
int
FluxObjective::setVariableType(const std::string& variableType)
{
unsigned int coreLevel = getLevel();
unsigned int coreVersion = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3)
if (pkgVersion >= 3)
{
mVariableType = FbcVariableType_fromString(variableType.c_str());

Expand Down Expand Up @@ -550,8 +546,6 @@ FluxObjective::hasRequiredAttributes () const
{
bool allPresent = true;

unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (isSetReaction() == false)
Expand All @@ -560,7 +554,7 @@ FluxObjective::hasRequiredAttributes () const
if (isSetCoefficient() == false)
allPresent = false;

if (level == 3 && version == 1 && pkgVersion == 3)
if (pkgVersion >= 3)
{
if (isSetVariableType() == false)
{
Expand Down Expand Up @@ -974,16 +968,14 @@ FluxObjective::addExpectedAttributes(ExpectedAttributes& attributes)
{
SBase::addExpectedAttributes(attributes);

unsigned int level = getLevel();
unsigned int coreVersion = getVersion();
unsigned int pkgVersion = getPackageVersion();

attributes.add("id");
attributes.add("name");
attributes.add("reaction");
attributes.add("coefficient");

if (level == 3 && coreVersion == 1 && pkgVersion == 3)
if (pkgVersion >= 3)
{
attributes.add("variableType");
attributes.add("reaction2");
Expand Down Expand Up @@ -1162,7 +1154,7 @@ FluxObjective::readAttributes (const XMLAttributes& attributes,
//

std::string variableType;
if (pkgVersion == 3)
if (pkgVersion >= 3)
{
assigned = attributes.readInto("variableType", variableType);

Expand Down Expand Up @@ -1352,10 +1344,6 @@ ListOfFluxObjectives::addFluxObjective(const FluxObjective* fo)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != fo->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>(fo)) == false)
{
return LIBSBML_NAMESPACES_MISMATCH;
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/sbml/GeneAssociation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,6 @@ int
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != association->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else
{
if (mAssociation != NULL)
Expand Down
4 changes: 0 additions & 4 deletions src/sbml/packages/fbc/sbml/GeneProduct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,10 +1071,6 @@ ListOfGeneProducts::addGeneProduct(const GeneProduct* gp)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != gp->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>(gp)) == false)
{
return LIBSBML_NAMESPACES_MISMATCH;
Expand Down
28 changes: 9 additions & 19 deletions src/sbml/packages/fbc/sbml/KeyValuePair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,9 @@ KeyValuePair::isSetUri() const
int
KeyValuePair::setId(const std::string& id)
{
unsigned int coreLevel = getLevel();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
return SyntaxChecker::checkAndSetSId(id, mId);
}
Expand All @@ -255,10 +254,9 @@ KeyValuePair::setId(const std::string& id)
int
KeyValuePair::setName(const std::string& name)
{
unsigned int coreLevel = getLevel();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
mName = name;
return LIBSBML_OPERATION_SUCCESS;
Expand All @@ -276,10 +274,9 @@ KeyValuePair::setName(const std::string& name)
int
KeyValuePair::setKey(const std::string& key)
{
unsigned int coreLevel = getLevel();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
mKey = key;
return LIBSBML_OPERATION_SUCCESS;
Expand All @@ -297,10 +294,9 @@ KeyValuePair::setKey(const std::string& key)
int
KeyValuePair::setValue(const std::string& value)
{
unsigned int coreLevel = getLevel();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
mValue = value;
return LIBSBML_OPERATION_SUCCESS;
Expand All @@ -318,10 +314,9 @@ KeyValuePair::setValue(const std::string& value)
int
KeyValuePair::setUri(const std::string& uri)
{
unsigned int coreLevel = getLevel();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
mUri = uri;
return LIBSBML_OPERATION_SUCCESS;
Expand Down Expand Up @@ -458,11 +453,9 @@ KeyValuePair::hasRequiredAttributes() const
{
bool allPresent = true;

unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (level == 3 && version == 1 && pkgVersion == 3)
if (pkgVersion >= 3)
{
if (isSetKey() == false)
{
Expand Down Expand Up @@ -854,10 +847,9 @@ KeyValuePair::addExpectedAttributes(ExpectedAttributes& attributes)
{
SBase::addExpectedAttributes(attributes);

unsigned int level = getLevel();
unsigned int pkgVersion = getPackageVersion();

if (level == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
attributes.add("id");
attributes.add("name");
Expand Down Expand Up @@ -936,7 +928,7 @@ KeyValuePair::readAttributes(const XMLAttributes& attributes,
}
}

if (level == 3 && version == 1 && pkgVersion == 3)
if (pkgVersion >= 3)
{
readL3V1V3Attributes(attributes);
}
Expand Down Expand Up @@ -1063,11 +1055,9 @@ KeyValuePair::writeAttributes(XMLOutputStream& stream) const
{
SBase::writeAttributes(stream);

unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (level == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
writeL3V1V3Attributes(stream);
}
Expand Down
18 changes: 4 additions & 14 deletions src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,9 @@ ListOfKeyValuePairs::setXmlns(const XMLNamespaces* xmlns, const std::string& pre
int
ListOfKeyValuePairs::setXmlns(const std::string& xmlns)
{
unsigned int coreLevel = getLevel();
unsigned int coreVersion = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (coreLevel == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
mXmlns = xmlns;
return LIBSBML_OPERATION_SUCCESS;
Expand Down Expand Up @@ -286,10 +284,6 @@ ListOfKeyValuePairs::addKeyValuePair(const KeyValuePair* kvp)
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != kvp->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const
SBase*>(kvp)) == false)
{
Expand Down Expand Up @@ -382,11 +376,9 @@ ListOfKeyValuePairs::hasRequiredAttributes() const
{
bool allPresent = true;

unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (level == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
if (isSetXmlns() == false)
{
Expand Down Expand Up @@ -483,7 +475,7 @@ ListOfKeyValuePairs::readAttributes(const XMLAttributes& attributes,
}
}

if (level == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
readL3V1V3Attributes(attributes);
}
Expand Down Expand Up @@ -550,11 +542,9 @@ ListOfKeyValuePairs::writeAttributes(XMLOutputStream& stream) const
{
ListOf::writeAttributes(stream);

unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();

if (level == 3 && pkgVersion == 3)
if (pkgVersion >= 3)
{
writeL3V1V3Attributes(stream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ ListOfUserDefinedConstraintComponents::addUserDefinedConstraintComponent(const
{
return LIBSBML_LEVEL_MISMATCH;
}
else if (getVersion() != udcc->getVersion())
{
return LIBSBML_VERSION_MISMATCH;
}
else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const
SBase*>(udcc)) == false)
{
Expand Down
Loading

0 comments on commit 94fa3fb

Please sign in to comment.