int SBaseRef::removeFromParentAndDelete() { SBase* parent = getParentSBMLObject(); if (parent==NULL) return LIBSBML_OPERATION_FAILED; SBaseRef* parentSBR; switch(parent->getTypeCode()) { case SBML_LIST_OF: //This will be the case if we are a deletion, replaced element, replaced by, or port. return SBase::removeFromParentAndDelete(); case SBML_COMP_DELETION: case SBML_COMP_SBASEREF: case SBML_COMP_REPLACEDELEMENT: case SBML_COMP_REPLACEDBY: case SBML_COMP_PORT: //This will be the case if we are a 'raw' SBaseRef object. parentSBR = static_cast<SBaseRef*>(parent); if (parentSBR==NULL) return LIBSBML_OPERATION_FAILED; return parentSBR->unsetSBaseRef(); default: assert(false); //Nothing else should ever be a parent of an SBaseRef object. return LIBSBML_OPERATION_FAILED; } }