int pioReadAllNumbers(PIODataset dataset, int* number) { link_t* links = NULL; int tr; int sumNumber; // return expected length of @a number array if (!number) return dataset.ntimeranges; links = (link_t*) malloc(sizeof(link_t)*dataset.ntimeranges); if (getLinks(dataset, links) < 0) { free(links); return -1; } sumNumber = 0; for (tr=0; tr<dataset.ntimeranges; tr++) { number[tr] = links[tr].number; sumNumber += number[tr]; } free(links); return sumNumber; }
QVector<Structure::Node*> Structure::Graph::getNeighbourNodes( Node* node ) { QVector<Node*> neighbours; for (Link* l : getLinks(node->mID)) neighbours.push_back(l->getNodeOther(node->mID)); return neighbours; }
void Property::toggleInteractionMode(bool interactionmode, void* source) { if (!interactionModeVisited_) { interactionModeVisited_ = true; // propagate to owner if (getOwner() && (invalidationLevel_ != Processor::VALID)) { getOwner()->toggleInteractionMode(interactionmode, source); } // propagate over links for (size_t i=0; i<getLinks().size(); ++i) { Property* destProperty = getLinks()[i]->getDestinationProperty(); tgtAssert(destProperty, "Link without destination property"); destProperty->toggleInteractionMode(interactionmode, source); } interactionModeVisited_ = false; } }
QList<Datum*> InputHandler::getInputDatums() const { QList<Datum*> list; for (auto link : getLinks()) { Q_ASSERT(dynamic_cast<Datum*>(link->parent())); list << static_cast<Datum*>(link->parent()); } return list; }
bool CommonData::checkIni() { bool ret = true; if (ret) ret = this->checkFileExists(getBinDir()); if (!ret) { qFatal("Bin Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getImgDir()); if (!ret) { qFatal("Img Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getDocDir()); if (!ret) { qFatal("Doc Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getReportDir()); if (!ret) { qFatal("Reports Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getQrDir()); if (ret) ret = this->checkFileExists(getBiblioDir()); if (ret) ret = this->checkFileExists(getHtmlDir()); if (ret) ret = this->checkFileExists(getBlocknotesDir()); if (ret) ret = this->checkFileExists(getTexDir()); if (ret) ret = this->checkFileExists(getCollezione()); if (ret) ret = this->checkFileExists(getContenitori()); if (ret) ret = this->checkFileExists(getContatti()); if (ret) ret = this->checkFileExists(getBiblioteca()); if (ret) ret = this->checkFileExists(getLinks()); if (ret) ret = this->checkFileExists(getBackupDir()); return ret; }
void MSOffTrafficLightLogic::rebuildPhase() throw() { size_t no = getLinks().size(); std::string state; for (unsigned int i=0; i<no; ++i) { // !!! no brake mask! state += 'o'; } for (MSTrafficLightLogic::Phases::const_iterator i=myPhaseDefinition.begin(); i!=myPhaseDefinition.end(); ++i) { delete *i; } myPhaseDefinition.clear(); myPhaseDefinition.push_back(new MSPhaseDefinition(1, state)); }
CompiledMaterial MaterialEditorModel::compileMaterial() { if(getNodes().isEmpty()) { return material; } MaterialCompiler comp; Node *n = getNodes().first(); if(n) { if(comp.serialize(n, getLinks())) { material = comp.getCompiledMaterial(); QDataStream str(&material.data, QIODevice::WriteOnly); serialize(str); } else { qDebug(QString("Unable to compile material : error %1").arg(comp.getError()).toUtf8()); } } return material; }
void CNetwork::readInputFile() { // open the TRAF file FILE *file_trf = NULL; if (file_trf = fopen(m_traf_input_file, "r")) { sprintf(out_buf, "Opened file: \"%s\".", m_traf_input_file); OutputString(out_buf, strlen(out_buf), SIM_COLOR_RGB, RTE_MESSAGE_RGB); // parse the time periods processTimePeriods(file_trf); rewind(file_trf); // create the node list getNodes(file_trf); rewind(file_trf); // create the link list getLinks(file_trf); rewind(file_trf); // find the opposing link for each link, if one exists int up = 0; int down = 0; CLink *link = NULL; POSITION pos = m_link_list.GetHeadPosition(); while (pos != NULL) { link = m_link_list.GetNext(pos); up = link->getOpposingNodeId(); down = link->m_dn_node->getId(); CLink *opposing = NULL; opposing = findLink(up, down); link->setOpposingLink(opposing); } // create the lanes on each link createLanes(file_trf); rewind(file_trf); // NOTE: create here the signal timings for the nodes to be controlled by the algorithm, if you want // create the detectors that exist in the TRAF file getDetectors(file_trf); // close the stream fclose(file_trf); } }
void MaterialEditorModel::serialize(QDataStream &str) const { QList<Node *> nodes = getNodes(); QList<NodeLink *> lnks = getLinks(); int version = 1; str<<version; str<<nodes.size(); str<<lnks.size(); for(Node *n : nodes) { n->serialize(str); } for(NodeLink *l : lnks) { NodeOut *start = l->getStart(); NodeIn *end = l->getEnd(); str<<nodes.indexOf(start->getParent()); str<<nodes.indexOf(end->getParent()); str<<start->getParent()->getOuts().indexOf(start); str<<end->getParent()->getIns().indexOf(end); } }
#include "graph/node.h" #include "graph/datum.h" #include "graph/proxy.h" TEST_CASE("Link detection") { auto g = new Graph(); auto n = new Node("n", g); auto x = new Datum("x", "1.0", &PyFloat_Type, n); auto y = new Datum("y", Datum::SIGIL_CONNECTION + std::string("[__0.__0]"), &PyFloat_Type, n); auto z = new Datum("z", "n.x", &PyFloat_Type, n); REQUIRE(y->isValid()); REQUIRE(z->isValid()); auto links = y->getLinks(); REQUIRE(std::find(links.begin(), links.end(), x) != links.end()); REQUIRE(std::find(links.begin(), links.end(), z) == links.end()); } TEST_CASE("Link pruning on deletion") { auto g = new Graph(); auto n = new Node("n", g); auto x = new Datum("x", "1.0", &PyFloat_Type, n); auto y = new Datum("y", Datum::SIGIL_CONNECTION + std::string("[__0.__0]"), &PyFloat_Type, n); n->uninstall(x); REQUIRE(y->isValid() == true); REQUIRE(y->getLinks().size() == 0);
void HtmlHandler::getMusicInfo() { getInfomation(); getLinks(); emit signalMusicInfoGotten(music_info); }
void MSSOTLTrafficLightLogic::init(NLDetectorBuilder& nb) throw(ProcessError) { MSTrafficLightLogic::init(nb); if (isDecayThresholdActivated()) { decayThreshold = 1; } if (sensorsSelfBuilt) { //Building SOTLSensors switch (SENSORS_TYPE) { case SENSORS_TYPE_E1: assert(0); // Throw exception because TLS can only handle E2 sensors case SENSORS_TYPE_E2: //Adding Sensors to the ingoing Lanes LaneVectorVector lvv = getLaneVectors(); DBG( WRITE_MESSAGE("Listing lanes for TLS " + getID()); for (unsigned int i = 0; i < lvv.size(); i++) { LaneVector lv = lvv[i]; for (unsigned int j = 0; j < lv.size(); j++) { MSLane* lane = lv[j]; WRITE_MESSAGE(lane ->getID()); } } ) mySensors = new MSSOTLE2Sensors(myID, &(getPhases())); ((MSSOTLE2Sensors*)mySensors)->buildSensors(myLanes, nb, getInputSensorsLength()); mySensors->stepChanged(getCurrentPhaseIndex()); if (getParameter("USE_VEHICLE_TYPES_WEIGHTS", "0") == "1") { ((MSSOTLE2Sensors*) mySensors)->setVehicleWeigths(getParameter("VEHICLE_TYPES_WEIGHTS", "")); } //threshold speed param for tuning with irace ((MSSOTLE2Sensors*)mySensors)->setSpeedThresholdParam(getSpeedThreshold()); myCountSensors = new MSSOTLE2Sensors(myID + "Count", &(getPhases())); myCountSensors->buildCountSensors(myLanes, nb); myCountSensors->stepChanged(getCurrentPhaseIndex()); //Adding Sensors to the outgoing Lanes LinkVectorVector myLinks = getLinks(); DBG( WRITE_MESSAGE("Listing output lanes"); for (unsigned int i = 0; i < myLinks.size(); i++) { LinkVector oneLink = getLinksAt(i); for (unsigned int j = 0; j < oneLink.size(); j++) { MSLane* lane = oneLink[j]->getLane(); WRITE_MESSAGE(lane ->getID()); } } ) LaneVectorVector myLaneVector; LaneVector outLanes; LinkVectorVector myoutLinks = getLinks(); for (unsigned int i = 0; i < myLinks.size(); i++) { LinkVector oneLink = getLinksAt(i); for (unsigned int j = 0; j < oneLink.size(); j++) { MSLane* lane = oneLink[j]->getLane(); outLanes.push_back(lane); } } if (outLanes.size() > 0) { myLaneVector.push_back(outLanes); } if (myLaneVector.size() > 0) { ((MSSOTLE2Sensors*)mySensors)->buildOutSensors(myLaneVector, nb, getOutputSensorsLength()); myCountSensors->buildCountOutSensors(myLaneVector, nb); } }
bool Region::operator==(const Region &o) const { if (initialized_ != o.initialized_ || outputs_.size() != o.outputs_.size() || inputs_.size() != o.inputs_.size()) { return false; } if (name_ != o.name_ || type_ != o.type_ || spec_ != o.spec_ || phases_ != o.phases_ ) { return false; } if (getDimensions() != o.getDimensions()) { return false; } // Compare Regions's Input (checking only input buffer names and type) static auto compareInput = [](decltype(*inputs_.begin()) a, decltype(*inputs_.begin()) b) { if (a.first != b.first) { return false; } auto input_a = a.second; auto input_b = b.second; if (input_a->getDimensions() != input_b->getDimensions()) return false; if (input_a->isInitialized() != input_b->isInitialized()) return false; if (input_a->isInitialized()) { if (input_a->getData().getType() != input_b->getData().getType() || input_a->getData().getCount() != input_b->getData().getCount()) return false; } auto links_a = input_a->getLinks(); auto links_b = input_b->getLinks(); if (links_a.size() != links_b.size()) { return false; } for (size_t i = 0; i < links_a.size(); i++) { if (*(links_a[i]) != *(links_b[i])) { return false; } } return true; }; if (!std::equal(inputs_.begin(), inputs_.end(), o.inputs_.begin(), compareInput)) { return false; } // Compare Regions's Output (checking only output buffer names and type.) static auto compareOutput = [](decltype(*outputs_.begin()) a, decltype(*outputs_.begin()) b) { if (a.first != b.first ) { return false; } auto output_a = a.second; auto output_b = b.second; if (output_a->getDimensions() != output_b->getDimensions()) return false; if (output_a->getData().getType() != output_b->getData().getType() || output_a->getData().getCount() != output_b->getData().getCount()) return false; return true; }; if (!std::equal(outputs_.begin(), outputs_.end(), o.outputs_.begin(), compareOutput)) { return false; } return true; }
void EntityLinkRenderer::validate() { Vertex::List links; getLinks(links); m_entityLinks = VertexArray::swap(links); m_valid = true; }
QVector<QVector<QString> > Structure::Graph::findCycleBase() { QMap<QString, QSet<QString>> used; QMap<QString, QString> parent; QStack<QString> stack; QVector<QVector<QString>> cycles; for (Node* root_node : nodes) { QString root = root_node->mID; // Loop over the connected // components of the graph. if (parent.contains(root)) { continue; } // Free some memory in case of // multiple connected components. used.clear(); // Prepare to walk the spanning tree. parent[root] = root; used[root] = QSet<QString>(); stack.push(root); // Do the walk. It is a BFS with // a LIFO instead of the usual // FIFO. Thus it is easier to // find the cycles in the tree. while (!stack.isEmpty()) { QString current = stack.pop(); QSet<QString> currentUsed = used[current]; for (Link* e : getLinks(current)) { QString neighbor = e->getNodeOther(current)->mID; if (!used.contains(neighbor)) { // found a new node parent[neighbor] = current; QSet<QString> neighbourUsed; neighbourUsed << current; used[neighbor] = neighbourUsed; stack.push(neighbor); } else if (neighbor == current) { // found a self loop QVector<QString> cycle; cycle << current; cycles << cycle; } else if (!currentUsed.contains(neighbor)) { // found a cycle QSet<QString>& neighbourUsed = used[neighbor]; QVector<QString> cycle; cycle << neighbor; cycle << current; QString p = parent[current]; while (!neighbourUsed.contains(p)) { cycle << p; p = parent[p]; } cycle << p; cycles << cycle; neighbourUsed << current; } } } } return cycles; }
void PageItem::generateLinks(const QStringList &popplerPageLabels) { m_links.clear(); m_links = getLinks(m_popplerPage, popplerPageLabels); }