void CheckFileSystemView::checkPath( const QString& path, Qt::CheckState state ) { QModelIndex index = m_fsModel->index(path); m_fsModel->setCheck(index, state); updateNode(index); }
void SceneGraphEditor::updateNode(SceneGraphNode* pnode, int uid, int xpos, int ypos) { feather::status e; unsigned int nid = feather::qml::command::get_node_id(uid,e); // if the node is already in the draw list, don't add a new one SceneGraphNode *node = getNode(uid); if(!node){ std::cout << "ADDING NODE TO SG EDITOR\n"; node = new SceneGraphNode(uid,nid,this); m_nodes.push_back(node); // setup the node qt connections connect(node,SIGNAL(ConnClicked(Qt::MouseButton,SceneGraphConnection::Connection,int,int)),this,SLOT(ConnOption(Qt::MouseButton,SceneGraphConnection::Connection,int,int))); connect(node,SIGNAL(nodePressed(Qt::MouseButton,int,int)),this,SLOT(nodePressed(Qt::MouseButton,int,int))); // place the node in the scenegraph node->setX(xpos); node->setY(ypos); // get the connected nodes std::vector<int> cuids; feather::qml::command::get_node_connected_uids(uid,cuids); // add a link for each connection between the two nodes int ystep=0; for(auto c : cuids) { // add the child node to draw list and get it's links updateNode(node, c, xpos+200, ypos+ystep); ystep+=node->height()+40; } }
void Grid::findAll(vector<int> &out, const IRect &view_rect, int flags) const { IRect grid_box(0, 0, m_size.x, m_size.y); for(int y = grid_box.min.y; y < grid_box.max.y; y++) { const int2 &row_rect = m_row_rects[y]; if(row_rect.x >= view_rect.max.y || row_rect.y <= view_rect.min.y) continue; for(int x = grid_box.min.x; x < grid_box.max.x; x++) { int node_id = nodeAt(int2(x, y)); const Node &node = m_nodes[node_id]; if(!flagTest(node.obj_flags, flags) || !areOverlapping(view_rect, node.rect)) continue; bool anything_found = false; const Object *objects[node.size]; int count = extractObjects(node_id, objects, -1, flags); for(int n = 0; n < count; n++) { if(areOverlapping(view_rect, objects[n]->rect())) { if(objects[n]->node_id == -1) disableOverlap(objects[n]); out.push_back(objects[n] - &m_objects[0]); anything_found = true; } } if(!anything_found && node.is_dirty) updateNode(node_id); } } clearDisables(); }
int Grid::pixelIntersect(const int2 &screen_pos, bool (*pixelTest)(const ObjectDef&, const int2&), int flags) const { IRect grid_box(0, 0, m_size.x, m_size.y); int best = -1; FBox best_box; for(int y = grid_box.min.y; y < grid_box.max.y; y++) { const int2 &row_rect = m_row_rects[y]; if(row_rect.x >= screen_pos.y || row_rect.y <= screen_pos.y) continue; for(int x = grid_box.min.x; x < grid_box.max.x; x++) { int node_id = nodeAt(int2(x, y)); const Node &node = m_nodes[node_id]; if(!flagTest(node.obj_flags, flags) || !node.rect.isInside(screen_pos)) continue; if(node.is_dirty) updateNode(node_id); const Object *objects[node.size]; int count = extractObjects(node_id, objects, -1, flags); for(int n = 0; n < count; n++) if(objects[n]->rect().isInside(screen_pos) && pixelTest(*objects[n], screen_pos)) { if(best == -1 || drawingOrder(objects[n]->bbox, best_box) == 1) { best = objects[n] - &m_objects[0]; best_box = objects[n]->bbox; } } } } return best; }
foreach (Device *device, myDevices()) { if (device->deviceClassId() == merkurNodeDeviceClassId) { updateNode(device); } else if(device->deviceClassId() == rplRouterDeviceClassId) { scanNodes(device); } }
void Grid::findAll(vector<int> &out, const FBox &box, int ignored_id, int flags) const { IRect grid_box = nodeCoords(box); for(int y = grid_box.min.y; y <= grid_box.max.y; y++) for(int x = grid_box.min.x; x <= grid_box.max.x; x++) { int node_id = nodeAt(int2(x, y)); const Node &node = m_nodes[node_id]; if(!flagTest(node.obj_flags, flags) || !areOverlapping(box, node.bbox)) continue; bool anything_found = false; const Object *objects[node.size]; int count = extractObjects(node_id, objects, ignored_id, flags); for(int n = 0; n < count; n++) if(areOverlapping(box, objects[n]->bbox)) { if(objects[n]->node_id == -1) disableOverlap(objects[n]); out.push_back(objects[n] - &m_objects[0]); anything_found = true; } if(!anything_found && node.is_dirty) updateNode(node_id); } clearDisables(); }
void CheckDirTree::checkPath( const QString& path, Qt::CheckState state ) { QModelIndex index = m_dirModel.index( path ); m_dirModel.setCheck( index, state ); updateNode( index ); }
int DiskMultiMap::erase(const std::string& key, const std::string& value, const std::string& context){ Header head; m_bf.read(head, 0); size_t hashedKey = hashKey(key); int index = hashToOffset(hashedKey); HashTableBucket bucket; m_bf.read(bucket, index); //read to proper bucket Node node; int address = bucket.m_start; int deletedBuckets = 0; while(address != -1){ m_bf.read(node, address); //go through bucket int nextIndex = node.m_next; string m_Key = node.m_key; string m_Value = node.m_value; string m_Context = node.m_context; if(m_Key == key && m_Value == value && m_Context == context){ deletedBuckets++; int temp = head.m_deleted; //keep track of the prior deleted node location head.m_deleted = address; //update the deleted location for the Header node.m_next = temp; //update the nodes next position updateNode(node, address); updateHeader(head); } address = nextIndex; } return deletedBuckets; }
unsigned SWProcess::add(IPropertyTree *params) { unsigned rc = SWComponentBase::add(params); IPropertyTree * envTree = m_envHelper->getEnvTree(); const char* key = params->queryProp("@key"); StringBuffer xpath; xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key); IPropertyTree * compTree = envTree->queryPropTree(xpath.str()); assert(compTree); const char* selector = params->queryProp("@selector"); if (selector) { String str(selector); if (str.startsWith("instance")) { addInstances(compTree, params); } else { // Following method can be overwritten. // For example, NodeGroup in BackupNodeProcess, EspBinding in EspProcess addOtherSelector(compTree, params); } } else { IPropertyTree* pAttrs = params->queryPropTree("Attributes"); updateNode(compTree, pAttrs); } return rc; }
/* Notes: * Updates a single node and reorders the PQueue * O(n) * could just simply swap the values. */ void reorder(PQueue q, Item vertex, int distance) { Node cur = q->head; Node pNode = NULL; // prioritised node int largestP = 0; // highest priority int updateNode(PQueue q, Item vertex, int newPriority); // updates a node with a new priority void swapNodes(PQueue q, Node n1, Node n2); if (vertex != NO_UPDATE && distance != NO_UPDATE){ // only update if the user wants to update if (!updateNode(q, vertex, distance)) { printf("Coulnd't find vertex in queue.\n"); } // update a vertex with a new priority queue } if (cur != NULL){ while (cur != NULL){ if (cur->p > largestP){ pNode = cur; largestP = cur->p; } cur = cur->next; } if (pNode != q->head && pNode != NULL){ swapNodes(q, q->head, pNode); } } }
unsigned SWBackupNode::add(IPropertyTree *params) { unsigned rc = SWProcess::add(params); IPropertyTree * envTree = m_envHelper->getEnvTree(); const char* key = params->queryProp("@key"); StringBuffer xpath; xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key); IPropertyTree * compTree = envTree->queryPropTree(xpath.str()); assert(compTree); const char* selector = params->queryProp("@selector"); if (selector && !stricmp("NodeGroup", selector)) { IPropertyTree *nodeGroup = createPTree(selector); IPropertyTree* pAttrs = params->queryPropTree("Attributes"); updateNode(nodeGroup, pAttrs, NULL); if (!nodeGroup->hasProp("@interval")) { xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"NodeGroup\"]/xs:complexType/xs:attribute[@name=\"interval\"]/@default"); const char *interval = m_pSchema->queryProp(xpath.str()); if ( interval && *interval ) { nodeGroup->addProp("@interval", interval); } else { throw MakeStringException(CfgEnvErrorCode::MissingRequiredParam, "Missing required paramter \"interval\" and there is no default value."); } } compTree->addPropTree(selector, nodeGroup); } return rc; }
void WTools::receiveComponentAction(const DataHeader &data) { if(data.getAction() == DataHeader::TOOL_UPDATE_ITEM) { int index = data.getResultToString().toInt(); updateNode(index); } }
void SWBackupNode::addOtherSelector(IPropertyTree *compTree, IPropertyTree *params) { StringBuffer xpath; assert(compTree); const char* selector = params->queryProp("@selector"); if (selector && !stricmp("NodeGroup", selector)) { IPropertyTree *nodeGroup = createPTree(selector); IPropertyTree* pAttrs = params->queryPropTree("Attributes"); updateNode(nodeGroup, pAttrs, NULL); if (!nodeGroup->hasProp("@interval")) { xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"NodeGroup\"]/xs:complexType/xs:attribute[@name=\"interval\"]/@default"); const char *interval = m_pSchema->queryProp(xpath.str()); if ( interval && *interval ) { nodeGroup->addProp("@interval", interval); } else { throw MakeStringException(CfgEnvErrorCode::MissingRequiredParam, "Missing required paramter \"interval\" and there is no default value."); } } compTree->addPropTree(selector, nodeGroup); } }
CheckDirTree::CheckDirTree( QWidget* parent ) : QTreeView( parent ) { m_dirModel.setFilter( QDir::Dirs | QDir::NoDotAndDotDot ); m_dirModel.setRootPath( "/" ); m_dirModel.setNameFilters( QStringList() << "[^\\.]*" ); setModel( &m_dirModel ); setColumnHidden( 1, true ); setColumnHidden( 2, true ); setColumnHidden( 3, true ); //header()->hide(); connect( &m_dirModel, SIGNAL( dataChangedByUser( QModelIndex ) ), SLOT( updateNode( QModelIndex ) ) ); connect( &m_dirModel, SIGNAL( dataChangedByUser( const QModelIndex& ) ), SIGNAL( changed() ) ); connect( &m_dirModel, SIGNAL( modelReset() ), SLOT( modelReset() ) ); connect( this, SIGNAL( collapsed( QModelIndex ) ), SLOT( onCollapse( QModelIndex ) ) ); connect( this, SIGNAL( expanded( QModelIndex ) ), SLOT( onExpand( QModelIndex ) ) ); }
void traverse() { mEditor.pushCurrentContext(); updateNode(); for(bool exists = mEditor.gotoFirstChild(); exists; exists = mEditor.gotoNextSibling()) traverse(); mEditor.popCurrentContext(); }
bool TraceListIO::update(const Trace::TracePointerVector& i_traceVector) { clear(); pugi::xml_node traceNode; for (auto trace : i_traceVector) { LOG_DEBUG("Update a trace from TraceListIO"); traceNode = addTraceNode(trace); updateNode(&traceNode, trace); } return true;; }
NodeModel::NodeModel(QObject *parent) : QAbstractListModel(parent), m_qmlNode(0) { Settings *s = Settings::get(); m_nodes = s->nodes(); connect(s, SIGNAL(nodeAdded(Node)), this, SLOT(addNode(Node))); connect(s, SIGNAL(nodeUpdated(Node)), this, SLOT(updateNode(Node))); }
void OSGNode::componentComplete() { // qDebug() << "OSGNode::componentComplete" << this; updateNode(); clearDirty(); h->complete = true; if (!h->node.valid()) { qWarning() << "OSGNode::componentComplete - node is not valid!" << this; } }
int main() { LinkList l; l = init(5); printLink(l); insertEle(l, 6, 10); printLink(l); delNode(l, 2); printLink(l); updateNode(l, 5, 22); printLink(l); return 0; }
osg::Group* GridVisualizationBase::getNodeForItem ( envire::EnvironmentItem* item ) const { osg::ref_ptr<osg::Group> group = new osg::Group(); osg::ref_ptr<osg::Geode> geode = new osg::Geode(); // apply transparency geode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); osg::BlendFunc* bf = new osg::BlendFunc( osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA ); geode->getOrCreateStateSet()->setAttributeAndModes(bf); group->addChild(geode.get()); updateNode ( item, group); return group.release(); }
/** * @brief Create a file * * Help from FUSE: * * This is called for creation of all non-directory, non-symlink nodes. * If the filesystem defines a create() method, then for regular files that will be called instead. * * @param path file path * @param mode creation mode * @param device device where the device will be created (contains both major and minor numbers) * @return 0 on success and <0 on error **/ static int my_mknod(const char *path, mode_t mode, dev_t device) { char modebuf[10]; mode_string(mode, modebuf); fprintf(stderr, "--->>>my_mknod: path %s, mode %s, major %d, minor %d\n", path, modebuf, (int)MAJOR(device), (int)MINOR(device)); // We check that the length of the file name is correct if(strlen(path + 1) > myFileSystem.superBlock.maxLenFileName) { return -ENAMETOOLONG; } // There exist an available inode if(myFileSystem.numFreeNodes <= 0) { return -ENOSPC; } // There is still space for a new file if(myFileSystem.directory.numFiles >= MAX_FILES_PER_DIRECTORY) { return -ENOSPC; } // The directory exists if(findFileByName(&myFileSystem, (char *)path + 1) != -1) return -EEXIST; /// Update all the information in the backup file: int idxNodoI, idxDir; if((idxNodoI = findFreeNode(&myFileSystem)) == -1 || (idxDir = findFreeFile(&myFileSystem)) == -1) { return -ENOSPC; } // Update root folder myFileSystem.directory.files[idxDir].freeFile = false; myFileSystem.directory.numFiles++; strcpy(myFileSystem.directory.files[idxDir].fileName, path + 1); myFileSystem.directory.files[idxDir].nodeIdx = idxNodoI; myFileSystem.numFreeNodes--; // Fill the fields of the new inode if(myFileSystem.nodes[idxNodoI] == NULL) myFileSystem.nodes[idxNodoI] = malloc(sizeof(NodeStruct)); myFileSystem.nodes[idxNodoI]->fileSize = 0; myFileSystem.nodes[idxNodoI]->numBlocks = 0; myFileSystem.nodes[idxNodoI]->modificationTime = time(NULL); myFileSystem.nodes[idxNodoI]->freeNode = false; reserveBlocksForNodes(&myFileSystem, myFileSystem.nodes[idxNodoI]->blocks, 0); updateDirectory(&myFileSystem); updateNode(&myFileSystem, idxNodoI, myFileSystem.nodes[idxNodoI]); return 0; }
void LinearCheckNodeUpdater::update(MultiVector<float> & messages) { uint32_t N_nodes = messages.size(); assert(N_nodes == m_checkNodesPriorLogPmQ.size()); // for each check node for (uint32_t node_ind = 0; node_ind < N_nodes; node_ind++) { updateNode(node_ind, messages); } }
/** * @brief Write data on an opened file * * Help from FUSE * * Write should return exactly the number of bytes requested except on error. * * @param path file path * @param buf buffer where we have data to write * @param size quantity of bytes to write * @param offset offset over the writing * @param fi FUSE structure linked to the opened file * @return 0 on success and <0 on error **/ static int my_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { char buffer[BLOCK_SIZE_BYTES]; // 1 bloque de caracteres. int bytes2Write = size, totalWrite = 0; NodeStruct *node = myFileSystem.nodes[fi->fh]; // fh==File handle. May be filled in by filesystem in open(). fprintf(stderr, "--->>>my_write: path %s, size %zu, offset %jd, fh %"PRIu64"\n", path, size, (intmax_t)offset, fi->fh); // Increase the file size if it is needed if(resizeNode(fi->fh, size + offset) < 0) return -EIO; // Write data while(bytes2Write) { int i; int currentBlock, offBloque; currentBlock = node->blocks[offset / BLOCK_SIZE_BYTES]; offBloque = offset % BLOCK_SIZE_BYTES; // posicionas el cursor del archivo en el bloque + offset. // lees un bloque entero empezando en esa posición. SI alguno de los dos falla exit. if((lseek(myFileSystem.fdVirtualDisk, currentBlock * BLOCK_SIZE_BYTES, SEEK_SET) == (off_t) - 1) || (read(myFileSystem.fdVirtualDisk, &buffer, BLOCK_SIZE_BYTES) == -1)) { perror("Failed lseek/read in my_write"); return -EIO; } // Desde el punto inicial del offset, hasta el final del bloque, escribes la información // del buf (texto que nos pasan en la función) en el buffer. for(i = offBloque; (i < BLOCK_SIZE_BYTES) && (totalWrite < size); i++) { buffer[i] = buf[totalWrite++]; } // GUardas el buffer con la información modificada en el archivo indicado en el descriptor físico. if((lseek(myFileSystem.fdVirtualDisk, currentBlock * BLOCK_SIZE_BYTES, SEEK_SET) == (off_t) - 1) || (write(myFileSystem.fdVirtualDisk, &buffer, BLOCK_SIZE_BYTES) == -1)) { perror("Failed lseek/write in my_write"); return -EIO; } // Discont the written stuff bytes2Write -= (i - offBloque); offset += i; } sync(); node->modificationTime = time(NULL); updateSuperBlock(&myFileSystem); updateBitmap(&myFileSystem); updateNode(&myFileSystem, fi->fh, node); return size; }
static void nodeInsertAction( Process::MessageNode& node, State::MessageList& msg, const Id<Process::ProcessModel>& proc, ProcessPosition pos ) { auto it = msg.begin(); auto end = msg.end(); while(it != end) { const auto& mess = *it; if(match(node, mess)) { switch(pos) { case ProcessPosition::Previous: { updateNode(node.values.previousProcessValues, mess.value, proc); break; } case ProcessPosition::Following: { updateNode(node.values.followingProcessValues, mess.value, proc); break; } default: ISCORE_ABORT; break; } it = msg.erase(it); } else { ++it; } } }
bool DiskMultiMap::insert(const std::string& key, const std::string& value, const std::string& context){ if(key.size() > 120 || value.size() > 120 || context.size() > 120){ return false; } MultiMapTuple tuple; tuple.key = key; tuple.value = value; tuple.context = context; Node nodeToAdd(tuple); int lastNode = -1; //this is to track the deleted nodes size_t index_hash = hashKey(key); int bucketIndex = hashToOffset(index_hash); HashTableBucket bucket; m_bf.read(bucket, bucketIndex); Header head; m_bf.read(head, 0); string k = nodeToAdd.m_key; string v = nodeToAdd.m_value; string c = nodeToAdd.m_context; if(head.m_deleted == -1){ lastNode = head.m_tail; head.m_tail += sizeof(Node); }else{ lastNode = head.m_deleted; Node newNode; m_bf.read(newNode, head.m_deleted); head.m_deleted = newNode.m_next; } nodeToAdd.m_next = bucket.m_start; bucket.m_start = lastNode; updateBucket(bucket, bucketIndex); if(!updateHeader(head)){ return false; } if(updateNode(nodeToAdd, lastNode)){ return true; }else{ return false; } }
void SWProcess::addOtherSelector(IPropertyTree *compTree, IPropertyTree *params) { const char* selector = params->queryProp("@selector"); IPropertyTree* selectorTree = compTree->queryPropTree(selector); if (!selectorTree) { selectorTree = createPTree(selector); compTree->addPropTree(selector, selectorTree); } IPropertyTree* pAttrs = params->queryPropTree("Attributes"); if (pAttrs) updateNode(selectorTree, pAttrs); }
void add(node **ptr,T data){ if(*ptr == NULL){ node *q = (node*)malloc(sizeof(node)); q->left = NULL; q->right = NULL; q->data = data; q->bFactor = 0; q->height = 0; *ptr = q; return ; } else if(data < (*ptr)->data) add(&((*ptr)->left),data); else add(&((*ptr)->right),data); updateNode(*ptr); if((*ptr)->bFactor > 1){ node *q = (*ptr)->left; if(height(q->left) > height(q->right)) *ptr = LeftLeftRotate(*ptr); else *ptr = RightLeftRotate(*ptr); } else if((*ptr)->bFactor < -1){ node *q = (*ptr)->right; if(height(q->right) > height(q->left)) *ptr = RightRightRotate(*ptr); else *ptr = LeftRightRotate(*ptr); } else return ; updateNode(*ptr); updateNode((*ptr)->left); updateNode((*ptr)->right); }
void LinearCheckNodeUpdater::update(MultiVector<BipartiteBP::QLLR> & messages) { uint32_t N_nodes = messages.size(); assert(N_nodes == m_checkNodesPriorQLLR.size()); #ifdef SUPER_VERBOSE std::cout << "Check Node NEW ITERATION *******" << std::endl; #endif // for each check node for (uint32_t node_ind = 0; node_ind < N_nodes; node_ind++) { updateNode(node_ind, messages); } }
int main(void) { puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */ LinkList l; l = init(5); printLink(l); insertEle(l, 6, 10); printLink(l); delNode(l, 2); printLink(l); updateNode(l, 6, 22); printLink(l); printf("this is a test for list by c./n"); return EXIT_SUCCESS; }
void ChunkManager::update() { if (!planetList.empty()) { timeNow = Planet::getTimer().getMilliseconds(); std::list<Planet*>::iterator i; for (i = planetList.begin(); i != planetList.end(); ++i) { Planet *planet = *i; expirationTime = planet->getChunkLoader()->getExpirationTime(); for (Ogre::uint32 o = 0; o < 6; ++o) { updateNode(planet->getCubeFace(o)); } } } }