/** Unpacks a connect message. The id of the client is stored in this object, * and the list of tracks is used to set tracks that are not available on * the client to be 'unavailable' on the server. * \param pkt Enet packet. */ ConnectMessage::ConnectMessage(ENetPacket* pkt):Message(pkt, MT_CONNECT) { m_id = getString(); std::vector<std::string> all_tracks = getStringVector(); std::vector<std::string> all_karts = getStringVector(); track_manager->setUnavailableTracks(all_tracks); kart_properties_manager->setUnavailableKarts(all_karts); } // ConnectMessage
bool OptionsCont::isUsableFileList(const std::string &name) const throw(InvalidArgument) { Option *o = getSecure(name); // check whether the option is set // return false i not if (!o->isSet()) { return false; } // check whether the list of files is valid bool ok = true; std::vector<std::string> files = getStringVector(name); if (files.size()==0) { MsgHandler::getErrorInstance()->inform("The file list for '" + name + "' is empty."); ok = false; } for (std::vector<std::string>::const_iterator fileIt=files.begin(); fileIt!=files.end(); ++fileIt) { if (!FileHelpers::exists(*fileIt)) { if (*fileIt!="") { MsgHandler::getErrorInstance()->inform("File '" + *fileIt + "' does not exist."); ok = false; } else { MsgHandler::getWarningInstance()->inform("Empty file name given; ignoring."); } } } return ok; }
bool OptionsCont::isUsableFileList(const std::string& name) const { Option* o = getSecure(name); // check whether the option is set // return false i not if (!o->isSet()) { return false; } // check whether the list of files is valid bool ok = true; std::vector<std::string> files = getStringVector(name); if (files.size() == 0) { WRITE_ERROR("The file list for '" + name + "' is empty."); ok = false; } for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (!FileHelpers::isReadable(*fileIt)) { if (*fileIt != "") { WRITE_ERROR("File '" + *fileIt + "' is not accessible (" + std::strerror(errno) + ")."); ok = false; } else { WRITE_WARNING("Empty file name given; ignoring."); } } } return ok; }
unsigned int RData::getDataLength() const { if (datatype == RealVector) return (getRealVector ().size ()); if (datatype == IntVector) return (getIntVector ().size ()); if (datatype == StringVector) return (getStringVector ().size ()); if (datatype == StructureVector) return (getStructureVector ().size ()); return 0; }
void RData::printStructure (const QString &prefix) { switch (datatype) { case NoData: qDebug ("%s: NoData, length %d", prefix.toLatin1().data(), getDataLength ()); break; case IntVector: qDebug ("%s: IntVector, length %d", prefix.toLatin1().data(), getDataLength ()); for (unsigned int i = 0; i < getDataLength (); ++i) { qDebug ("%s%d: %d", prefix.toLatin1().data(), i, getIntVector ()[i]); } break; case RealVector: qDebug ("%s: RealVector, length %d", prefix.toLatin1().data(), getDataLength ()); for (unsigned int i = 0; i < getDataLength (); ++i) { qDebug ("%s%d: %f", prefix.toLatin1().data(), i, getRealVector ()[i]); } break; case StringVector: qDebug ("%s: StringVector, length %d", prefix.toLatin1().data(), getDataLength ()); for (unsigned int i = 0; i < getDataLength (); ++i) { qDebug ("%s%d: %s", prefix.toLatin1().data(), i, getStringVector ()[i].toLatin1().data()); } break; case StructureVector: qDebug ("%s: StructureVector, length %d", prefix.toLatin1().data(), getDataLength ()); for (unsigned int i = 0; i < getDataLength (); ++i) { QString sub_prefix = prefix + QString::number (i); getStructureVector ()[i]->printStructure (sub_prefix); } break; default: qDebug ("%s: INVALID %d, length %d", prefix.toLatin1().data(), datatype, getDataLength ()); } qDebug ("%s: END\n\n", prefix.toLatin1 ().data()); }
bool OptionsCont::isInStringVector(const std::string &optionName, const std::string &itemName) throw(InvalidArgument) { if (isSet(optionName)) { std::vector<std::string> values = getStringVector(optionName); return find(values.begin(), values.end(), itemName)!=values.end(); } return false; }
void function(std::string sInput/*std::vector< std::string > vsInput*/,std::map<std::string,int> mSpecies, std::vector< int >& viResult) { /** * La intención es que la input se divida en dos partes, puesto que solo llega dividida por -> * luego, es preciso detectar las especies indicadas para construir el vector y'-y el cual será * entregado en viResult, pasandolo por referencia, la idea es construiruna matriz de reacciones * tal como lo recomienda al artículo de Pablo Villosada de PLoS * */ std::vector<std::string> vsComplexBuffer; std::vector<std::string> vsLeftCompoundsBuffer; std::vector<std::string> vsRightCompoundsBuffer; std::vector<int> viReactants; std::vector<int> viProducts; viReactants.resize(viResult.size()); viProducts.resize(viResult.size()); int iStoichometricCoefficient=1; getStringVector("->",sInput,vsComplexBuffer); for(int i=0;i!=vsComplexBuffer.size();i++) { std::cout << vsComplexBuffer[i] << std::endl; } // for(int i=0;i!=vsComplexBuffer.size();i++) // { // getStringVector("+",vsComplexBuffer[i],vsCompoundsBuffer); // } getStringVector("+",vsComplexBuffer[0],vsRightCompoundsBuffer); // std::cout << "Right Add" << std::endl; getStringVector("+",vsComplexBuffer[1],vsLeftCompoundsBuffer); // std::cout << "Left Add" << std::endl; for(int i=0;i!=vsRightCompoundsBuffer.size();i++) { iStoichometricCoefficient = unStoichem(vsRightCompoundsBuffer[i]); viProducts[mSpecies.at(vsRightCompoundsBuffer[i])-1]=iStoichometricCoefficient; } for(int i=0;i!=vsLeftCompoundsBuffer.size();i++) { iStoichometricCoefficient = unStoichem(vsLeftCompoundsBuffer[i]); viReactants[mSpecies.at(vsLeftCompoundsBuffer[i])-1]=iStoichometricCoefficient; } for(int i=0;i!=viResult.size();i++) { viResult[i]=viProducts[i]-viReactants[i]; } std::cout << "\n"; for(int i=0;i!=viResult.size();i++) { std::cout << " " << viResult[i]; } std::cout << "\n"; }