本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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++;
}
}
}
}
示例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);
}
示例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;
}
示例14: Caption
Relation
HTMLFigureAccessible::RelationByType(RelationType aType)
{
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
if (aType == RelationType::LABELLED_BY)
rel.AppendTarget(mDoc, Caption());
return rel;
}
示例15:
Relation
HTMLTableAccessible::RelationByType(RelationType aType)
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType == RelationType::LABELLED_BY)
rel.AppendTarget(Caption());
return rel;
}