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


C++ Predicate类代码示例

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


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

示例1: nodesInAxis

void Step::evaluate(Node* context, NodeSet& nodes) const
{
    nodesInAxis(context, nodes);
    
    EvaluationContext& evaluationContext = Expression::evaluationContext();
    
    for (unsigned i = 0; i < m_predicates.size(); i++) {
        Predicate* predicate = m_predicates[i];

        NodeSet newNodes;
        if (!nodes.isSorted())
            newNodes.markSorted(false);

        evaluationContext.size = nodes.size();
        evaluationContext.position = 1;
        for (unsigned j = 0; j < nodes.size(); j++) {
            Node* node = nodes[j];

            Expression::evaluationContext().node = node;
            EvaluationContext backupCtx = evaluationContext;
            if (predicate->evaluate())
                newNodes.append(node);

            evaluationContext = backupCtx;
            ++evaluationContext.position;
        }

        nodes.swap(newNodes);
    }
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:30,代码来源:XPathStep.cpp

示例2: GetLog

shared_ptr<ActionObject> HingeEffector::GetActionObject(const Predicate& predicate)
{
    for(;;)
        {
            if (mJoint.get() == 0)
                {
                    break;
                }

            if (predicate.name != GetPredicate())
                {
                    GetLog()->Error()
                        << "ERROR: (HingeEffector) invalid predicate"
                        << predicate.name << "\n";
                    break;
                }

            Predicate::Iterator iter = predicate.begin();

            float velocity;
            if (! predicate.AdvanceValue(iter, velocity))
                {
                    GetLog()->Error()
                        << "ERROR: (HingeEffector) motor velocity expected\n";
                    break;
                }

            return shared_ptr<HingeAction>(new HingeAction(GetPredicate(),velocity));
        }

    return shared_ptr<ActionObject>();
}
开发者ID:MadMaxPavlo,项目名称:SimSpark-SPL,代码行数:32,代码来源:hingeeffector.cpp

示例3: copyConsTest

void copyConsTest()
{
	char str[100];
	while (gets(str)) {
		Parser p(str);

		Formula *f = p.parse();
		f->print();
		puts("");
		
		Predicate *pred = f->getPredicate();
		Term *t = pred->getTermList()->getList()->at(0);

		puts("here");
		Term w = *t;
		w.print();
		puts("here");
		w.setName("chan");
		w.print();
		puts("");

		f->print();
		puts("");
	}
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:25,代码来源:fotableau.cpp

示例4: parseParamList

void Parser::parseParamList(vector<Token>& toParse, Predicate& p)
{
	fillmyToken(toParse);
	if(myToken.myType == STRING)
	{
		match(STRING);
		Parameter param(myToken.data, myToken.myType);
		p.addParameter(param);
		domain.insert(myToken.data);
	}
	else
	{
		match(ID);
		Parameter param(myToken.data, myToken.myType);
		p.addParameter(param);
	}

	fillmyToken(toParse);
	if(myToken.myType == COMMA)	//more parameters to read
	{
		advanceIndex();
		parseParamList(toParse, p);
	}
	else
	{
		//do nothing; no more parameters
	}

}
开发者ID:FoxxGuthy,项目名称:CS-236,代码行数:29,代码来源:Parser.cpp

示例5: ParseError

/*
 * Fa il parsing della RHS della regola
 */
list<PredicateCall>
Parser::parse_rule_rhs(list<Token> token_list) {
  list<Token>::iterator token_iterator = token_list.begin();
  list<Token> predicate_tokens;
  list<PredicateCall> rhs;
  uint32_t read_tokens = 0;

  if (token_iterator == token_list.end())
    throw ParseError("empty right hand side");

  while (token_iterator != token_list.end()) {
    predicate_tokens = BUILD_TOKEN_BLOCK(token_iterator, string(1, LNG_STMT_END).c_str(), TKN_OPERATOR, token_list.end());
    Predicate pred = this->parse_predicate(predicate_tokens, predicate_tokens.begin(), &read_tokens);
    token_iterator = this->advance_iterator(token_iterator, read_tokens);
    ++token_iterator;
    read_tokens = 0;

    if ((token_iterator->get_type() == TKN_OPERATOR) &&
        (!token_iterator->get_value().compare(string(1, LNG_STMT_END)))) {
      ++token_iterator;
    } else if (token_iterator == token_list.end()) {
      throw ParseError("expected ; as predicate separator", (*(--token_iterator)).get_line_no());
    }

    PredicateCall call;
    call.set_name(pred.get_name());
    call.set_parameters(pred.get_parameters());
    rhs.push_back(call);
  }
  return rhs;
};
开发者ID:kratorius,项目名称:ant,代码行数:34,代码来源:rules.cpp

示例6: nodesInAxis

void Step::evaluate(EvaluationContext& evaluationContext, Node* context, NodeSet& nodes) const
{
    evaluationContext.position = 0;

    nodesInAxis(evaluationContext, context, nodes);

    // Check predicates that couldn't be merged into node test.
    for (unsigned i = 0; i < m_predicates.size(); i++) {
        Predicate* predicate = m_predicates[i].get();

        OwnPtrWillBeRawPtr<NodeSet> newNodes(NodeSet::create());
        if (!nodes.isSorted())
            newNodes->markSorted(false);

        for (unsigned j = 0; j < nodes.size(); j++) {
            Node* node = nodes[j];

            evaluationContext.node = node;
            evaluationContext.size = nodes.size();
            evaluationContext.position = j + 1;
            if (predicate->evaluate(evaluationContext))
                newNodes->append(node);
        }

        nodes.swap(*newNodes);
    }
}
开发者ID:335969568,项目名称:Blink-1,代码行数:27,代码来源:XPathStep.cpp

示例7: if

ProteinList_Filter::Impl::Impl(ProteinListPtr _original, const Predicate& predicate)
:   original(_original), getSequence(false)
{
    if (!original.get()) throw runtime_error("[ProteinList_Filter] Null pointer");

    // iterate through the proteins, using predicate to build the sub-list
    for (size_t i=1, end=original->size(); i<=end; ++i)
    {
        if (predicate.done()) break;

        ProteinPtr protein = original->protein(i-1, getSequence);
        tribool accepted = predicate.accept(*protein);

        if (accepted || getSequence) // if still indeterminate with getSequence = true, it passes the filter by default
        {
            pushProtein(*protein);            
        }
        else if (!accepted)
        {
            // do nothing 
        }
        else // indeterminate and !getSequence
        {
            // try again with getSequence = true
            getSequence = true;
            --i;
        }
    }
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:29,代码来源:ProteinList_Filter.cpp

示例8: nodesInAxis

void Step::evaluate(Node* context, NodeSet& nodes) const
{
    EvaluationContext& evaluationContext = Expression::evaluationContext();
    evaluationContext.position = 0;

    nodesInAxis(context, nodes);

    // Check predicates that couldn't be merged into node test.
    for (unsigned i = 0; i < m_predicates.size(); i++) {
        Predicate* predicate = m_predicates[i].get();

        NodeSet newNodes;
        if (!nodes.isSorted())
            newNodes.markSorted(false);

        for (unsigned j = 0; j < nodes.size(); j++) {
            Node* node = nodes[j];

            evaluationContext.node = node;
            evaluationContext.size = nodes.size();
            evaluationContext.position = j + 1;
            if (predicate->evaluate())
                newNodes.append(node);
        }

        nodes.swap(newNodes);
    }
}
开发者ID:Igalia,项目名称:blink,代码行数:28,代码来源:XPathStep.cpp

示例9: assert

/*
 * Caller is responsible for deleting returned Predicate* if necessary
 */
Predicate* Domain::getNonEvidenceAtom(const int& index) const
{
  int predId = -1;
  int numAtomsPerPred;
  int numAtoms = 0;
  for (int i = 0; i < getNumPredicates(); i++)
  {
    numAtomsPerPred = (*numNonEvidAtomsPerPred_)[i];
    if (numAtoms + numAtomsPerPred >= index + 1)
    {
      predId = i;
      break;
    }
    numAtoms += numAtomsPerPred;
  }
  assert(predId >= 0);

    // Get the newIndex-th grounding of f.o. pred with id predId   
  Predicate* pred = createPredicate(predId, false);
    // Not all groundings of pred are non-evidence, so we need the while loop
  bool foundNE = false;
  while(!foundNE)
  {
    for (int i = 0; i < pred->getNumTerms(); i++)
    {
      int termType = pred->getTermTypeAsInt(i);
      const Array<int>* constantsByType = getConstantsByType(termType);
      int constIdx = random() % constantsByType->size();
      pred->setTermToConstant(i, (*constantsByType)[constIdx]);
    }
    assert(pred->isGrounded());
    if (!db_->getEvidenceStatus(pred)) foundNE = true;
  }
  return pred;
}
开发者ID:aduitsis,项目名称:alchemy-2,代码行数:38,代码来源:domain.cpp

示例10: GetLog

shared_ptr<ActionObject>
PanTiltEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
    {
        GetLog()->Error() << "ERROR: (PanTiltEffector) invalid predicate"
                          << predicate.name << "\n";
        return shared_ptr<ActionObject>();
    }

    Predicate::Iterator iter = predicate.begin();

    float pan;
    if (! predicate.AdvanceValue(iter, pan))
    {
        GetLog()->Error() << "ERROR: (PanTiltEffector) 2 float parameters expected\n";
        return shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
    }
    float tilt;
    if (! predicate.AdvanceValue(iter, tilt))
    {
        GetLog()->Error() << "ERROR: (PanTiltEffector) float parameter expected\n";
        return shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
    }
    return shared_ptr<ActionObject>(new PanTiltAction(GetPredicate(),pan,tilt));
}
开发者ID:GiorgosMethe,项目名称:SimSpark-SPL,代码行数:26,代码来源:pantilteffector.cpp

示例11: initFactorMesssages

//the contribution of the factor itself
void Factor::initFactorMesssages()
{
    Predicate *pred;
    int numPreds = clause_->getNumPredicates();
    int stateCnt = (int)pow(2.0, numPreds);
    factorMsgs_ = new double[stateCnt];
    bool isSatisfied;
    for (int state = 0; state < stateCnt; state++)
    {
        isSatisfied = false;
        for (int predno = 0; predno < numPreds; predno++)
        {
            pred = clause_->getPredicate(predno);
            bool predBit = state & (1<<predno);
            if (pred->getSense() == predBit)
            {
                isSatisfied = true;
                break;
            }
        }

        if (isSatisfied)
        {
            // Always 1
            // MS: should be weight of clause in ground network (super or ground)
            factorMsgs_[state] = clause_->getWt();
        }
        else
        {
            factorMsgs_[state] = 0;
        }
    }
}
开发者ID:JIELOGAN,项目名称:alchemy-2,代码行数:34,代码来源:factor.cpp

示例12: GetLog

boost::shared_ptr<ActionObject>
SceneEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
        {
            GetLog()->Error() << "(SceneEffector) ERROR: invalid predicate"
                              << predicate.name << "\n";
            return boost::shared_ptr<ActionObject>();
        }

    string scene;
    if (! predicate.GetValue(predicate.begin(), scene))
        {
            GetLog()->Error()
                << "ERROR: (SceneEffector) scene filename expected\n";
            return boost::shared_ptr<ActionObject>();
        };

    boost::shared_ptr<ParameterList> parameters(
        new ParameterList(predicate.parameter));
    parameters->Pop_Front();

    return boost::shared_ptr<ActionObject>(
        new SceneAction(GetPredicate(), scene, parameters));
}
开发者ID:MadMaxPavlo,项目名称:SimSpark-SPL,代码行数:25,代码来源:sceneeffector.cpp

示例13:

double Matcher::predicateMatchScore
( const Predicate& sp, 
  const Predicate& tp ) const 
{
  map<Predicate, Predicate>::const_iterator sp_pos = matchedPreds.find(sp);
  map<Predicate, Predicate>::const_iterator tp_pos = matchedPreds.find(tp);
  if (sp_pos != matchedPreds.end() and sp_pos->second != tp) {
    return 0;
  }
  if (tp_pos != matchedPreds.end() and tp_pos->second != sp) {
    return 0;
  }
  if (sp.get_arity() == 0 and tp.get_arity() == 0) {
    return 1;
  }
  
  set<PlaceType> spTypes = sourcePreds.find(sp)->second;
  set<PlaceType> tpTypes = targetPreds.find(tp)->second;
  
  vector<PlaceType> intersection;
  set_intersection(spTypes.begin(), spTypes.end(), 
                   tpTypes.begin(), tpTypes.end(), 
                   back_inserter(intersection));
  double score = intersection.size() / (spTypes.size() + tpTypes.size());
  return score;
}
开发者ID:IvanLogvinov,项目名称:soar,代码行数:26,代码来源:matcher.cpp

示例14: GetLog

boost::shared_ptr<ActionObject>
SayEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
    {
        GetLog()->Error() << "ERROR: (SayEffector) invalid predicate"
                          << predicate.name << "\n";

        // some error happened
        return boost::shared_ptr<ActionObject>();
    }

    Predicate::Iterator iter = predicate.begin();

    std::string message;
    if (! predicate.AdvanceValue(iter, message))
    {
        GetLog()->Error()
            << "ERROR: (SayEffector) said message expected\n";

        // some error happened
        return boost::shared_ptr<ActionObject>();
    }

    // construct the SayAction object
    return boost::shared_ptr<SayAction>(new SayAction(GetPredicate(), message));

}
开发者ID:MadMaxPavlo,项目名称:SimSpark-SPL,代码行数:28,代码来源:sayeffector.cpp

示例15: getPredicate

Predicate* PredicateTable::getPredicate(index_object id) {

	Predicate p;
	p.setIndex(id);

	Predicate *p_finded = *hash.find(&p);
	return p_finded;
}
开发者ID:dave90,项目名称:DlvGrounder1,代码行数:8,代码来源:PredicateTable.cpp


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