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


C++ ASTNode::addChild方法代码示例

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


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

示例1: convertTimeAndExtent

int Submodel::convertTimeAndExtent()
{
  int ret=LIBSBML_OPERATION_SUCCESS;
  string tcf = "";
  ASTNode* tcf_ast = NULL;
  if (isSetTimeConversionFactor()) {
    tcf = getTimeConversionFactor();
    tcf_ast = new ASTNode(AST_NAME);
    tcf_ast->setName(tcf.c_str());
  }
  string xcf = "";
  ASTNode* xcf_ast = NULL;
  if (isSetExtentConversionFactor()) {
    xcf = getExtentConversionFactor();
    xcf_ast = new ASTNode(AST_NAME);
    xcf_ast->setName(xcf.c_str());
  }

  ASTNode* klmod = NULL;
  if (xcf_ast != NULL) {
    klmod = xcf_ast;
  }
  if (tcf_ast != NULL) {
    if (klmod==NULL) {
      klmod = new ASTNode(AST_INTEGER);
      klmod->setValue(1);
    }
    ASTNode* divide = new ASTNode(AST_DIVIDE);
    divide->addChild(klmod);
    divide->addChild(tcf_ast);
    klmod = divide;
  }

  ret = convertTimeAndExtentWith(tcf_ast, xcf_ast, klmod);
  delete klmod;
  return ret;
}
开发者ID:sys-bio,项目名称:libroadrunner-deps,代码行数:37,代码来源:Submodel.cpp

示例2: parseElse

void parseElse(CurrPtr& curr, EndPtr end) {
	getToken(curr, end);	// consume else

	if (!getColon(curr, end))
		return;

	ASTNode* pop = currNode;
	currNode = new ASTNode(kTokenElse);
	pop->addChild(currNode);

	parseStatements(curr, end, currNode);
	getSemiColon(curr, end);

	currNode = pop;
}
开发者ID:meshula,项目名称:Landru,代码行数:15,代码来源:Parser.cpp

示例3: parseStatements

void parseStatements(CurrPtr& curr, EndPtr end, ASTNode *& currNode)
{
	ASTNode* pop = currNode;
	ASTNode* ast = new ASTNode(kTokenStatements);
	pop->addChild(ast);
	currNode = ast;

	while (more(curr, end))
	{
		if (*curr == kTerminalChar) // ; at the end of the block of statements
		{
			break;
		}

		parseStatement(curr, end);
	}
	currNode = pop;
}
开发者ID:meshula,项目名称:Landru,代码行数:18,代码来源:Parser.cpp

示例4: parseLandruVarDeclaration

void parseLandruVarDeclaration(CurrPtr& curr, EndPtr end, ASTNode *& currNode)
{
	bool sharedToken = peekToken(curr, end) == kTokenShared;
	bool paramToken = !sharedToken && peekToken(curr, end) == kTokenParam;
	if (sharedToken || paramToken)
		getToken(curr, end);

	char varType[256];
	getType(curr, end, varType);

    if (!strlen(varType))
        lcRaiseError("Expected variable type, found:", curr, 32);

	TokenId declaredType = peekToken(varType, varType+sizeof(varType));

	char name[256];
	getDeclarator(curr, end, name);

    if (!strlen(name))
        lcRaiseError("Expected variable name, found:", curr, 32);

	auto token = kTokenLocalVariable;
	if (sharedToken)
		token = kTokenSharedVariable;
	else if (paramToken)
		token = kTokenParam;

	ASTNode * variableNode = new ASTNode(token, varType, name);
	currNode->addChild(variableNode);

	token = peekToken(curr, end);
	if (token == kTokenEq) {
		getToken(curr, end); // consume assignment operator
		ASTNode * pop = currNode;
		if (sharedToken)
			currNode = new ASTNode(kTokenInitialAssignment, name);
		else
			currNode = new ASTNode(kTokenAssignment, name);
		variableNode->addChild(currNode);
		parseLiteral(curr, end, currNode, declaredType); // and put the assigned value in the tree
		currNode = pop;
	}
}
开发者ID:meshula,项目名称:Landru,代码行数:43,代码来源:Parser.cpp

示例5: ASTNode

END_TEST


START_TEST (test_MathMLFromAST_function_2)
{
  const char* expected = wrapMathML
  (
    "  <apply>\n"
    "    <ci> foo </ci>\n"
    "    <cn type=\"integer\"> 1 </cn>\n"
    "    <cn type=\"integer\"> 2 </cn>\n"
    "    <apply>\n"
    "      <ci> bar </ci>\n"
    "      <ci> z </ci>\n"
    "    </apply>\n"
    "  </apply>\n"
  );

  // N = SBML_parseFormula("foo(1, 2, bar(z))");
  N = new ASTNode(AST_FUNCTION);
  fail_unless( N->setName("foo") == LIBSBML_OPERATION_SUCCESS);
  
  ASTNode *c1 = new ASTNode(AST_INTEGER);
  c1->setValue(long(1));
  ASTNode *c2 = new ASTNode(AST_INTEGER);
  c2->setValue(long(2));

  ASTNode *bar = new ASTNode(AST_FUNCTION);
  bar->setName("bar");

  ASTNode *cz = new ASTNode(AST_NAME);
  cz->setName("z");

  fail_unless (bar->addChild(cz) == LIBSBML_OPERATION_SUCCESS);

  fail_unless (N->addChild(c1) == LIBSBML_OPERATION_SUCCESS);
  fail_unless (N->addChild(c2) == LIBSBML_OPERATION_SUCCESS);
  fail_unless (N->addChild(bar) == LIBSBML_OPERATION_SUCCESS);

  S = writeMathMLToString(N);

  fail_unless( equals(expected, S) );
}
开发者ID:0u812,项目名称:roadrunner-backup,代码行数:43,代码来源:TestNewWriteMathMLFromAST.cpp

示例6: parseFunction

void parseFunction(CurrPtr& curr, EndPtr end, TokenId token) {
	char buff[256];
	getNameSpacedDeclarator(curr, end, buff);   // get function name

	ASTNode* pop = currNode;
	currNode = new ASTNode(token, buff);
	pop->addChild(currNode);

    parseParamList(curr, end);
    currNode = pop;

    more(curr, end);
    if (peekChar(curr, end) == '.') {
        // chained functions assume that the previous function left something on the stack
        // which can have a function invoked on it.
        ++curr;
        currNode->addChild(new ASTNode(kTokenDotChain, buff));
        parseFunction(curr, end, kTokenFunction);
    }
}
开发者ID:meshula,项目名称:Landru,代码行数:20,代码来源:Parser.cpp

示例7: parseOn

void parseOn(CurrPtr& curr, EndPtr end) {
	getToken(curr, end); // consume on

	char name[256];
	name[0] = '\0';
	TokenId what = peekToken(curr, end);
	if (what == kTokenUnknown) {
		char const* tokenStr;
		uint32_t length;
		curr = tsGetNameSpacedTokenAlphaNumeric(curr, end, '.', &tokenStr, &length);
		strncpy(name, tokenStr, length);
		name[length] = '\0';
		what = kTokenFunction;
	}
	else {
		getToken(curr, end);
	}

    ASTNode* pop = currNode;
	ASTNode* onNode = new ASTNode(kTokenOn);
	currNode->addChild(onNode);
	currNode = onNode;
	ASTNode* eventNode = new ASTNode(what, name);
	onNode->addChild(eventNode);
	currNode = eventNode;				// curr is now the qualifier, eg. message

    more(curr, end);
    if (peekChar(curr, end) == '(')
        parseParamList(curr, end);

	currNode = onNode;

	if (!getColon(curr, end))
		return;

	parseStatements(curr, end, currNode);
	getSemiColon(curr, end);

	currNode = pop;
}
开发者ID:meshula,项目名称:Landru,代码行数:40,代码来源:Parser.cpp

示例8: toAST

ASTNode* CEvaluationNodeCall::toAST(const CCopasiDataModel* pDataModel) const
{
  ASTNode* pNode = NULL;

  pNode = new ASTNode(AST_FUNCTION);
  const std::string funName = this->getData();
  CFunction * pFun = CCopasiRootContainer::getFunctionList()->findFunction(funName);
  assert(pFun != NULL);

  if (pFun == NULL || pFun->getSBMLId().empty()) fatalError();

  pNode->setName(pFun->getSBMLId().c_str());

  const CEvaluationNode* child = static_cast<const CEvaluationNode*>(this->getChild());

  while (child)
    {
      pNode->addChild(child->toAST(pDataModel));
      child = static_cast<const CEvaluationNode*>(child->getSibling());
    }

  return pNode;
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例9: ASTNode

END_TEST


START_TEST (test_MathMLFromAST_plus_nary_3)
{
  const char* expected = wrapMathML
  (
    "  <apply>\n"
    "    <plus/>\n"
    "    <cn type=\"integer\"> 1 </cn>\n"
    "    <cn type=\"integer\"> 2 </cn>\n"
    "    <cn type=\"integer\"> 3 </cn>\n"
    "  </apply>\n"
  );

//  N = SBML_parseFormula("1 + (2 + 3)");
  
  N = new ASTNode(AST_PLUS);
  
  ASTNode *c1 = new ASTNode(AST_INTEGER);
  c1->setValue(1);
  ASTNode *c2 = new ASTNode(AST_INTEGER);
  c2->setValue(2);
  ASTNode *c3 = new ASTNode(AST_INTEGER);
  c3->setValue(3);
  
  ASTNode *plus = new ASTNode(AST_PLUS);
  plus->addChild(c2);
  plus->addChild(c3);
  
  N->addChild(c1);
  N->addChild(plus);
  
  S = writeMathMLToString(N);

  fail_unless( equals(expected, S) );
}
开发者ID:0u812,项目名称:libsbml.js.frozen,代码行数:37,代码来源:TestWriteMathMLFromAST.cpp

示例10: UnitDefinition

END_TEST

START_TEST (test_UnitFormulaFormatter_getUnitDefinition_piecewise)
{
  UnitDefinition * ud = new UnitDefinition(2, 4);

  ud = uff->getUnitDefinition(m->getRule(7)->getMath());

  fail_unless(ud->getNumUnits() == 1);

  fail_unless(!strcmp(ud->getId().c_str(), ""), NULL);

  fail_unless(ud->getUnit(0)->getMultiplier() == 1);
  fail_unless(ud->getUnit(0)->getScale() == 0);
  fail_unless(ud->getUnit(0)->getExponent() == 1);
  fail_unless(ud->getUnit(0)->getOffset() == 0.0);
  fail_unless(ud->getUnit(0)->getKind() == UNIT_KIND_METRE);

  /* check deals with invalid nodes */
  delete ud;
  UnitDefinition * ud1 = new UnitDefinition(m->getLevel(), m->getVersion());
  ASTNode *node = new ASTNode(AST_FUNCTION_PIECEWISE);

  ud1 == uff->getUnitDefinition(node);

  fail_unless (ud1->getNumUnits() == 0);

  ASTNode *c = new ASTNode(AST_UNKNOWN);
  node->addChild(c);
  
  ud1 == uff->getUnitDefinition(node);

  fail_unless (ud1->getNumUnits() == 0);

  delete ud1;
  delete node;
}
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:37,代码来源:TestUnitFormulaFormatter.cpp

示例11: sbmlns

LIBSBML_CPP_NAMESPACE_USE

int
main (int argc, char* argv[])
{
  SBMLNamespaces sbmlns(3,1,"arrays",1);

  // create the document

  SBMLDocument *document = new SBMLDocument(&sbmlns);

  // set the required attribute to true
  ArraysSBMLDocumentPlugin * docPlug = 
    static_cast<ArraysSBMLDocumentPlugin*>(document->getPlugin("arrays"));
  docPlug->setRequired(true);


  // create the Model

  Model* model=document->createModel();

  // create the parameters

  // first parameter - for dimension m
  Parameter * p = model->createParameter();
  p->setId("m");
  p->setConstant(true);
  p->setValue(2);

  // second parameter - for dimension n
  p = model->createParameter();
  p->setId("n");
  p->setConstant(true);
  p->setValue(1);

  // third parameter - 2 x 1 matrix of parameters
  p = model->createParameter();
  p->setId("x");
  p->setConstant(false);


  // create the Dimensions via the Plugin
  ArraysSBasePlugin * arraysPlug = 
    static_cast<ArraysSBasePlugin*>(p->getPlugin("arrays"));

  // first dimension
  Dimension * dim = arraysPlug->createDimension();
  dim->setArrayDimension(0);
  dim->setSize("m");

  // second dimension
  dim = arraysPlug->createDimension();
  dim->setArrayDimension(1);
  dim->setSize("n");

  // other parameters
  p = model->createParameter();
  p->setId("y");
  p->setConstant(true);
  p->setValue(2.3);



  // create the initialAssignment
  InitialAssignment *ia = model->createInitialAssignment();
  ia->setSymbol("x");

  ASTNode * row1 = new ASTNode(AST_LINEAR_ALGEBRA_VECTOR_CONSTRUCTOR);
  
  ASTNode * ci1 = new ASTNode(AST_NAME);
  ci1->setName("y");
  
  row1->addChild(ci1);

  ASTNode * row2 = new ASTNode(AST_LINEAR_ALGEBRA_VECTOR_CONSTRUCTOR);
  
  ASTNode * ci2 = new ASTNode(AST_INTEGER);
  ci2->setValue(2);

  row2->addChild(ci2);

  ASTNode * math = new ASTNode(AST_LINEAR_ALGEBRA_VECTOR_CONSTRUCTOR);

  math->addChild(row1);
  math->addChild(row2);

  ia->setMath(math);

  writeSBML(document,"arrays_example3.xml");
 
  delete document;

  return 0;
}
开发者ID:kirichoi,项目名称:roadrunner,代码行数:94,代码来源:arrays_example3.cpp

示例12: ASTNode

END_TEST


START_TEST (test_MathMLFromAST_matrix)
{
  const char* expected = wrapMathML
  (
    "  <matrix>\n"
    "    <matrixrow>\n"
    "      <apply>\n"
    "        <cos/>\n"
    "        <cn type=\"integer\"> 5 </cn>\n"
    "      </apply>\n"
    "      <ci> y </ci>\n"
    "    </matrixrow>\n"
    "    <matrixrow>\n"
    "      <cn type=\"integer\"> 2 </cn>\n"
    "      <cn type=\"integer\"> 4 </cn>\n"
    "    </matrixrow>\n"
    "  </matrix>\n"
  );


  ASTNode * y = new ASTNode(AST_NAME);
  fail_unless(y->setName("y") == LIBSBML_OPERATION_SUCCESS);

  ASTNode *int1 = new ASTNode(AST_INTEGER);
  fail_unless(int1->setValue((long)(5)) == LIBSBML_OPERATION_SUCCESS);

  ASTNode *cos = new ASTNode(AST_FUNCTION_COS);
  fail_unless(cos->addChild(int1) == LIBSBML_OPERATION_SUCCESS);

  ASTNode *row1 = new ASTNode(AST_LINEAR_ALGEBRA_MATRIXROW_CONSTRUCTOR);
  fail_unless( row1->getPackageName() == "arrays");

  fail_unless(row1->addChild(cos) == LIBSBML_OPERATION_SUCCESS);
  fail_unless(row1->addChild(y) == LIBSBML_OPERATION_SUCCESS);


  ASTNode *int2 = new ASTNode(AST_INTEGER);
  fail_unless(int2->setValue((long)(2)) == LIBSBML_OPERATION_SUCCESS);

  ASTNode *int3 = new ASTNode(AST_INTEGER);
  fail_unless(int3->setValue((long)(4)) == LIBSBML_OPERATION_SUCCESS);

  ASTNode *row2 = new ASTNode(AST_LINEAR_ALGEBRA_MATRIXROW_CONSTRUCTOR);
  fail_unless( row2->getPackageName() == "arrays");

  fail_unless(row2->addChild(int2) == LIBSBML_OPERATION_SUCCESS);
  fail_unless(row2->addChild(int3) == LIBSBML_OPERATION_SUCCESS);

  N = new ASTNode(AST_LINEAR_ALGEBRA_MATRIX_CONSTRUCTOR);
  fail_unless( N->getPackageName() == "arrays");

  fail_unless(N->addChild(row1) == LIBSBML_OPERATION_SUCCESS);
  fail_unless(N->addChild(row2) == LIBSBML_OPERATION_SUCCESS);

  S = writeMathMLToString(N);

  fail_unless( equals(expected, S) );
}
开发者ID:TheCoSMoCompany,项目名称:biopredyn,代码行数:61,代码来源:TestNewWriteMathMLFromAST.cpp

示例13: parseParamList

void parseParamList(CurrPtr& curr, EndPtr end) {
	// if parsing a function, then an opening paren must have been encountered
	if (peekChar(curr, end) != '(') {
		lcRaiseError("Expecting a parameter list, no opening parenthesis found", curr, 32);
		return;
	}

    std::vector<std::string> paramList;
    parseExpression(curr, end, paramList);

    // closing paren
    if (peekChar(curr, end) == ')')
        getChar(curr, end);  // consume ')'
	else
		lcRaiseError("Expected closing parenthesis, found", curr, 32);

    ASTNode* popNode = currNode;

    std::vector<ASTNode*> nodeStack; // this is where the things that get parameters go

    ASTNode* paramNode = 0;
    for (auto i = paramList.begin(); i != paramList.end(); ++i) {
        const std::string& s = *i;
        const char* strstart = s.c_str();
        const char* strend = strstart + s.size();

        if (s == "(") {
            nodeStack.push_back(currNode);
            currNode = new ASTNode(kTokenParameters);
        }
        else if (s == ")") {
            paramNode = currNode;
            currNode = nodeStack.back();
            nodeStack.pop_back();
        }
        else if (*(strend - 1) == '#') {
            if (!paramNode)
                lcRaiseError("Missing parameters for function", curr, 32);

            std::string funcName;
            funcName = s.substr(0, s.size() - 1);
            ASTNode* functionNode = new ASTNode(kTokenFunction, funcName.c_str());
            functionNode->addChild(paramNode);
            paramNode = 0;
            currNode->addChild(functionNode);
        }
        else if (peekIsLiteral(strstart, strend))
            parseLiteral(strstart, strend, currNode, kTokenNullLiteral);
        else if (s == "*")
            currNode->addChild(new ASTNode(kTokenOpMultiply));
        else if (s == "+")
            currNode->addChild(new ASTNode(kTokenOpAdd));
        else if (s == "/")
            currNode->addChild(new ASTNode(kTokenOpDivide));
        else if (s == "-")
            currNode->addChild(new ASTNode(kTokenOpSubtract));
        else if (s == "!")
            currNode->addChild(new ASTNode(kTokenOpNegate));
        else if (s == "%")
            currNode->addChild(new ASTNode(kTokenOpModulus));
        else if (s == ">")
            currNode->addChild(new ASTNode(kTokenOpGreaterThan));
        else if (s == "<")
            currNode->addChild(new ASTNode(kTokenOpLessThan));
        //else if (s == "=")
        //    pushAssign();
        else if (s[0] == '@')
			currNode->addChild(new ASTNode(kTokenGetVariableReference, strstart+1));
		else
            currNode->addChild(new ASTNode(kTokenGetVariable, strstart));
    }
    if (!nodeStack.empty() || !paramNode)
        lcRaiseError("Unmatched parenthesis in expression", curr, 32);

    currNode = popNode;
    currNode->addChild(paramNode);
}
开发者ID:meshula,项目名称:Landru,代码行数:77,代码来源:Parser.cpp

示例14: convertTimeAndExtentWith

int Submodel::convertTimeAndExtentWith(const ASTNode* tcf, const ASTNode* xcf, const ASTNode* klmod)
{
  if (tcf==NULL && xcf==NULL) return LIBSBML_OPERATION_SUCCESS;
  Model* model = getInstantiation();
  if (model==NULL) {
    //getInstantiation sets its own error messages.
    return LIBSBML_OPERATION_FAILED;
  }
  ASTNode* tcftimes = NULL;
  ASTNode* tcfdiv = NULL;
  if (tcf != NULL) {
    tcftimes = new ASTNode(AST_TIMES);
    tcftimes->addChild(tcf->deepCopy());
    tcfdiv = new ASTNode(AST_DIVIDE);
    tcfdiv->addChild(tcf->deepCopy());
  }
  ASTNode* rxndivide = NULL;
  if (klmod != NULL) {
    rxndivide = new ASTNode(AST_DIVIDE);
    ASTNode rxnref(AST_NAME);
    rxndivide->addChild(rxnref.deepCopy());
    rxndivide->addChild(klmod->deepCopy());
  }
  List* allelements = model->getAllElements();
  for (unsigned int el=0; el<allelements->getSize(); el++) {
    SBase* element = static_cast<SBase*>(allelements->get(el));
    assert(element != NULL);
    ASTNode* ast1 = NULL;
    ASTNode* ast2 = NULL;
    Constraint* constraint = NULL;
    Delay* delay = NULL;
    EventAssignment* ea = NULL;
    InitialAssignment* ia = NULL;
    KineticLaw* kl = NULL;
    Priority* priority = NULL;
    RateRule* rrule = NULL;
    Rule* rule = NULL;
    Submodel* submodel = NULL;
    Trigger* trigger = NULL;
    string cf = "";
    //Reaction math will be converted below, in the bits with the kinetic law.  But because of that, we need to handle references *to* the reaction:  even if it has no kinetic law, the units have changed, and this needs to be reflected by the flattening routine.
    if (rxndivide != NULL && element->getTypeCode()==SBML_REACTION && element->isSetId()) {
      rxndivide->getChild(0)->setName(element->getId().c_str());
      for (unsigned int sube=0; sube<allelements->getSize(); sube++) {
        SBase* subelement = static_cast<SBase*>(allelements->get(sube));
        subelement->replaceSIDWithFunction(element->getId(), rxndivide);
      }
    }

    //Submodels need their timeConversionFactor and extentConversionFactor attributes converted.  We're moving top-down, so all we need to do here is fix the conversion factor attributes themselves, pointing them to new parameters if need be.
    if ((tcf !=NULL || xcf != NULL) && element->getTypeCode()==SBML_COMP_SUBMODEL) {
      submodel = static_cast<Submodel*>(element);
      if (tcf != NULL) {
        if (submodel->isSetTimeConversionFactor()) {
          createNewConversionFactor(cf, tcf, submodel->getTimeConversionFactor(), model);
          submodel->setTimeConversionFactor(cf);
        }
        else {
          submodel->setTimeConversionFactor(tcf->getName());
        }
      }
      if (xcf != NULL) {
        if (submodel->isSetExtentConversionFactor()) {
          createNewConversionFactor(cf, xcf, submodel->getExtentConversionFactor(), model);
          submodel->setExtentConversionFactor(cf);
        }
        else {
          submodel->setExtentConversionFactor(xcf->getName());
        }
      }
    }
    if (tcf==NULL) {
      if (klmod !=NULL && element->getTypeCode()==SBML_KINETIC_LAW) {
        kl = static_cast<KineticLaw*>(element);
        if (kl->isSetMath()) {
          ast1 = new ASTNode(AST_TIMES);
          ast1->addChild(klmod->deepCopy());
          ast1->addChild(kl->getMath()->deepCopy());
          kl->setMath(ast1);
          delete ast1;
        }
      }
    }
    else {
      // All math 'time' and 'delay' csymbols must still be converted.
      // Also, several constructs are modified directly.
      switch(element->getTypeCode()) {
        //This would be a WHOLE LOT SIMPLER if there was a 'hasMath' class in libsbml.  But even so, it would have to
        // handle the kinetic laws, rate rules, and delays separately.
      case SBML_KINETIC_LAW:
        //Kinetic laws are multiplied by 'klmod'.
        kl = static_cast<KineticLaw*>(element);
        ast1 = kl->getMath()->deepCopy();
        convertCSymbols(ast1, tcfdiv, tcftimes);
        if (klmod !=NULL) {
          kl = static_cast<KineticLaw*>(element);
          if (kl->isSetMath()) {
            ast2 = new ASTNode(AST_TIMES);
            ast2->addChild(klmod->deepCopy());
            ast2->addChild(ast1);
//.........这里部分代码省略.........
开发者ID:0u812,项目名称:roadrunner-backup,代码行数:101,代码来源:Submodel.cpp

示例15: createExampleEnzymaticReaction


//.........这里部分代码省略.........
   //------------------------------------------

   ASTNode* astCytosol = new ASTNode(AST_NAME);
   astCytosol->setName("cytosol");

   ASTNode* astKon = new ASTNode(AST_NAME);
   astKon->setName("kon");

   ASTNode* astKoff = new ASTNode(AST_NAME);
   astKoff->setName("koff");

   ASTNode* astE = new ASTNode(AST_NAME);
   astE->setName("E");

   ASTNode* astS = new ASTNode(AST_NAME);
   astS->setName("S");

   ASTNode* astES = new ASTNode(AST_NAME);
   astES->setName("ES");


   //--------------------------------------------
   //
   // create node representing
   //            <apply>
   //              <times/>
   //              <ci> koff </ci>
   //              <ci> ES </ci>
   //            </apply>
   //
   //--------------------------------------------

   ASTNode *astTimes1 = new ASTNode(AST_TIMES);
   astTimes1->addChild(astKoff);
   astTimes1->addChild(astES);

   //--------------------------------------------
   //
   // create node representing
   //            <apply>
   //              <times/>
   //              <ci> kon </ci>
   //              <ci> E </ci>
   //              <ci> S </ci>
   //            </apply>
   //
   //
   // (NOTES)
   //
   //  Since there is a restriction with an ASTNode of "<times/>" operation
   //  such that the ASTNode is a binary class and thus only two operands can
   //  be directly added, the following code in this comment block is invalid
   //  because the code directly adds three <ci> ASTNodes to <times/> ASTNode.
   //
   //    ASTNode *astTimes = new ASTNode(AST_TIMES);
   //    astTimes->addChild(astKon);
   //    astTimes->addChild(astE);
   //    astTimes->addChild(astS);
   //
   // The following valid code after this comment block creates the ASTNode
   // as a binary tree.
   //
   // Please see "Converting between ASTs and text strings" described
   // at http://sbml.org/Software/libSBML/docs/cpp-api/class_a_s_t_node.html
   // for the detailed information.
   //
开发者ID:sys-bio,项目名称:libroadrunner-deps,代码行数:67,代码来源:createExampleSBML.cpp


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