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


C++ Relation类代码示例

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


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

示例1: generateGeometry

OsmMapPtr AlphaShapeGenerator::generateMap(OsmMapPtr inputMap)
{
  boost::shared_ptr<Geometry> cutterShape = generateGeometry(inputMap);
  if (cutterShape->getArea() == 0.0)
  {
    //would rather this be thrown than a warning logged, as the warning may go unoticed by web
    //clients who are expecting the alpha shape to be generated
    throw HootException("Alpha Shape area is zero. Try increasing the buffer size and/or alpha.");
  }

  OsmMapPtr result;

  result.reset(new OsmMap(inputMap->getProjection()));
  // add the resulting alpha shape for debugging.
  GeometryConverter(result).convertGeometryToElement(cutterShape.get(), Status::Invalid, -1);

  const RelationMap& rm = result->getRelations();
  for (RelationMap::const_iterator it = rm.begin(); it != rm.end(); ++it)
  {
    Relation* r = result->getRelation(it->first).get();
    r->setTag("area", "yes");
  }

  return result;
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:25,代码来源:AlphaShapeGenerator.cpp

示例2: getHeadRelation

void Database::processRule(Rule* rule) {
    //Find the relation in the list of schemes matching the head of the predicate
    Relation* headRelation = getHeadRelation(rule);
    
    //Get the list of predicates
    std::vector<Predicate*> predicateList = rule->j;
    
    //Create new relations from each predicate
    std::vector<Relation*> relationList = getRelationList(predicateList);
    
    //Natural join the relations from the predicates
    Relation* newRelation = join(relationList);
    
    //Project on the final relation; only keep columns matching variables in the rule head
    std::vector<std::string> headVariables = getHeadVariables(rule->hpl);
    newRelation = newRelation->project(headVariables);
    
    //Find the relation in the database that matches the head of the rule
        //Already done (it's headRelation)
    
    //Rename attributes in the new relation so it matches the rule head's schema
    newRelation = renameToMatch(headRelation, newRelation, headVariables);
    
    //Union the new relation with the matching relation
    headRelation = unionWith(headRelation, newRelation);
    std::sort(headRelation->facts.begin(), headRelation->facts.end(), Relation::tupleCompare);
}
开发者ID:connorsmith256,项目名称:Project5,代码行数:27,代码来源:Database.cpp

示例3: join

void join(Relation &lhs, Relation &rhs, vector<size_t> &vars, Relation &result) {
  Relation temp;
  Relation *l, *r;
  if (lhs.size() >= rhs.size()) {
    l = &lhs;
    r = &rhs;
  } else {
    l = &rhs;
    r = &lhs;
  }
  Order order(vars, false);
  multiset<Tuple, Order> index (order);
  Relation::iterator it = r->begin();
  for (; it != r->end(); ++it) {
    index.insert(*it);
  }
  for (it = l->begin(); it != l->end(); ++it) {
    pair<multiset<Tuple, Order>::iterator,
         multiset<Tuple, Order>::iterator> rng = index.equal_range(*it);
    multiset<Tuple, Order>::iterator rit;
    for (rit = rng.first; rit != rng.second; ++rit) {
      Tuple res;
      if (!join(*it, *rit, res)) {
        cerr << "[ERROR] Two tuples that were expected to be compatible turned out not to be.  This indicates a flaw in the program logic." << endl;
      }
      temp.push_back(res);
    }    
  }
  result.swap(temp);
}
开发者ID:jrweave,项目名称:phd,代码行数:30,代码来源:infer-rules.cpp

示例4: createStandardRelation

Tokend::Relation *EstEIDSchema::createKeyRelation(CSSM_DB_RECORDTYPE keyType) {
    FLOG;

    Relation *rn = createStandardRelation(keyType);

    // Set up coders for key records.
    MetaRecord &mr = rn->metaRecord();
    mr.keyHandleFactory(&mEstEIDKeyHandleFactory);

    // Print name of a key might as well be the key name.
    mr.attributeCoder(kSecKeyPrintName, &mDescriptionCoder);

    // Other key values
    mr.attributeCoder(kSecKeyKeyType, &mKeyAlgorithmCoder);
    mr.attributeCoder(kSecKeyKeySizeInBits, &mKeySizeCoder);
    mr.attributeCoder(kSecKeyEffectiveKeySize, &mKeySizeCoder);

    // Key attributes
    mr.attributeCoder(kSecKeyExtractable, &mFalseCoder);
    mr.attributeCoder(kSecKeySensitive, &mTrueCoder);
    mr.attributeCoder(kSecKeyModifiable, &mFalseCoder);
    mr.attributeCoder(kSecKeyPrivate, &mTrueCoder);
    mr.attributeCoder(kSecKeyNeverExtractable, &mTrueCoder);
    mr.attributeCoder(kSecKeyAlwaysSensitive, &mTrueCoder);

    // Key usage
    mr.attributeCoder(kSecKeyEncrypt, &mFalseCoder);
    mr.attributeCoder(kSecKeyWrap, &mFalseCoder);
    mr.attributeCoder(kSecKeyVerify, &mFalseCoder);
    mr.attributeCoder(kSecKeyDerive, &mFalseCoder);
    mr.attributeCoder(kSecKeySignRecover, &mFalseCoder);
    mr.attributeCoder(kSecKeyVerifyRecover, &mFalseCoder);

    return rn;
}
开发者ID:kasparsd,项目名称:esteid-tokend,代码行数:35,代码来源:EstEIDSchema.cpp

示例5: RelationByType

Relation HTMLOutputAccessible::RelationByType(RelationType aType) const {
  Relation rel = AccessibleWrap::RelationByType(aType);
  if (aType == RelationType::CONTROLLED_BY)
    rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for));

  return rel;
}
开发者ID:BorisChiou,项目名称:gecko-dev,代码行数:7,代码来源:HTMLElementAccessibles.cpp

示例6: ChildCount

Relation
XULGroupboxAccessible::RelationByType(PRUint32 aType)
{
    Relation rel = AccessibleWrap::RelationByType(aType);
    if (aType != nsIAccessibleRelation::RELATION_LABELLED_BY)
        return rel;

    // The label for xul:groupbox is generated from xul:label that is
    // inside the anonymous content of the xul:caption.
    // The xul:label has an accessible object but the xul:caption does not
    PRUint32 childCount = ChildCount();
    for (PRUint32 childIdx = 0; childIdx < childCount; childIdx++) {
        Accessible* childAcc = GetChildAt(childIdx);
        if (childAcc->Role() == roles::LABEL) {
            // Ensure that it's our label
            Relation reverseRel =
                childAcc->RelationByType(nsIAccessibleRelation::RELATION_LABEL_FOR);
            Accessible* testGroupbox = nsnull;
            while ((testGroupbox = reverseRel.Next()))
                if (testGroupbox == this) {
                    // The <label> points back to this groupbox
                    rel.AppendTarget(childAcc);
                }
        }
    }

    return rel;
}
开发者ID:bitshadow,项目名称:mozilla-central,代码行数:28,代码来源:XULFormControlAccessible.cpp

示例7: matchRelation

void HasTagSelector::matchRelation(RelId relID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
	Relation* relation = geodata->getRelation(relID);

	auto& map = relation->getTags();
	if (map.find(tag) != map.end()) {
		next->matchRelation(relID, ti, attributes);
	}
}
开发者ID:DennisOSRM,项目名称:alacarte,代码行数:8,代码来源:hastag_selector.cpp

示例8: print_relations

void print_relations(const Relation& relations)
{
    for (Relation::const_iterator rela_iter = relations.begin();
            rela_iter != relations.end(); rela_iter++) {
        copy(rela_iter->begin(), rela_iter->end(), ostream_iterator<int>(cout, " "));
        cout << endl;
    }
}
开发者ID:spockwangs,项目名称:snippets,代码行数:8,代码来源:micro.cpp

示例9: evalRelationName

/*--------------------------------------------------
 * A query starts with a relation's name, followed 
 * by the relation assignment '<-' and an expression. 
 *--------------------------------------------------*/
Engine Evaluator::evalQuery() {
	string relationName = evalRelationName(tokens[cur]);

	// Check if relation-name is valid
	if(relationName.empty()) {
		return engine;
	} else {
		// Check if pointer can move
		if(isEndOfLine()) {
			printIncompleteError("query", "Missing <-");
			return engine;
		} else {
			// Move pointer to next token: <-
			cur++;
			string arrowCheck = tokens[cur];
			
			if(arrowCheck.compare("<-") == 0) {
				// Check if pointer can move
				if(isEndOfLine()) {
					printIncompleteError("query", "Missing expression");
					return engine;
				} else {
					// Move pointer to next token: expression
					cur++;
					
					Relation rel = evalExpression();
//					rel.printTuples();
					cur--;
					// Check if relation is valid
					if(rel.isVoid()) {
						return engine;
					} else {
						// Check if pointer can move
						if(isEndOfLine()) {
							printIncompleteError("query", "Missing ;");
							return engine;
						} else {
							// Move pointer to next token: ;
							cur++;
							string semiCheck = tokens[cur];
							//if(semiCheck.compare(";") == 0) {
								rel.setName(relationName);
								cout << rel.getName() << endl;
								//I changed this
								//rel.printTuples();								
								engine.addRelation(rel);
								//engine.show(relationName);
								//engine.setRelation(relationName, rel);

							//} else printInvalidError("open", ";", semiCheck);
						}
					}
				}
			} else printInvalidError("query", "<-", arrowCheck);		
		}
	}
	return engine;
}
开发者ID:hcheng761,项目名称:Database-Management-System,代码行数:62,代码来源:Evaluator.cpp

示例10: findRelation

Relation* RelationList::findRelation(Node* node0, Node* node1){
	for (int i=0; i<getNumNodes(); i++) {
		Relation* relation = (Relation*)getNodeAt(i);
		if ( (relation->getNode0()==node0 && relation->getNode1()==node1) || (relation->getNode0()==node1 && relation->getNode1()==node0) ) {
			return relation;
		}
	}
	return NULL;
}
开发者ID:Thr44,项目名称:Thr44-C-Lib,代码行数:9,代码来源:RelationList.cpp

示例11: predToTuple

void Interpretter::evalRules(vector <Rule>& rulelist) {

    for (Rule rule : rulelist) {
        cout << rule.toString();
        output += rule.toString();
        
        //get the first rule, then iterate thru the rest, adding to the new "joined" Relation
        Relation joined = db[rule.getPredicates()[0].getID()];
        
        // set a joined scheme, based on predicate[0]'s params. And give it to me in tuple format
        joined.redoScheme(rule.getPredicates()[0].getParams());
        if (rulelist.size() > 1) {
            vector <Relation> processedPreds;
            if (rule.getPredicates().size() > 1) {
                
                //for each Predicate (after the first) in the rule
                for (int i = 1; i < rule.getPredicates().size(); i++) {
                    Relation r = db[rule.getPredicates()[i].getID()];
                    Tuple predT = predToTuple(rule.getPredicates()[i]);
                    
                    Relation selected = r.select(predT);
                    //output += selected.toString();
                    
                    //Relation projected = selected.project(predT);
                    //output += projected.toString();
                    
                    Relation renamed = selected.rename(predT);
                    processedPreds.push_back(renamed);
                    joined = joined.join(renamed);
                }
            }
        }

        Tuple renameScheme;
        //cout << "rule.getName() = " << rule.getName() << endl;
        for (auto item : rule.getParams()) {
            renameScheme.push_back(item.getVal());
        }
        //cout << "joined" << joined.toString();
        Relation projectRule = joined.project2(renameScheme); //project with the original columns
        //Relation renameRule = projectRule.rename(renameScheme); // use the original scheme
        //cout << renameRule.toString();
        int prevSize = db[rule.getName()].getRelSize();
        for (auto tuple : projectRule.getTuples()) {

            db[rule.getName()].add(tuple);

            //if it actually added
            if (db[rule.getName()].getRelSize() > prevSize) {
                output += db[rule.getName()].tupleToString(tuple);
                prevSize = db[rule.getName()].getRelSize();
                addedTuples++;
            }
        }
        
    }
}
开发者ID:thelinguist,项目名称:CS-236,代码行数:57,代码来源:Interpretter.cpp

示例12: rename

string Relation::parse(Queries query){
	Relation editedRelation = *this;

	editedRelation = rename(query.getTuple(), editedRelation);
	editedRelation = select(query.getTuple(), editedRelation);
	editedRelation = project(query.getTuple(), editedRelation);

	return editedRelation.toFinalString(query);
}
开发者ID:raull,项目名称:CS236,代码行数:9,代码来源:Relation.cpp

示例13: IDRefsIterator

Relation
nsHTMLOutputAccessible::RelationByType(PRUint32 aType)
{
  Relation rel = nsAccessibleWrap::RelationByType(aType);
  if (aType == nsIAccessibleRelation::RELATION_CONTROLLED_BY)
    rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for));

  return rel;
}
开发者ID:dclarke,项目名称:services-central,代码行数:9,代码来源:nsHTMLTextAccessible.cpp

示例14: Caption

Relation
HTMLFigureAccessible::RelationByType(RelationType aType)
{
  Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
  if (aType == RelationType::LABELLED_BY)
    rel.AppendTarget(mDoc, Caption());

  return rel;
}
开发者ID:JerryShih,项目名称:gecko-dev,代码行数:9,代码来源:HTMLFormControlAccessible.cpp

示例15:

Relation
HTMLTableAccessible::RelationByType(RelationType aType)
{
  Relation rel = AccessibleWrap::RelationByType(aType);
  if (aType == RelationType::LABELLED_BY)
    rel.AppendTarget(Caption());

  return rel;
}
开发者ID:kinetiknz,项目名称:gecko-dev,代码行数:9,代码来源:HTMLTableAccessible.cpp


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