/** @cond doxygenLibsbmlInternal */ SBase* CompSBasePlugin::createObject(XMLInputStream& stream) { SBase* object = 0; const std::string& name = stream.peek().getName(); const XMLNamespaces& xmlns = stream.peek().getNamespaces(); const std::string& prefix = stream.peek().getPrefix(); const std::string& targetPrefix = (xmlns.hasURI(mURI)) ? xmlns.getPrefix(mURI) : mPrefix; if (prefix == targetPrefix) { if ( name == "listOfReplacedElements" ) { if (mListOfReplacedElements != NULL) { getErrorLog()->logPackageError("comp", CompOneListOfReplacedElements, getPackageVersion(), getLevel(), getVersion()); } createListOfReplacedElements(); object = mListOfReplacedElements; if (targetPrefix.empty()) { // // (NOTE) // // A top-level element (listOfReplacedElements) of the comp extension is located // in a default namespace, and thus xmlns=".." attribute must be added to // the element. // This is done by invoking SBMLDocument::enableDefaultNS() function with // the two arguments (the URI of this package and true value). // mListOfReplacedElements->getSBMLDocument()->enableDefaultNS(mURI,true); } } if ( name == "replacedBy" ) { if (mReplacedBy != NULL) { if (mSBML != NULL && getErrorLog() != NULL) { getErrorLog()->logPackageError("comp", CompOneReplacedByElement, getPackageVersion(), getLevel(), getVersion()); } } delete mReplacedBy; COMP_CREATE_NS(compns, getSBMLNamespaces()); mReplacedBy = new ReplacedBy(compns); object = mReplacedBy; object->connectToParent(getParentSBMLObject()); delete compns; } } return object; }
void CompSBasePlugin::createListOfReplacedElements() { if (mListOfReplacedElements==NULL) { COMP_CREATE_NS(compns, getSBMLNamespaces()); mListOfReplacedElements = new ListOfReplacedElements(compns); mListOfReplacedElements->connectToParent(getParentSBMLObject()); delete compns; } }
ReplacedBy* CompSBasePlugin::createReplacedBy() { if (mReplacedBy!=NULL) { delete mReplacedBy; } COMP_CREATE_NS(compns, getSBMLNamespaces()); mReplacedBy = new ReplacedBy(compns); mReplacedBy->connectToParent(getParentSBMLObject()); delete compns; return mReplacedBy; }
void CompSBasePlugin::logInvalidId(const std::string& attribute, const std::string& wrongattribute) { if (&attribute == NULL || &wrongattribute == NULL) return; bool knownelement = (getParentSBMLObject() == NULL); std::ostringstream msg; msg << "Setting the attribute '" << attribute << "' "; if (knownelement) { msg << "of a <" << getParentSBMLObject()->getElementName() << "> "; } msg << "in the " << getPackageName() << " package (version " << getPackageVersion() << ") to '" << wrongattribute << "' is illegal: the string is not a well-formed SId."; SBMLErrorLog* errlog = getErrorLog(); if (errlog) { errlog->logError(NotSchemaConformant, getLevel(), getVersion(), msg.str()); } }
CompSBasePlugin::CompSBasePlugin(const CompSBasePlugin& orig) : SBasePlugin(orig) , mListOfReplacedElements(NULL) , mReplacedBy(NULL) { if (orig.isSetReplacedBy()) { mReplacedBy = orig.mReplacedBy->clone(); mReplacedBy->connectToParent(getParentSBMLObject()); } if (orig.getNumReplacedElements() > 0) { createListOfReplacedElements(); for (unsigned int re=0; re<orig.getNumReplacedElements(); re++) { mListOfReplacedElements->append(orig.getReplacedElement(re)); } } connectToChild(); }
CompSBasePlugin& CompSBasePlugin::operator=(const CompSBasePlugin& orig) { if(&orig!=this) { SBasePlugin::operator =(orig); if (orig.getNumReplacedElements() > 0) { createListOfReplacedElements(); for (unsigned int re=0; re<orig.getNumReplacedElements(); re++) { mListOfReplacedElements->append(orig.getReplacedElement(re)); } } if (orig.mReplacedBy != NULL) { mReplacedBy=orig.mReplacedBy->clone(); mReplacedBy->connectToParent(getParentSBMLObject()); } } return *this; }
int CompSBasePlugin::setReplacedBy (const ReplacedBy* replacedBy) { if (mReplacedBy == replacedBy) { return LIBSBML_OPERATION_SUCCESS; } else if (replacedBy == NULL) { if (mReplacedBy != NULL) delete mReplacedBy; mReplacedBy = NULL; return LIBSBML_OPERATION_SUCCESS; } else if (!replacedBy->hasRequiredAttributes() || !replacedBy->hasRequiredElements()) { return LIBSBML_INVALID_OBJECT; } else if (getLevel() != replacedBy->getLevel()) { return LIBSBML_LEVEL_MISMATCH; } else if (getVersion() != replacedBy->getVersion()) { return LIBSBML_VERSION_MISMATCH; } else if (getPackageVersion() != replacedBy->getPackageVersion()) { return LIBSBML_PKG_VERSION_MISMATCH; } else { if (mReplacedBy != NULL) delete mReplacedBy; mReplacedBy = replacedBy->clone(); if (mReplacedBy == NULL) { return LIBSBML_OPERATION_FAILED; } mReplacedBy->connectToParent(getParentSBMLObject()); return LIBSBML_OPERATION_SUCCESS; } }
/** @cond doxygenLibsbmlInternal */ void GeneralGlyph::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfAdditionalGraphicalObjects - which will have * happened immediately prior to this read */ bool loSubGlyphs = false; if (getParentSBMLObject() != NULL && getParentSBMLObject()->getElementName() == "listOfSubGlyphs") { loSubGlyphs = true; } if (getErrorLog() != NULL && static_cast<ListOfGraphicalObjects*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else { getErrorLog()->logPackageError("layout", LayoutLOAddGOAllowedAttribut, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else { getErrorLog()->logPackageError("layout", LayoutLOAddGOAllowedAttribut, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } } GraphicalObject::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("layout", LayoutGGAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("layout", LayoutGGAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // reference SIdRef ( use = "optional" ) // assigned = attributes.readInto("reference", mReference); if (assigned == true) { // check string is not empty and correct syntax if (mReference.empty() == true) { logEmptyString(mReference, getLevel(), getVersion(), "<GeneralGlyph>"); } else if (SyntaxChecker::isValidSBMLSId(mReference) == false) { getErrorLog()->logPackageError("layout", LayoutGGReferenceSyntax, getPackageVersion(), sbmlLevel, sbmlVersion); } } }
/** @cond doxygenLibsbmlInternal */ void ReferenceGlyph::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfReferenceGlyphs - which will have * happened immediately prior to this read */ bool loSubGlyphs = false; if (getParentSBMLObject() != NULL && getParentSBMLObject()->getElementName() == "listOfSubGlyphs") { loSubGlyphs = true; } if (getErrorLog() != NULL && static_cast<ListOfReferenceGlyphs*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else { getErrorLog()->logPackageError("layout", LayoutLOReferenceGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else { getErrorLog()->logPackageError("layout", LayoutLOReferenceGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } } GraphicalObject::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("layout", LayoutREFGAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("layout", LayoutREFGAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } bool assigned = false; // // glyph SIdRef ( use = "required" ) // assigned = attributes.readInto("glyph", mGlyph); if (getErrorLog() != NULL) { if (assigned == true) { // check string is not empty and correct syntax if (mGlyph.empty() == true) { logEmptyString(mGlyph, getLevel(), getVersion(), "<ReferenceGlyph>"); } else if (SyntaxChecker::isValidSBMLSId(mGlyph) == false) { getErrorLog()->logPackageError("layout", LayoutREFGGlyphSyntax, getPackageVersion(), sbmlLevel, sbmlVersion, "The glyph on the <" + getElementName() + "> is '" + mGlyph + "', which does not conform to the syntax.", getLine(), getColumn()); } } else { std::string message = "Layout attribute 'glyph' is missing."; getErrorLog()->logPackageError("layout", LayoutREFGAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } } // // reference SIdRef ( use = "optional" ) // assigned = attributes.readInto("reference", mReference); if (assigned == true && getErrorLog() != NULL) { // check string is not empty and correct syntax if (mReference.empty() == true) { logEmptyString(mReference, getLevel(), getVersion(), "<ReferenceGlyph>"); } else if (SyntaxChecker::isValidSBMLSId(mReference) == false) { getErrorLog()->logPackageError("layout", LayoutREFGReferenceSyntax, getPackageVersion(), sbmlLevel, sbmlVersion, "The reference on the <" + getElementName() + "> is '" + mReference + "', which does not conform to the syntax.", getLine(), getColumn()); } } // // role string ( use = "optional" ) // std::string role; assigned = attributes.readInto("role", role); if (assigned == true) { // check string is not empty if (role.empty() == true && getErrorLog() != NULL) { logEmptyString(role, getLevel(), getVersion(), "<ReferenceGlyph>"); } this->setRole(role); } }
/** @cond doxygenLibsbmlInternal */ void SpeciesGlyph::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfSpeciesGlyphs - which will have * happened immediately prior to this read */ bool loSubGlyphs = false; if (getParentSBMLObject() != NULL && getParentSBMLObject()->getElementName() == "listOfSubGlyphs") { loSubGlyphs = true; } if (getErrorLog() != NULL && static_cast<ListOfSpeciesGlyphs*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else { getErrorLog()->logPackageError("layout", LayoutLOSpeciesGlyphAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else { getErrorLog()->logPackageError("layout", LayoutLOSpeciesGlyphAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } } GraphicalObject::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("layout", LayoutSGAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("layout", LayoutSGAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } bool assigned = false; // // species SIdRef ( use = "optional" ) // assigned = attributes.readInto("species", mSpecies); if (assigned == true && getErrorLog() != NULL) { // check string is not empty and correct syntax if (mSpecies.empty() == true) { logEmptyString(mSpecies, getLevel(), getVersion(), "<SpeciesGlyph>"); } else if (SyntaxChecker::isValidSBMLSId(mSpecies) == false) { getErrorLog()->logPackageError("layout", LayoutSGSpeciesSyntax, getPackageVersion(), sbmlLevel, sbmlVersion, "The species on the <" + getElementName() + "> is '" + mSpecies + "', which does not conform to the syntax.", getLine(), getColumn()); } } }