bool World::sendMessage(SmartMessage & message, Component * sender) { bool anyReceiver = false; if(message->getEntityTargetType()) { // Intentamos conseguir una lista con todas las entidades que comparten un tipo determinado. std::string targetType(message->getEntityTargetType()); EntityStringTableIterator victim = _entitiesByType.find(targetType); if(victim != _entitiesByType.end()) { EntityListIterator i = victim->second.begin(); EntityListIterator end = victim->second.end(); if(message->getEntityTargetName()) { // Mandamos el mensaje a todas las entidades con un tipo y nombre determinado. std::string targetName(message->getEntityTargetName()); for(; i != end; ++i) { if((*i)->getName() == targetName) { anyReceiver = (*i)->sendMessage(message, sender) || anyReceiver; } } } else { // Mandamos el mensaje a todas las entidades con un tipo determinado. for(; i != end; ++i) { anyReceiver = (*i)->sendMessage(message, sender) || anyReceiver; } } } } else if(message->getEntityTargetName()) { // Intentamos conseguir una lista con todas las entidades que comparten un nombre determinado. std::string targetName(message->getEntityTargetName()); EntityStringTableIterator victim = _entitiesByName.find(targetName); if(victim != _entitiesByName.end()) { // Mandamos el mensaje a todas las entidades con un nombre determinado. EntityListIterator i = victim->second.begin(); EntityListIterator end = victim->second.end(); for(; i != end; ++i) { anyReceiver = (*i)->sendMessage(message, sender) || anyReceiver; } } } else { // Mandamos el mensaje a todas las entidades que han sido registradas. EntityIdTableIterator i = _entitiesById.begin(); EntityIdTableIterator end = _entitiesById.end(); for(; i != end; ++i) { anyReceiver = i->second->sendMessage(message, sender) || anyReceiver; } } return anyReceiver; }
PyType PyType::target() const { const std::string &typeName = name(); if (isPointerType(typeName) || isArrayType(typeName)) return lookupType(targetName(), m_module); return PyType(); }
MaemoGlobal::MaemoVersion MaemoGlobal::version(const QtVersion *qtVersion) { const QString &name = targetName(qtVersion); if (name.startsWith(QLatin1String("fremantle"))) return Maemo5; if (name.startsWith(QLatin1String("harmattan"))) return Maemo6; if (name.startsWith(QLatin1String("meego"))) return Meego; return static_cast<MaemoVersion>(-1); }
void VolumeGroupDialog::setupDialog() { QRegExp re(QStringLiteral("[\\w-.+]+")); QRegExpValidator *validator = new QRegExpValidator(re, this); dialogWidget().vgName().setValidator(validator); dialogWidget().vgName().setText(targetName()); dialogWidget().volumeType().addItem(QStringLiteral("LVM")); dialogWidget().volumeType().addItem(QStringLiteral("RAID")); dialogWidget().volumeType().setCurrentIndex(0); setMinimumSize(dialogWidget().size()); resize(dialogWidget().size()); }
int MakeCommand::execute() { const QString projectPathParameter = projectPath().isEmpty() ? QString() : QLatin1String(" -p ") + QLatin1String("'") + projectPath() + QLatin1String("'"); QString command = QLatin1String("mb2") + projectPathParameter + QLatin1String(" -t ") + targetName() + QLatin1Char(' ') + arguments().join(QLatin1String(" ")) + QLatin1Char(' '); MerRemoteProcess process; process.setSshParameters(sshParameters()); process.setCommand(remotePathMapping(command)); return process.executeAndWait(); }
/** * @brief Helpful method for testing purposes. * * Compares this target's members with @p other target's. * * @param[in] other target to compare with this target * @return true if equal, else false. */ bool Target::isEqual(const Target& other) const { if (targetId() != other.targetId()) { return false; } if (targetName() != other.targetName()) { return false; } int i = 0; int size = other.m_gestureRecognizers.size(); if(size != m_gestureRecognizers.size()) { return false; } for(i = 0; i < size; ++i) { if (!m_gestureRecognizers[i]->isEqual(*other.m_gestureRecognizers[i])) { return false; } } return true; }
void VolumeGroupDialog::setupDialog() { dialogWidget().vgName().setText(targetName()); dialogWidget().volumeType().addItem(QStringLiteral("LVM")); dialogWidget().volumeType().addItem(QStringLiteral("RAID")); dialogWidget().volumeType().setCurrentIndex(0); //update used size and LV infos qint32 totalLV = 0; QString vgname = dialogWidget().vgName().text(); if (!vgname.isEmpty()) { m_TotalUsedSize = LvmDevice::getAllocatedPE(vgname) * LvmDevice::getPeSize(vgname); QStringList lvlist = LvmDevice::getLVs(vgname); if (!lvlist.isEmpty() ) { totalLV = lvlist.count(); } } dialogWidget().totalUsedSize().setText(Capacity::formatByteSize(m_TotalUsedSize)); dialogWidget().totalLV().setText(QString::number(totalLV)); setMinimumSize(dialogWidget().size()); resize(dialogWidget().size()); }
bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) { player->PlayerTalkClass->ClearMenus(); std::string targetName(code); if (player->GetName() == targetName) { player->GetSession()->SendNotification("You can not challenge yourself"); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } Player* target = sObjectAccessor->FindPlayerByName(targetName); if (!target) { player->GetSession()->SendNotification("Challenged player not logged in"); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } if (player->GetGUID() == target->GetGUID()) { player->GetSession()->SendNotification("You can not challenge yourself"); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } if (target->GetZoneId() != player->GetZoneId()) { player->GetSession()->SendNotification("%s is not in same zone", target->GetName().c_str()); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } #if (USE_TOKEN == 1) if (!player->HasItemCount(TOKEN_ID, action)) { player->GetSession()->SendNotification("You do not have enough tokens"); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } if (!target->HasItemCount(TOKEN_ID, action)) { player->GetSession()->SendNotification("%s does not have enough tokens", target->GetName().c_str()); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } #else if (target->GetMoney() < action * GOLD) { player->GetSession()->SendNotification("%s does not have enough money", target->GetName().c_str()); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } if (player->GetMoney() < action * GOLD) { player->GetSession()->SendNotification("You do not have enough money"); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } #endif if (!bloodMoney.AddChallenger(target->GetGUIDLow(), player->GetGUIDLow(), action)) { player->GetSession()->SendNotification("One of you already challenged the other"); OnGossipSelect(player, creature, SENDER_CHALLENGE, GOSSIP_ACTION_INFO_DEF); return true; } creature->Whisper(player->GetName() + " has requested a Blood Money duel with you!", LANG_UNIVERSAL, target, true); player->CLOSE_GOSSIP_MENU(); return true; }
bool MakeCommand::isValid() const { return Command::isValid() && !targetName().isEmpty() ; }
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ) { QFileInfo f(destDir + "/" + targetName(buildType, exeName, version)); return f.exists(); }
/** scan the makefile -nd output */ static void GraphScan(GraphPtr graph,TargetPtr root,FILE* in) { char* line=NULL; char* makefile_name=NULL; while((line=readline(in))!=NULL) { if(startsWith(line,"Considering target file")) { char* tName=targetName(line); if(!graph->show_root && makefile_name!=NULL && strcmp(tName,makefile_name)==0) { free(tName); free(line); //skip lines while((line=readline(in))!=NULL) { if(startsWith(line,"Finished prerequisites of target file ")) { tName=targetName(line); free(line); if(strcmp(tName,makefile_name)==0) { free(tName); break; } free(tName); continue; } free(line); } continue; } TargetPtr child=GraphGetTarget(graph,tName); free(tName); TargetAddChildren(root,child); GraphScan(graph,child,in); } else if(startsWith(line,"Must remake target ")) { char* tName=targetName(line); GraphGetTarget(graph,tName)->must_remake=1; free(tName); } else if(startsWith(line,"Pruning file ")) { char* tName=targetName(line); TargetAddChildren(root,GraphGetTarget(graph,tName)); free(tName); } /* else if(startsWith(line,"Finished prerequisites of target file ")) { char* tName=targetName(line); if(strcmp(tName,root->name)!=0) { fprintf(stderr,"expected %s got %s\n", root->name , line); exit(EXIT_FAILURE); } free(tName); free(line); break; }*/ else if(startsWith(line,"Reading makefile ")) { free(makefile_name); makefile_name=targetName(line); } free(line); } free(makefile_name); }
void MainWindow::openFile() { if( !scene->items().isEmpty() ) { QMessageBox::warning(this, tr("Warning"), tr("All unsaved data will be lost!")); } QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("XML Files (*.xml)")); if(fileName != "") { scene->clearAllItems(); projectName.clear(); commands.clear(); TiXmlDocument doc; if(!doc.LoadFile(fileName.toStdString())) { QMessageBox::critical(this, tr("Error"), tr("Could not open file")); } TiXmlElement * pProjectElement = doc.FirstChildElement("project"); TiXmlElement * pNodeElement; if( pProjectElement == NULL ) { QMessageBox::critical(this, tr("Error"), tr("Could not parse file: <project> not found")); return; } pNodeElement = pProjectElement->FirstChildElement("name"); if( pNodeElement != NULL ) { projectName = QString(pNodeElement->GetText()); ui->projectEdit->setText(projectName); } std::map<QString, HEESGraphicsItem*> nameIndex; // First pass: add components for( pNodeElement = pProjectElement->FirstChildElement("comp"); pNodeElement != NULL; pNodeElement = pNodeElement->NextSiblingElement("comp")) { HEESGraphicsItem * item; QString type(pNodeElement->Attribute("type")); if( type == QString("cti") ) { item = new HEESGraphicsItem(CTI); } else if( type == QString("bank")) { item = new HEESGraphicsItem(BANK); } else if( type == QString("load") ) { item = new HEESGraphicsItem(LOAD); } else if( type == QString("source") ) { item = new HEESGraphicsItem(SOURCE); } else if( type == QString("converter") ) { // will be added in the second pass continue; } else if( type == QString("manager") ) { item = new HEESGraphicsItem(MANAGER); } else { continue; } QString xpos(pNodeElement->Attribute("x_pos")); QString ypos(pNodeElement->Attribute("y_pos")); if( !xpos.isEmpty() && !ypos.isEmpty() ) { item->setPos( xpos.toDouble(), ypos.toDouble() ); } TiXmlElement * pNameElement = pNodeElement->FirstChildElement("name"); if( pNameElement != NULL ) { item->name = QString(pNameElement->GetText()); } TiXmlElement * pDerivedElement = pNodeElement->FirstChildElement("derived"); if( pDerivedElement == NULL ) { QMessageBox::critical(this, tr("Error"), tr("Could not parse file: <derived> not found for component:")+item->name); scene->clearAllItems(); projectName.clear(); commands.clear(); return; } if( type != QString("cti") ) { item->derivedType = QString(pDerivedElement->Attribute("type")); } TiXmlElement * pElement; for( pElement = pDerivedElement->FirstChildElement(); pElement != NULL; pElement = pElement->NextSiblingElement() ) { item->myAttributes()->insertBack( pElement->Value(), pElement->GetText() ); } nameIndex[item->name] = item; scene->addItem(item); } // Second pass: add converters for( pNodeElement = pProjectElement->FirstChildElement("comp"); pNodeElement != NULL; pNodeElement = pNodeElement->NextSiblingElement("comp")) { HEESGraphicsItem * item; QString type(pNodeElement->Attribute("type")); if( type == QString("converter") ) { // will be added in the second pass item = new HEESGraphicsItem(CONVERTER); } else { continue; } QString xpos(pNodeElement->Attribute("x_pos")); QString ypos(pNodeElement->Attribute("y_pos")); if( !xpos.isEmpty() && !ypos.isEmpty() ) { item->setPos( xpos.toDouble(), ypos.toDouble() ); } TiXmlElement * pNameElement = pNodeElement->FirstChildElement("name"); if( pNameElement != NULL ) { item->name = QString(pNameElement->GetText()); } TiXmlElement * pDerivedElement = pNodeElement->FirstChildElement("derived"); if( pDerivedElement == NULL ) { QMessageBox::critical(this, tr("Error"), tr("Could not parse file: <derived> not found for component:")+item->name); scene->clearAllItems(); projectName.clear(); commands.clear(); return; } item->derivedType = QString(pDerivedElement->Attribute("type")); TiXmlElement * pElement; for( pElement = pDerivedElement->FirstChildElement(); pElement != NULL; pElement = pElement->NextSiblingElement() ) { item->myAttributes()->insertBack( pElement->Value(), pElement->GetText() ); } TiXmlElement * pElementA = pNodeElement->FirstChildElement("port_a"); TiXmlElement * pElementB = pNodeElement->FirstChildElement("port_b"); std::map<QString, HEESGraphicsItem*>::iterator it; if( pElementA != NULL && (it = nameIndex.find(QString(pElementA->GetText()))) != nameIndex.end() ) { if( it->second->myType() != CONVERTER && it->second->myType() != MANAGER ) item->setLeftItem(it->second); } if( pElementB != NULL && (it = nameIndex.find(QString(pElementB->GetText()))) != nameIndex.end() ) { if( it->second->myType() != CONVERTER && it->second->myType() != MANAGER ) item->setRightItem(it->second); } nameIndex[item->name] = item; scene->addItem(item); } // Thrid pass: add sensors for( pNodeElement = pProjectElement->FirstChildElement("sensor"); pNodeElement != NULL; pNodeElement = pNodeElement->NextSiblingElement("sensor") ) { QString target(pNodeElement->Attribute("target")); QString prop(pNodeElement->Attribute("property")); if( nameIndex.find(target) != nameIndex.end() ) { nameIndex[target]->mySensors()->insertBack(prop); } } // Fourth pass: add commands for( pNodeElement = pProjectElement->FirstChildElement("cmd"); pNodeElement != NULL; pNodeElement = pNodeElement->NextSiblingElement("cmd") ) { QString type(pNodeElement->Attribute("type")); double time; pNodeElement->Attribute("time", &time); if( type == QString("set") || type == QString("get") ) { QString targetName(pNodeElement->Attribute("target")); for(TiXmlElement * pElement = pNodeElement->FirstChildElement(); pElement != NULL; pElement = pElement->NextSiblingElement() ) { Command command; command.type = type; command.time = time; command.targetName = targetName; command.propertyName = QString(pElement->Value()); command.propertyValue = QString(pElement->GetText()); commands.insertBack(command); } } else if( type == QString("finish") || type == QString("sim") ) { Command command; command.type = type; command.time = time; commands.insertBack(command); } } } }