void PackageIdReplacementCheck::checkReferencedElement(ReplacedBy& repBy) { unsigned int numErrsB4 = repBy.getSBMLDocument()->getNumErrors(); SBase* refElem = repBy.getReferencedElement(); // if there is an issue with references the getReferencedElement // will log errors and possibly fail // we dont want to try any further unsigned int numErrsAfter = repBy.getSBMLDocument()->getNumErrors(); if (numErrsB4 != numErrsAfter || refElem == NULL) { return; } SBase * parent = repBy.getParentSBMLObject(); if (parent->isSetId() == true && refElem->isSetId() == false) { logMissingIdAttribute(repBy, refElem, parent); } }
void ClassReplacements::checkReferencedElement(ReplacedBy& repBy) { unsigned int numErrsB4 = repBy.getSBMLDocument()->getNumErrors(); SBase* refElem = repBy.getReferencedElement(); // if there is an issue with references the getReferencedElement // will log errors and possibly fail // we dont want to try any further unsigned int numErrsAfter = repBy.getSBMLDocument()->getNumErrors(); if (numErrsB4 != numErrsAfter || refElem == NULL) { return; } SBase * parent = repBy.getParentSBMLObject(); if (refElem->getTypeCode() != parent->getTypeCode()) { int refElemTC = refElem->getTypeCode(); // exception is anything with mathematical meaning // may replace a parameter if (parent->getTypeCode() == SBML_PARAMETER) { if (refElemTC == SBML_COMPARTMENT || refElemTC == SBML_SPECIES || refElemTC == SBML_SPECIES_REFERENCE || refElemTC == SBML_REACTION || refElemTC == SBML_LOCAL_PARAMETER) { return; } } else if (parent->getTypeCode() == SBML_LOCAL_PARAMETER) { if (refElemTC == SBML_PARAMETER) { return; } } logBadClassReplacement(repBy, refElem, parent); } }
void UnitReplacementCheck::checkReferencedElement(ReplacedBy& repBy) { unsigned int numErrsB4 = repBy.getSBMLDocument()->getNumErrors(); SBase* refElem = repBy.getReferencedElement(); // if there is an issue with references the getReferencedElement // will log errors and possibly fail // we dont want to try any further unsigned int numErrsAfter = repBy.getSBMLDocument()->getNumErrors(); if (numErrsB4 != numErrsAfter || refElem == NULL) { return; } SBase * parent = repBy.getParentSBMLObject(); UnitDefinition *parentUnits = parent->getDerivedUnitDefinition(); //bool delparunit = parent->getTypeCode()==SBML_PARAMETER; UnitDefinition *refElemUnits = refElem->getDerivedUnitDefinition(); //bool delrefunit = refElem->getTypeCode()==SBML_PARAMETER; if (parentUnits == NULL || refElemUnits == NULL) { //if (delparunit) //{ // delete parentUnits; //} //if (delrefunit) //{ // delete refElemUnits; //} return; } if (parent->containsUndeclaredUnits() == true || refElem->containsUndeclaredUnits() == true) { //if (delparunit) //{ // delete parentUnits; //} //if (delrefunit) //{ // delete refElemUnits; //} return; } if (UnitDefinition::areIdentical(parentUnits, refElemUnits) == false) { logMismatchUnits(repBy, refElem, parent); } else { // if we have Compartments that have spatialDimensions but no units // we can check this if (parent->getTypeCode() == SBML_COMPARTMENT && parentUnits->getNumUnits() == 0 && refElem->getTypeCode() == SBML_COMPARTMENT && refElemUnits->getNumUnits() == 0) { if (static_cast<Compartment *>(parent)->isSetSpatialDimensions() == true && static_cast<Compartment *>(refElem)->isSetSpatialDimensions() == true) { if (util_isEqual( static_cast<Compartment *>(parent)->getSpatialDimensionsAsDouble(), static_cast<Compartment *>(refElem)->getSpatialDimensionsAsDouble()) == 0) { logMismatchSpatialDimensions(repBy, refElem, parent); } } } } //if (delparunit) //{ // delete parentUnits; //} //if (delrefunit) //{ // delete refElemUnits; //} }