Пример #1
0
void drawChildren(Status *parent, Status *all, int level)
{
    Status *ap = rewindStatus(all);

    while (ap) {

        if (ap->ppid == parent->pid && ap != parent) {

            levelPadding(level);

            if (hasChildren(ap)) {
            	pParent(ap);
                drawChildren(ap, all, level + 1);
            } else {
            	pChild(ap);
            }
        }

        ap = ap->next;
    }
}
Пример #2
0
void
ElemLiteralResult::postConstruction(
			StylesheetConstructionContext&	constructionContext,
			const NamespacesHandler&		theParentHandler)
{
	if (m_avtsCount != 0 ||
		getNamespacesHandler().getNamespaceDeclarationsCount() != 0)
	{
		canGenerateAttributes(true);
	}
	else
	{
		// OK, let's turn this off and see what our
		// base classes say about it when we chain up...
		canGenerateAttributes(false);
	}

	// OK, now we can chain-up...
	ElemUse::postConstruction(constructionContext, theParentHandler);

	// OK, now let's do some more checking to see if we'll
	// generate attributes...
	if (canGenerateAttributes() == false)
	{
		// If there are no children, we can't generate any attributes...
		if (hasChildren() == true)
		{
			assert(getFirstChildElem() != 0);

			// If there's a single text child, or the first child
			// is another LRE, then we won't generate any attributes.
			// Otherwise, we might...
			if (hasSingleTextChild() == false &&
				getFirstChildElem()->getXSLToken() != StylesheetConstructionContext::ELEMNAME_LITERAL_RESULT)
			{
				canGenerateAttributes(true);
			}
		}
	}
}
Пример #3
0
// -------------------------------------------------------------------------------
QModelIndex CCollectionModel::findChildWithDescription( QModelIndex parentIndex,
                                                        QString sData ) const
// -------------------------------------------------------------------------------
{
   Q_ASSERT( NULLPTR != mpCollection );
   if ( !mpCollection )
      return QModelIndex();


   if ( !hasChildren(parentIndex) )
      return QModelIndex();

   QModelIndex x;
   for ( int iRow = 0; iRow < rowCount( parentIndex ); iRow++ )
   {
      x = index( iRow, 0, parentIndex );
      if ( x.isValid() && (getIEDescription(x) == sData) )
         return x;
   }

   return QModelIndex();
}
Пример #4
0
int kwait(int *status) {
    int cid;
    PROC *ptr;
    
    if (hasChildren(running) == 0) {
	printf("Warning: No children.\n");
	return(-1);
    }
    
    //printf("Finding zombies...\n");
    while (1) {
	for (cid=1; cid<NPROC; cid++) {
	    ptr = &proc[cid];
	    
	    // find ZOMBIE child
	    if (ptr->status == ZOMBIE &&
		ptr->ppid == running->pid) {
		//printf("Found zombie %d\n", ptr->pid);
		
		//copy child's exitValue to *status
		*status = ptr->exitCode;
		
		//free the ZOMBIE child PROC
		ptr->status = FREE;
		ptr->ppid = 0;
		ptr->parent = 0;
		ptr->priority = 0;
		ptr->exitCode = 0;
		enqueue(&freeList, ptr);
		
		//return dead child's pid
		return(cid);
	    }
	}
	
	//printf("sleeping...\n");
	ksleep(running);
    }
}
Пример #5
0
Файл: t.c Проект: shank8/CS460
int wait(int * status){
  /* int wait(status) int *status;
           {
              if (no child)
                 return -1 for ERROR;
              while(1){
                 if (found a ZOMBIE child){
                    copy child's exitValue to *status;
                    free the ZOMBIE child PROC;
                    return dead child's pid;
                 }
                 sleep(running);    // sleep at its own &PROC
              }
            }*/
      PROC * zombie = 0;
    
      

      if(!hasChildren(running)){
       
        return -1;
      }

      while(1){
        zombie = getZombieChild(running);
        if(zombie != 0){
          printf("FOUND ZOMBIE.. KILLING PROC %d with exitValue %d\n", zombie->pid, zombie->exitValue);
          *status = zombie->exitValue;
          // free the ZOMBIE CHILD PROC ???
          zombie->status = FREE;
          enqueue(zombie, &freeList);

          return zombie->pid;
        }

      
        sleep(running); // sleep on its own address
      }
}
Пример #6
0
void CSMWorld::IdTree::setNestedTable(const QModelIndex& index, const CSMWorld::NestedTableWrapperBase& nestedTable)
{
    if (!hasChildren(index))
        throw std::logic_error("Tried to set nested table, but index has no children");

    bool removeRowsMode = false;
    if (nestedTable.size() != this->nestedTable(index)->size())
    {
        emit resetStart(this->index(index.row(), 0).data().toString());
        removeRowsMode = true;
    }

    mNestedCollection->setNestedTable(index.row(), index.column(), nestedTable);

    emit dataChanged (CSMWorld::IdTree::index (index.row(), 0),
                      CSMWorld::IdTree::index (index.row(), idCollection()->getColumns()-1));

    if (removeRowsMode)
    {
        emit resetEnd(this->index(index.row(), 0).data().toString());
    }
}
Пример #7
0
void
LiNode::postprocess() {

    // If a branch
    if(hasChildren()) {
        // Process children first
        for( int i = 0; i < 8; i++) {
            child(i)->postprocess();
        }
        // Sum children SH coefficients
        // TODO: Later

    // If a leaf
    }else{
        //printf("SURF: %d\n", _surfelCount);
        if(_surfelCount == 0) {
            return;
        }

        assert(_surfelData[0] != NULL);

        // Process lighting using surfel list
        vector<shared_ptr<Surfel> > surf_list;
        for(int i = 0; i < _surfelCount; i++) {
            
            surf_list.push_back(shared_ptr<Surfel>());
            surf_list[i] = _surfelData[i];
            assert(_surfelData[i] != NULL);
        }
        light::sh::SHProject(surf_list, 2, sh_c);

        assert(_surfelData[0] != NULL);
        /*
        printf("NODE FINISHED:\n\t%s \n\t%s \n\t%s \n\t%s \n\t%s \n\t%s \n\t%s \n\t%s \n\t%s\n",
                sh_c[0].str(),sh_c[1].str(),sh_c[2].str(),sh_c[3].str(),sh_c[4].str(),sh_c[5].str(),sh_c[6].str(),sh_c[7].str(),sh_c[8].str());
        //* */
    }
}
bool PointsFileSystem::setData(const QModelIndex &index, const QVariant &value, int role)
{
    bool is_point_cloud = (filePath(index).right(3) == "pcd");
    if(role == Qt::CheckStateRole)
    {
        if (is_point_cloud)
        {
            if(value == Qt::Checked)
                showPointCloud(index);
            else
                hidePointCloud(index);
        }

        if(hasChildren(index) == true)
            recursiveCheck(index, value);

        emit dataChanged(index, index);

        return true;
    }

    return FileSystemModel::setData(index, value, role);
}
Пример #9
0
Qt::ItemFlags BookmarksModel::flags(const QModelIndex &index) const
{
    if (!index.isValid())
        return Qt::NoItemFlags;

    BookmarkNode *node = this->node(index);
    BookmarkNode::Type type = node->type();
    Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;

    if (hasChildren(index))
        flags |= Qt::ItemIsDropEnabled;

    if (node == m_bookmarksManager->menu()
            || node == m_bookmarksManager->toolbar())
        return flags;

    flags |= Qt::ItemIsDragEnabled;

    if ((index.column() == 0 && type != BookmarkNode::Separator)
            || (index.column() == 1 && type == BookmarkNode::Bookmark))
        flags |= Qt::ItemIsEditable;

    return flags;
}
Пример #10
0
bool DhQAbstractTableModel::DvhhasChildren() const {
  return hasChildren();
}
Пример #11
0
bool DhQAbstractTableModel::DvhhasChildren(const QModelIndex& x1) const {
  return hasChildren(x1);
}
Пример #12
0
void SystemInitProcess(int init_fd, int child_pid, int proc_fd, int null_fd) {
  int ret = 0;

  // CLONE_NEWPID doesn't adjust the contents of the "/proc" file system.
  // This is very confusing. And it is even possible the kernel developers
  // will consider this a bug and fix it at some point in the future.
  // So, to be on the safe side, we explicitly retrieve our process id
  // from the "/proc" file system. This should continue to work, even if
  // the kernel eventually gets fixed so that "/proc" shows the view from
  // inside of the new pid namespace.
  pid_t init_pid = getProcessStatus(proc_fd, "self", "Pid");
  if (init_pid <= 0) {
    fprintf(stderr,
            "Failed to determine real process id of new \"init\" process\n");
    _exit(1);
  }

  // Redirect stdio to /dev/null
  if (null_fd < 0 ||
      dup2(null_fd, 0) != 0 ||
      dup2(null_fd, 1) != 1 ||
      dup2(null_fd, 2) != 2) {
    fprintf(stderr, "Failed to point stdio to a safe place\n");
    _exit(1);
  }
  close(null_fd);

  // Close all file handles
  int fds_fd = openat(proc_fd, "self/fd", O_RDONLY | O_DIRECTORY);
  DIR *dir = fds_fd >= 0 ? fdopendir(fds_fd) : NULL;
  if (dir == NULL) {
    // If we don't know the list of our open file handles, just try closing
    // all valid ones.
    for (int fd = sysconf(_SC_OPEN_MAX); --fd > 2; ) {
      if (fd != init_fd && fd != proc_fd) {
        close(fd);
      }
    }
  } else {
    // If available, it is much more efficient to just close the file
    // handles that show up in "/proc/self/fd/"
    struct dirent de, *res;
    while (!readdir_r(dir, &de, &res) && res) {
      if (res->d_name[0] < '0')
        continue;
      int fd = atoi(res->d_name);
      if (fd > 2 && fd != init_fd && fd != proc_fd && fd != dirfd(dir)) {
        close(fd);
      }
    }
    closedir(dir);
  }

  // Set up signal handler to catch SIGCHLD, but mask the signal for now
  sigset_t mask;
  sigemptyset(&mask);
  sigaddset(&mask, SIGCHLD);
  sigprocmask(SIG_BLOCK, &mask, NULL);

  // Notify other processes that we are done initializing
  if (write(init_fd, " ", 1)) { }
  close(init_fd);

  // Handle dying processes that have been re-parented to the "init" process
  for (;;) {
    bool retry = false;
    do {
      for (;;) {
        // Reap all exit codes of our child processes. This includes both
        // processes that originally were our immediate children, and processes
        // that have since been re-parented to be our children.
        int status;
        pid_t pid = waitpid(0, &status, __WALL | WNOHANG);
        if (pid <= 0) {
          break;
        } else {
          // We found some newly deceased child processes. Better schedule
          // another very thorough inspection of our state.
          retry = false;
        }
        if (pid == child_pid) {
          // If our first immediate child died, remember its exit code. That's
          // the exit code that we should be reporting to our parent process
          if (WIFEXITED(status)) {
            ret = WEXITSTATUS(status);
          } else if (WIFSIGNALED(status)) {
            ret = -WTERMSIG(status);
          }
        }
      }
      if (hasChildren(proc_fd, init_pid)) {
        // As long as we still have child processes, continue waiting for
        // their ultimate demise.
        retry = false;
      } else {
        if (retry) {
          // No more child processes. We can exit now.
          if (ret < 0) {
            // Try to exit with the same signal that our child terminated with
            signal(-ret, SIG_DFL);
            kill(1, -ret);
            ret = 1;
          }
          // Exit with the same exit code that our child exited with
          _exit(ret);
        } else {
          // There is a little bit of a race condition between getting
          // notifications and scanning the "/proc" file system. This is
          // particularly true, because scanning "/proc" cannot possibly be
          // an atomic operation.
          // If we find that we no longer appear to have any children, we check
          // one more time whether there are any children we can now reap.
          // They might have died while we were scanning "/proc" and if so,
          // they should now show up.
          retry = true;
        }
      }
    } while (retry);

    // Wait until we receive a SIGCHLD signal. Our signal handler doesn't
    // actually need to do anything, though
    sigwaitinfo(&mask, NULL);
  }
}
QModelIndexList SamaelItemModel::match(const QModelIndex &start, int role, const QVariant &value, int hits /*= 1*/, Qt::MatchFlags flags /*= Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap ) */) const
{
    QModelIndexList result;

    uint paramMatchType = flags & 0x0F;
    Qt::CaseSensitivity paramCaseSensitvity = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
    bool paramMatchRecursive = flags & Qt::MatchRecursive;
    bool paramMatchWrap = flags & Qt::MatchWrap;
    bool paramAllHits = (hits == -1);

    QModelIndex p = parent(start);
    int from = start.row();
    int to = rowCount(p);

    QString text; ///< only convert to a string if it is needed

    for (int i = 0; (!paramMatchWrap && i < 1) || (paramMatchWrap && i < 2); ++i) ///< iterates twice if wrapping and once if not
    {
        for (int r = from; (r < to) && (paramAllHits || result.count() < hits); ++r) ///< takes care to meet the hit count
        {
            QModelIndex idx = index(r, start.column(), p);

            if (!idx.isValid())
                continue;

            QVariant v = data(idx, role);

            if (paramMatchType == Qt::MatchExactly) ///< variant based matching
            { 
                if (value == v)
                    result.append(idx);
            } 
            else ///< string based matching
            {
                if (text.isEmpty()) ///< lazy conversion
                    text = value.toString();

                QString t = v.toString();

                switch (paramMatchType) ///< string based matching by match type
                {
                case Qt::MatchRegExp:
                    if (QRegExp(text, paramCaseSensitvity).exactMatch(t))
                        result.append(idx);
                    break;
                case Qt::MatchWildcard:
                    if (QRegExp(text, paramCaseSensitvity, QRegExp::Wildcard).exactMatch(t))
                        result.append(idx);
                    break;
                case Qt::MatchStartsWith:
                    if (t.startsWith(text, paramCaseSensitvity))
                        result.append(idx);
                    break;
                case Qt::MatchEndsWith:
                    if (t.endsWith(text, paramCaseSensitvity))
                        result.append(idx);
                    break;
                case Qt::MatchFixedString:
                    if (t.compare(text, paramCaseSensitvity) == 0)
                        result.append(idx);
                    break;
                case Qt::MatchContains:
                default:
                    if (t.contains(text, paramCaseSensitvity))
                        result.append(idx);
                }
            }

            if (paramMatchRecursive && hasChildren(idx)) ///< search the hierarchy
            {
                result += match \
                ( \
                    index( 0, idx.column(), idx ), \
                    role, \
                    ( text.isEmpty() ? value : text ), \
                    ( paramAllHits ? -1 : hits - result.count() ), \
                    flags \
                );
            }
        }
        
        from = 0; ///< prepare for the next iteration
        to = start.row();
    }

    return result;
}
Пример #14
0
void KTreeItem::drawBranch( QPainter *p )
{
	KTreeWidget::TreeStyles styles = m_treeWidget->treeStyle();
	if(!(styles & KTreeWidget::HasBranch))
	{
		return;
	}
	int ndepth = m_treeWidget->nodeDepth(m_nodeid);
	QColor clr = branchColor();
	int wdepth = m_treeWidget->indentation();
	QMargins m = margins();
	QRectF winRt = rect();
	QBrush brush(clr, Qt::Dense4Pattern);
	int xbegin = m.left() - wdepth;
	int ymid = winRt.center().y();
	if(hasChildren())
	{
		p->fillRect(xbegin + 4, winRt.top(), 1, ymid - 4 - winRt.top(), brush);
		QPen penold = p->pen();
		p->setPen(clr);
		if(hasExpanded())
		{
			p->drawLine(xbegin+2, ymid, xbegin + 6, ymid);
		}
		else
		{
			p->drawLine(xbegin+2, ymid, xbegin + 6, ymid);
			p->drawLine(xbegin + 4, ymid - 2, xbegin + 4, ymid + 2);
		}
		p->setPen(penold);
		QRect rt(xbegin, ymid-4, 8, 8);
		p->drawRect(rt);
		p->fillRect(xbegin + 8, ymid, wdepth - 8, 1, brush);
		if(hasNextSibling(m_nodeid))
		{
			p->fillRect(xbegin + 4, ymid + 4, 1, winRt.bottom() - ymid - 4, brush);
		}
	}
	else
	{
		p->fillRect(xbegin + 4, winRt.top(), 1, ymid - winRt.top(), brush);
		p->fillRect(xbegin + 4, ymid, wdepth - 8, 1, brush);
		if(hasNextSibling(m_nodeid))
		{
			p->fillRect(xbegin + 4, ymid, 1, winRt.bottom() - ymid, brush);
		}
	}
	xbegin -= wdepth;
	KAbstractTreeModel *model = m_treeWidget->model();
	qint64 nodeid = m_nodeid;
	for(int i = 0; i < ndepth - 1; i++)
	{
		int x = xbegin + 4;
		int y = winRt.top();
		nodeid = model->parent(nodeid);
		if(model->hasNextSibling(nodeid))
		{
			p->fillRect(x, y, 1, winRt.height(), brush);
		}
		xbegin -= wdepth;
	}
}
Пример #15
0
QModelIndexList QmitkXnatTreeModel::match(const QModelIndex &start, int role,
                                          const QVariant &value, int hits,
                                          Qt::MatchFlags flags) const
{
    QModelIndexList result;
    uint matchType = flags & 0x0F;
    Qt::CaseSensitivity cs = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
    bool recurse = flags & Qt::MatchRecursive;
    bool wrap = flags & Qt::MatchWrap;
    bool allHits = (hits == -1);
    QString text; // only convert to a string if it is needed
    QModelIndex p = parent(start);
    int from = start.row();
    int to = rowCount(p);

    // iterates twice if wrapping
    for (int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) {
        for (int r = from; (r < to) && (allHits || result.count() < hits); ++r) {
            QModelIndex idx = index(r, start.column(), p);
            if (!idx.isValid())
                 continue;
            QVariant v = data(idx, role);
            // QVariant based matching
            if (matchType == Qt::MatchExactly) {
                if (value != v)
                    result.append(idx);
            } else { // QString based matching
                if (text.isEmpty()) // lazy conversion
                    text = value.toString();
                QString t = v.toString();
                switch (matchType) {
                case Qt::MatchRegExp:
                    if (!QRegExp(text, cs).exactMatch(t))
                        result.append(idx);
                    break;
                case Qt::MatchWildcard:
                    if (!QRegExp(text, cs, QRegExp::Wildcard).exactMatch(t))
                        result.append(idx);
                    break;
                case Qt::MatchStartsWith:
                    if (!t.startsWith(text, cs))
                        result.append(idx);
                    break;
                case Qt::MatchEndsWith:
                    if (!t.endsWith(text, cs))
                        result.append(idx);
                    break;
                case Qt::MatchFixedString:
                    if (!t.compare(text, cs) == 0)
                        result.append(idx);
                    break;
                case Qt::MatchContains:
                default:
                    if (!t.contains(text, cs))
                        result.append(idx);
                }
            }
            if (recurse && hasChildren(idx)) { // search the hierarchy
                result += match(index(0, idx.column(), idx), role,
                                (text.isEmpty() ? value : text),
                                (allHits ? -1 : hits - result.count()), flags);
            }
        }
        // prepare for the next iteration
        from = 0;
        to = start.row();
    }
    return result;
}
Пример #16
0
bool DhQAbstractProxyModel::DvhhasChildren() const {
  return hasChildren();
}
Пример #17
0
TraceModel::ComponentType TraceModelImpl::getComponentType(int component) const// deprecated
{
    return hasChildren(component) ? ComponentType::RCHM : ComponentType::CHM;
}
Пример #18
0
bool DhQDirModel::DvhhasChildren(const QModelIndex& x1) const {
  return hasChildren(x1);
}
Пример #19
0
bool DhQDirModel::DvhhasChildren() const {
  return hasChildren();
}
Пример #20
0
 bool empty() const
     { return m_impl->m_name.empty() && !hasChildren(); }
Пример #21
0
bool wmsCapabilitiesState::getLatLonBoundingBox(double& minLat,
        double& minLon,
        double& maxLat,
        double& maxLon)const
{
    bool validChildBounds = false;
    double tempMinLat = 0.0;
    double tempMinLon = 0.0;
    double tempMaxLat = 0.0;
    double tempMaxLon = 0.0;
    if(hasChildren())
    {
        unsigned int idx = 0;
        for(idx = 0; idx < theChildren.size(); ++idx)
        {

            if(theChildren[idx].valid()&&
                    theChildren[idx]->getLatLonBoundingBox(tempMinLat,
                            tempMinLon,
                            tempMaxLat,
                            tempMaxLon))
            {
                if(!validChildBounds)
                {
                    minLat = tempMinLat;
                    minLon = tempMinLon;
                    maxLat = tempMaxLat;
                    maxLon = tempMaxLon;
                    validChildBounds = true;
                }
                else
                {
                    if(tempMinLat < minLat)
                    {
                        minLat = tempMinLat;
                    }
                    if(tempMinLon < minLon)
                    {
                        minLon = tempMinLon;
                    }
                    if(tempMaxLat > maxLat)
                    {
                        maxLat = tempMaxLat;
                    }
                    if(tempMaxLon > maxLon)
                    {
                        maxLon = tempMaxLon;
                    }
                }
            }
        }
    }

    if((theLatMin == "") ||
            (theLonMin == "") ||
            (theLatMax == "") ||
            (theLonMax == "") )
    {
        if(validChildBounds)
        {
            return true;
        }
    }

    tempMinLat = atof(theLatMin.c_str());
    tempMinLon = atof(theLonMin.c_str());
    tempMaxLat = atof(theLatMax.c_str());
    tempMaxLon = atof(theLonMax.c_str());

    if(tempMinLat < -90.0)
    {
        tempMinLat = -90.0;
    }
    if(tempMinLon < -180.0)
    {
        tempMinLon = -180.0;
    }
    if(tempMaxLat > 90.0)
    {
        tempMaxLat = 90.0;
    }
    if(tempMaxLon > 180.0)
    {
        tempMaxLon = 180.0;
    }
    if(validChildBounds)
    {
        if(tempMinLat < minLat)
        {
            minLat = tempMinLat;
        }
        if(tempMinLon < minLon)
        {
            minLon = tempMinLon;
        }
        if(tempMaxLat > maxLat)
        {
            maxLat = tempMaxLat;
        }
        if(tempMaxLon > maxLon)
        {
            maxLon = tempMaxLon;
        }
    }
    else
    {
        minLat = tempMinLat;
        minLon = tempMinLon;
        maxLat = tempMaxLat;
        maxLon = tempMaxLon;
    }
    return true;
}