当前位置: 首页>>代码示例>>C++>>正文


C++ SBMLErrorLog::clearLog方法代码示例

本文整理汇总了C++中SBMLErrorLog::clearLog方法的典型用法代码示例。如果您正苦于以下问题:C++ SBMLErrorLog::clearLog方法的具体用法?C++ SBMLErrorLog::clearLog怎么用?C++ SBMLErrorLog::clearLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SBMLErrorLog的用法示例。


在下文中一共展示了SBMLErrorLog::clearLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

/*
 * Performs a set of semantic consistency checks on the document.  Query
 * the results by calling getNumErrors() and getError().
 *
 * @return the number of failed checks (errors) encountered.
 */
unsigned int
SBMLInternalValidator::checkConsistency (bool writeDocument)
{
  unsigned int nerrors = 0;
  unsigned int total_errors = 0;

  //if (getLevel() == 3)
  //{
  //  logError(L3NotSupported);
  //  return 1;
  //}
  /* determine which validators to run */
  bool id    = ((mApplicableValidators & 0x01) == 0x01);
  bool sbml  = ((mApplicableValidators & 0x02) == 0x02);
  bool sbo   = ((mApplicableValidators & 0x04) == 0x04);
  bool math  = ((mApplicableValidators & 0x08) == 0x08);
  bool units = ((mApplicableValidators & 0x10) == 0x10);
  bool over  = ((mApplicableValidators & 0x20) == 0x20);
  bool practice = ((mApplicableValidators & 0x40) == 0x40);

  /* taken the state machine concept out for now
  if (LibSBMLStateMachine::isActive()) 
  {
    units = LibSBMLStateMachine::getUnitState();
  }
  */

  IdentifierConsistencyValidator id_validator;
  ConsistencyValidator validator;
  SBOConsistencyValidator sbo_validator;
  MathMLConsistencyValidator math_validator;
  UnitConsistencyValidator unit_validator;
  OverdeterminedValidator over_validator;
  ModelingPracticeValidator practice_validator;

  SBMLDocument *doc;
  SBMLErrorLog *log = getErrorLog();
  
  if (writeDocument)
  {
    char* sbmlString = writeSBMLToString(getDocument());
    log->clearLog();
    doc = readSBMLFromString(sbmlString);
    free (sbmlString);  
  }
  else
  {
    doc = getDocument();
  }

  /* calls each specified validator in turn 
   * - stopping when errors are encountered */

  if (id)
  {
    id_validator.init();
    nerrors = id_validator.validate(*doc);
    if (nerrors > 0) 
    {
      unsigned int origNum = log->getNumErrors();
      log->add( id_validator.getFailures() );

      if (origNum > 0 && log->contains(InvalidUnitIdSyntax) == true)
      {
        /* do not log dangling ref */
        while (log->contains(DanglingUnitSIdRef) == true)
        {
          log->remove(DanglingUnitSIdRef);
          nerrors--;
        }
        
        total_errors += nerrors;
        if (nerrors > 0)
        {
          if (writeDocument)
            SBMLDocument_free(doc);
          return total_errors;
        }
      }
      else if (log->contains(DanglingUnitSIdRef) == false)
      {
        total_errors += nerrors;
        if (writeDocument)
          SBMLDocument_free(doc);
        return total_errors;
      }
      else
      {
        bool onlyDangRef = true;
        for (unsigned int a = 0; a < log->getNumErrors(); a++)
        {
          if (log->getError(a)->getErrorId() != DanglingUnitSIdRef)
          {
            onlyDangRef = false;
//.........这里部分代码省略.........
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:101,代码来源:SBMLInternalValidator.cpp

示例2: if

/** @cond doxygenLibsbmlInternal */
int
CompFlatteningConverter::validateFlatDocument(Model * flatmodel,
            unsigned int pkgVersion, unsigned int level, unsigned int version)
{
  int result;
  // create a dummyDocument that will mirror what the user options are 
   // we need the dummyDoc to know things about unknown packages
  // but dont want the original model/error log
  SBMLDocument dummy = SBMLDocument(*(mDocument));
  dummy.setModel(NULL);
  dummy.getErrorLog()->clearLog();
   
  // Otherwise, transfer only errors 1090107->1090110
  SBMLErrorLog* log = mDocument->getErrorLog();
  for (unsigned int en=0; en<log->getNumErrors(); en++) 
  {
    unsigned int errid = mDocument->getError(en)->getErrorId();
    if (errid == CompFlatteningNotRecognisedNotReqd ||
        errid == CompFlatteningNotRecognisedReqd ||
        errid == CompFlatteningNotImplementedNotReqd ||
        errid == CompFlatteningNotImplementedReqd)
    {
          dummy.getErrorLog()->add(*(mDocument->getError(en)));
    }
  }

  log->clearLog();

  result = reconstructDocument(flatmodel, dummy, true );
  if (result != LIBSBML_OPERATION_SUCCESS)
  {
    //delete flatmodel;
    restoreNamespaces();
    return result;
  }

 //Now check to see if the flat model is valid
  // run regular validation on the flattened document if requested.

  // override comp flattening if necessary
  CompSBMLDocumentPlugin * dummyPlugin = static_cast<CompSBMLDocumentPlugin*>
                                         (dummy.getPlugin("comp"));

  if (dummyPlugin != NULL)
  {
    dummyPlugin->setOverrideCompFlattening(true);
  }

  std::string sbml = writeSBMLToStdString(&dummy);
  SBMLDocument *tempdoc = readSBMLFromString(sbml.c_str());
  unsigned int errors = 
           tempdoc->getErrorLog()->getNumFailsWithSeverity(LIBSBML_SEV_ERROR);
  
  // take out the error about a requiredpackage
  // if the user has specified to not abort for any packages
  // NOTE: we cannot actually remove it since the flattening code
  // uses it to check whether references might come from
  // other packages
  if (getAbortForNone() == true)
  {
    if (tempdoc->getErrorLog()->contains(RequiredPackagePresent))
    {
      errors--;
    }
  }

  if (errors > 0)
  {
    // we have serious errors so we are going to bail on the
    // flattening - log ONLY the errors
    //Transfer the errors to mDocument and don't reset the model.
    if (log->contains(CompLineNumbersUnreliable) == false)
    {
      log->logPackageError("comp", CompLineNumbersUnreliable, 
        pkgVersion, level, version);
    }
    std::string message = "Errors that follow relate to the flattened ";
    message += "document produced using the CompFlatteningConverter.";
    log->logPackageError("comp", CompFlatModelNotValid,
        pkgVersion, level, version);
  
    unsigned int nerrors = tempdoc->getErrorLog()->getNumErrors();
    for (unsigned int n = 0; n < nerrors; n++)
    {
      const SBMLError* error = tempdoc->getError(n);
      if (error->getSeverity() >= LIBSBML_SEV_ERROR) 
      {
        log->add( *(error) );
      }
      if (error->getErrorId() >= CompFlatteningNotRecognisedNotReqd &&
        error->getErrorId() <= CompFlatteningNotImplementedReqd) 
      {
        log->add( *(error) );
      }
      else if (error->getErrorId() == UnrequiredPackagePresent ||
        error->getErrorId() == RequiredPackagePresent)
      {
        log->add( *(error) );
      }
//.........这里部分代码省略.........
开发者ID:copasi,项目名称:copasi-dependencies,代码行数:101,代码来源:CompFlatteningConverter.cpp


注:本文中的SBMLErrorLog::clearLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。