void SymbolTable::addSymbols(const std::vector<GDLNode*> &ast) { for (const GDLNode *node : ast) { switch (node->getInstanceOf()) { case INSTANCE_OF_ROLE_NODE: addRole((RoleNode*)node); break; case INSTANCE_OF_RELATION_NODE: addRelation((RelationNode*)node); break; case INSTANCE_OF_IF_NODE: processIfNode((IfNode*)node); break; case INSTANCE_OF_BASE_NODE: processBaseNode((BaseNode*)node); break; case INSTANCE_OF_INIT_NODE: processInitNode((InitNode*)node); break; case INSTANCE_OF_INPUT_NODE: processInputNode((InputNode*)node); break; default: throw Exception("Unexpected node type in the abstract syntax tree"); } } }
void QgsRelationManager::setRelations( const QList<QgsRelation>& relations ) { mRelations.clear(); Q_FOREACH ( const QgsRelation& rel, relations ) { addRelation( rel ); }
void QgsRelationManager::setRelations( const QList<QgsRelation>& relations ) { mRelations.clear(); foreach ( const QgsRelation& rel, relations ) { addRelation( rel ); }
bool Network::addRelation(Node* node0, Node* node1, bool directed){ printf("\n.1"); Relation* relation=new Relation(node0, node1, directed); printf("\n.2"); bool added = addRelation(relation); if(!added){ //TODO:delete relation; } return added; }
void QgsRelationManagerDialog::setLayers( const QList< QgsVectorLayer* >& layers ) { mLayers = layers; const QList<QgsRelation>& relations = mRelationManager->relations().values(); Q_FOREACH ( const QgsRelation& rel, relations ) { addRelation( rel ); }
/*!\func TGraph::mousePressEvent * * \param * - event - * \return */ void GraphBody::mousePressEvent(QMouseEvent *event) { LOG(LOG_DEBUG, QString(__FUNCTION__) + " <" + QString::number(__LINE__) + ">"); if(state->isState(State::STATE_ADD_RELATION)) { if(node->nodes().contains(currentIndex)) { qint16 index = currentIndex; QGraphicsView::mousePressEvent(event); addRelation(index, currentIndex, state.data()); } } setState(new State()); QGraphicsView::mousePressEvent(event); }
// create a recursive tree from flat items and their path property ResourceItem::Relation * WebResourceProvider::addRelation( ResourceItem::Relation * _parent, ResourceItem * _item ) { if( _parent == database()->topLevelNode() || _item->path().isEmpty() ) { return new ResourceItem::Relation( _parent, _item ); } const QStringList itemPath = _item->path().split( '/' ); QString pathComponent = itemPath.first() + "/"; QString parentPath; if( _parent->item() ) { parentPath = _parent->item()->path() + _parent->item()->name(); const int parentPathSize = parentPath.count( '/' ); if( parentPathSize+1 >= itemPath.size() ) { // if( _item->path() == parentPath ) { return new ResourceItem::Relation( _parent, _item ); } /* else { // something went wrong return new ResourceItem::Relation( _parent, _item ); }*/ } pathComponent = itemPath[parentPathSize] + "/"; } ResourceItem::Relation * subParent = _parent->findChild( pathComponent, ResourceItem::BaseURL ); if( subParent == NULL ) { ResourceItem * dirItem = new ResourceItem( this, pathComponent, ResourceItem::TypeDirectory, ResourceItem::BaseURL, parentPath ); database()->addItem( dirItem ); subParent = new ResourceItem::Relation( _parent, dirItem ); } return addRelation( subParent, _item ); }
/** * Add data to the contact. * All fields must be empty. */ void PIMContact::addDataToContact() { printf("\n==============Add data to contact==============\n"); printf(sFieldSeparator); addContactName(); waitForClick(); addAddress(); waitForClick(); addBirthday(); waitForClick(); addEmail(); waitForClick(); addNickname(); waitForClick(); addNote(); waitForClick(); addOrg(); waitForClick(); // If you want to set a photo URL call addPhotoURL method instead of // addPhoto method. addPhoto(); waitForClick(); addPhone(); waitForClick(); addTitle(); waitForClick(); addURL(); waitForClick(); addIM(); waitForClick(); addRelation(); waitForClick(); addOrgInfo(); waitForClick(); }
/** * @brief RelationFactory::make * @param relType * @param tail * @param head * @param addToScene * @return */ SharedRelation RelationFactory::make(RelationType relType, const common::ID &tail, const common::ID &head, CreationOptions options) const { if (auto pr = G_ASSERT(project())) { if (G_ASSERT(pr->database() && project()->globalDatabase())) { if (auto maker = G_ASSERT(relationMaker[relType])) { if (auto relation = maker(tail, head, {pr->database(), pr->globalDatabase()})) { addRelation(relation, pr->database(), scene(), options); return relation; } } } } return nullptr; }
Database::Database(DatalogProgram* p) { parser = p; std::vector<Scheme*> svec = parser->sl->svec; for (int i = 0; i < svec.size(); i++) { //Loop through the list of schemes Token* name = svec.at(i)->first; std::vector<Token*> schema = svec.at(i)->idl; Relation* r = new Relation(name, schema); //Create a new relation with the name and attributes of each scheme addRelation(r); //Add the relation to the database } addTuples(); //Populate the database addRules(); //Add the rules to the database g = new Graph(rules); //Generate a depends-on graph for the rules //processRules(); //Generate new facts }
CatalogDatabase::CatalogDatabase(const serialization::CatalogDatabase &proto) : name_(proto.name()) { DCHECK(ProtoIsValid(proto)) << "Attempted to create CatalogDatabase from an invalid proto description:\n" << proto.DebugString(); for (int index_relations = 0, index_null_relations = 0; index_relations < proto.null_relations_size() + proto.relations_size(); ++index_relations) { if (index_null_relations < proto.null_relations_size() && index_relations == proto.null_relations(index_null_relations)) { rel_vec_.push_back(NULL); ++index_null_relations; } else { addRelation(new CatalogRelation(proto.relations(index_relations - index_null_relations))); } } }
void WebResourceProvider::importNodeIntoDB( const QDomNode & _n, ResourceItem::Relation * _parent ) { QDomNode n = _n; while( !n.isNull() ) { QString path = n.firstChildElement( "dir" ).text(); ResourceItem::Type type = ResourceItem::TypeUnknown; if( !path.isEmpty() ) { path += "/"; } if( n.nodeName() == "webresources" ) { type = ResourceItem::TypeDirectory; } ResourceItem * item = new ResourceItem( this, n.firstChildElement( "name" ).text(), type, ResourceItem::BaseURL, path, n.firstChildElement( "hash" ).text(), n.firstChildElement( "author" ).text(), n.firstChildElement( "tags" ).text(), n.firstChildElement( "size" ).text().toInt(), QDateTime::fromString( n.firstChildElement( "date" ).text(), Qt::ISODate ) ); database()->addItem( item ); ResourceItem::Relation * relation = addRelation( _parent, item ); if( n.nodeName() != "file" ) { importNodeIntoDB( n.firstChild(), relation ); } n = n.nextSibling(); } }
/** * @brief RelationFactory::make * @param src * @param addToScene * @return */ SharedRelation RelationFactory::make(const QJsonObject &src, ErrorList &errors, CreationOptions options) const { if (src.contains(relationship::Relation::typeMarker())) { auto relType = RelationType(src[relationship::Relation::typeMarker()].toInt()); if (auto maker = G_ASSERT(relationMaker[relType])) { db::WeakTypeSearchers ts {G_ASSERT(project())->database(), G_ASSERT(project())->globalDatabase()}; if (auto relation = maker(common::ID::nullID(), common::ID::nullID(), ts)) { relation->fromJson(src, errors); if (errors.isEmpty()) { addRelation(relation, G_ASSERT(project())->database(), scene(), options); return relation; } else { qWarning() << "Relation was loaded with errors."; } } } } return nullptr; }
void WorldModel::setRelation(Idx parent, Idx child, const RelationConstPtr& r) { const EntityConstPtr& p = entities_[parent]; const EntityConstPtr& c = entities_[child]; if (!p || !c) { std::cout << "[ED] ERROR: Invalid relation addition: parent or child does not exit." << std::endl; return; } Idx r_idx = p->relationTo(child); if (r_idx == INVALID_IDX) { r_idx = addRelation(r); EntityPtr p_new(new Entity(*entities_[parent])); EntityPtr c_new(new Entity(*entities_[child])); p_new->setRelationTo(child, r_idx); c_new->setRelationFrom(parent, r_idx); entities_[parent] = p_new; entities_[child] = c_new; } else { relations_[r_idx] = r; } // Update entity revisions for(std::size_t i = entity_revisions_.size(); i < std::max(parent, child) + 1; ++i) entity_revisions_.push_back(0); entity_revisions_[parent] = revision_; entity_revisions_[child] = revision_; }
inline void GMap3::init() { m_beta3 = addRelation("beta3") ; }
inline void Map3::init() { m_phi3 = addRelation("phi3") ; }
/** * \brief 处理Gateway转发过来的客户端消息 * \param pNullCmd 消息体 * \param cmdLen 消息长度 * \return true 处理完毕,false 不在处理范围之中 */ bool CRelationManager::processUserMessage(const Cmd::stNullUserCmd *pNullCmd,const DWORD cmdLen) { switch(pNullCmd->byCmd) { case Cmd::RELATION_USERCMD: { switch(pNullCmd->byParam) { case UNMARRY_PARA: { CRelation* relation = NULL; relation = getMarryRelation(); if (relation) { UserSession *otherUser = NULL; otherUser = UserSessionManager::getInstance()->getUserSessionByName(relation->name); if (otherUser) { removeRelation(relation->name); otherUser->relationManager.removeRelation(user->name); otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"%s选择和你离婚",user->name); otherUser->updateConsort(); } else { CRelation *tRelation = NULL; tRelation = (CRelation *)getEntryByName(relation->name); if (tRelation) writeOfflineNotify(tRelation); removeRelation(relation->name); } user->updateConsort(); } } break; case Cmd::RELATION_STATUS_PARA: { Cmd::stRelationStatusCmd *rev = (Cmd::stRelationStatusCmd *)pNullCmd; switch(rev->byState) { case Cmd::RELATION_ADD: { if (!strncmp(rev->name,user->name,MAX_NAMESIZE)) { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"不能把自己加入名单中?"); return true; } if (300>size()) { if (rev->type == Cmd::RELATION_TYPE_BAD) { addBadRelation(rev->name); } else { addEnemyRelation(rev->name); } } else { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"名单列表已满!"); } return true; } break; case Cmd::RELATION_ANSWER_NO: { UserSession *otherUser = NULL; otherUser = UserSessionManager::getInstance()->getUserByID(rev->userid); if (otherUser) { switch(rev->type) { case Cmd::RELATION_TYPE_FRIEND: { otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方不同意与你结为好友"); return true; } break; case Cmd::RELATION_TYPE_LOVE: { otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方不同意与你结为夫妻"); } break; default: break; } } } break; case Cmd::RELATION_ANSWER_YES: { UserSession *otherUser = NULL; otherUser = UserSessionManager::getInstance()->getUserByID(rev->userid); if (otherUser) { if (300>otherUser->relationManager.size()|| rev->type == Cmd::RELATION_TYPE_LOVE) { if (300>size() || rev->type == Cmd::RELATION_TYPE_LOVE) { addRelation(rev->userid,rev->type); otherUser->relationManager.addRelation(user->id,rev->type); if (rev->type != Cmd::RELATION_TYPE_LOVE) { otherUser->sendSysChat(Cmd::INFO_TYPE_ADDFRIEND,"你与 %s 义结金兰,成为好友",user->name); user->sendSysChat(Cmd::INFO_TYPE_ADDFRIEND,"你与 %s 义结金兰,成为好友",otherUser->name); } } else { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"我的好友列表已满"); otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方好友列表已满"); } } else { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方好友列表已满"); otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"你的好友列表已满"); } } } break; case Cmd::RELATION_QUESTION: //free 禁止好友功能 // user->sendSysChat(Cmd::INFO_TYPE_FAIL, "好友系统正在开 发中!"); // break; //#if 0 { if (!strncmp(rev->name,user->name,MAX_NAMESIZE)) { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"你在开玩笑吗?加自己为好友!"); return true; } CRelation *relation = NULL; relation = (CRelation *)getEntryByName(rev->name); if (relation) { if (!strncmp(rev->name,relation->name,MAX_NAMESIZE) && Cmd::RELATION_TYPE_BAD != relation->type) { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方已经在你的好友列表中了,无需再添加!"); return true; } } UserSession *otherUser = NULL; otherUser = UserSessionManager::getInstance()->getUserSessionByName(rev->name); if (otherUser) { if (isset_state(otherUser->sysSetting,Cmd::USER_SETTING_FRIEND)) { user->sendSysChat(Cmd::INFO_TYPE_GAME,"好友请求已发送,等待对方应答!"); rev->userid = user->id; strncpy(rev->name,user->name,MAX_NAMESIZE); otherUser->sendCmdToMe(rev,sizeof(Cmd::stRelationStatusCmd)); } else user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方添加好友未开启"); } else { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方不在线不能响应你的邀请"); } //#endif break; } case Cmd::RELATION_REMOVE: { CRelation *rel = NULL; rel = (CRelation *)getEntryByName(rev->name); if (!rel) return true; int type = rel->type; if (Cmd::RELATION_TYPE_BAD == type || Cmd::RELATION_TYPE_ENEMY == type) { removeRelation(rev->name); // 删除黑名单成员 } else { if (Cmd::RELATION_TYPE_LOVE == type) { user->sendSysChat(Cmd::INFO_TYPE_FAIL,"你必须到民政官那里去办理离婚手续!"); return true; } UserSession *otherUser = NULL; otherUser = UserSessionManager::getInstance()->getUserSessionByName(rev->name); if (otherUser) { removeRelation(rev->name); otherUser->relationManager.removeRelation(user->name); otherUser->sendSysChat(Cmd::INFO_TYPE_BREAKFRIEND,"%s选择与你割席断交",user->name); user->sendSysChat(Cmd::INFO_TYPE_BREAKFRIEND,"你选择与 %s 割席断交",otherUser->name); otherUser->updateConsort(); } else { user->sendSysChat(Cmd::INFO_TYPE_BREAKFRIEND,"你选择与 %s 割席断交",rev->name); CRelation *relation = NULL; relation = (CRelation *)getEntryByName(rev->name); if (relation) writeOfflineNotify(relation); removeRelation(rev->name); } user->updateConsort(); } } break; } return true; } break; default: break; } } break; default: break; } return false; }
inline void GMap0::init() { m_beta0 = addRelation("beta0") ; }
inline void GMap2::init() { m_beta2 = addRelation("beta2") ; }
bool DirtyListVisit::add(Feature* F) { if (DeletePass) return false; if (F->isDeleted()) return false; // TODO Needed to add children of updated imported features. Sure there is no advert cases? //if (!F->isDirty()) return false; // Allow "Force Upload" of OSM objects //if (F->hasOSMId()) return false; if (Future.willBeErased(F)) return EraseFromHistory; for (int i=0; i<AlreadyAdded.size(); ++i) if (AlreadyAdded[i] == F) return EraseResponse[i]; bool x; if (Node* Pt = CAST_NODE(F)) { if (Pt->isInteresting()) { if (F->hasOSMId()) x = updatePoint(Pt); else x = addPoint(Pt); AlreadyAdded.push_back(F); EraseResponse.push_back(x); return x; } else return EraseFromHistory; } else if (Way* R = dynamic_cast<Way*>(F)) { for (int i=0; i<R->size(); ++i) if (!R->getNode(i)->isVirtual()) if (!(R->get(i)->hasOSMId()) && notYetAdded(R->get(i))) add(R->get(i)); if (F->hasOSMId()) x = updateRoad(R); else x = addRoad(R); AlreadyAdded.push_back(F); EraseResponse.push_back(x); return x; } else if (Relation* Rel = dynamic_cast<Relation*>(F)) { for (int i=0; i<Rel->size(); ++i) if (!(Rel->get(i)->hasOSMId()) && notYetAdded(Rel->get(i))) add(Rel->get(i)); if (F->hasOSMId()) x = updateRelation(Rel); else x = addRelation(Rel); AlreadyAdded.push_back(F); EraseResponse.push_back(x); return x; } return EraseFromHistory; }
bool Network::addRelation(Node* node0, Node* node1){ return addRelation(node0, node1, false); }