Example #1
0
	/* Incremental cached-based lookup method. */
void
_TDL_TDLStatement::cacheDescendInto ( int4    theChildIndex,
				      BOOLEAN theIsDescendingIntoBranch,
				      BOOLEAN theCanCreateNewNodes )
{
  _TDL_Snode    * newStatementData = (_TDL_Snode    *) NULL;
  _TDL_TreeNode * newTreeNode      = (_TDL_TreeNode *) NULL;
  _TDL_TreeNode * oldTreeNode      = getCachedTreeNodeNonConst();
  const char    * errorMessage     = (const char    *) NULL;


  if ( getTopmostTreeNode() == (_TDL_TreeNode *) NULL )
  {
    setCachedTreeNode ( (_TDL_TreeNode *) NULL );
  }

	/* Ie: getCachedTreeNode() == NULL */
  else if ( hasCachedTreeNode() == FALSE )
  {
	/* We've hit a bug. */
    TDL::getLogStream()
      << "[_TDL_TDLStatement:cacheDescendInto("
      << theChildIndex << "," 
      << ( (theIsDescendingIntoBranch == TRUE) ? "BRANCH,"   : "NODE," )
      << ( (theCanCreateNewNodes      == TRUE) ? "NEW-NODES" : "NO-new-nodes" )
      << "):\"" << getName() << "\"] Error:  "
      << "cachedTreeNode is NULL." << endl;
    return; /* Abort further action.  Do not try to create this node. */
  }

	/* If doDestroy() has been invoked, there will be a terminating *
	 * (destroyed) leaf-node created.  Don't descend past it.       */
  else if (   (     getCachedTreeNode() -> isTreeNodeBranch()      == FALSE   )
	   && (   ( getCachedTreeNode() -> getIsDestroyedSubtree() == TRUE  )
	       || (   ( getCachedTreeNode()
				     -> isSpawnStatementTreeNode() == TRUE )
		   && ( getCachedTreeNode()
				     -> getSpawnStatementTreeNodeConst()
				     -> isDestroyed()              == TRUE )) )
	   )
  {
    return; /* Abort further action.  Do not try to create this node. */
  }

	/* Singleton case. */
  else if (   ( theChildIndex             == _TDL_TreeNode::NO_ARRAY_INDEX )
	   && ( theIsDescendingIntoBranch == FALSE                         )
	   && ( getCachedTreeNode()       == getTopmostTreeNode()          )
	   && ( getCachedTreeNode()
		  -> isTreeNodeBranch()   == FALSE                         )
	   && ( getCachedTreeNode()
		  -> getArrayIndex()      == _TDL_TreeNode::NO_ARRAY_INDEX ) )
  {	/* The Singleton node already exists...                         *
	 * And there is nothing more to be done for a singleton lookup. */
    return;  /* All done. */
  }

	/* Otherwise we are descending to our target node. */

  else if ( getCachedTreeNode() -> isTreeNodeBranch() == FALSE )
  {
	/* We've hit a premature-endpoint bug. */
    TDL::getLogStream()
      << "[_TDL_TDLStatement:cacheDescendInto("
      << theChildIndex << "," 
      << ( (theIsDescendingIntoBranch == TRUE) ? "BRANCH,"   : "NODE," )
      << ( (theCanCreateNewNodes      == TRUE) ? "NEW-NODES" : "NO-new-nodes" )
      << "):\"" << getName() << "\"] Error:  "
      << "cachedTreeNode is *NOT* a branch!!!." << endl;
    setCachedTreeNode ( (_TDL_TreeNode *) NULL );
    return; /* Abort further action.  Do not try to create this node. */
  }

  else
  {
    setCachedTreeNode ( getCachedTreeNode()
			  -> getTreeNodeBranchConst()
			  -> getChildWithArrayIndex ( theChildIndex ) );
  }



	/* If we can create new tree members, and this member does not exist.*/
  if (   ( theCanCreateNewNodes == TRUE  )
      && ( hasCachedTreeNode()  == FALSE ) )
  {
	/* Do we need to create a topmost-TreeNodeBranch??. */
    if (   ( getTopmostTreeNode() == (_TDL_TreeNode *) NULL        )
	&& ( theChildIndex        != _TDL_TreeNode::NO_ARRAY_INDEX ) )
    {
      oldTreeNode = getCachedTopmostTreeNodeBranch ( TRUE );
    }

	/**************************************/
	/* Now we can create our new TreeNode */
	/**************************************/

    if (   ( theIsDescendingIntoBranch == TRUE                     )

	    /* Note:  Abort descending into complex tree's if we have been *
	     * destroyed.  Instead, create a destroyed child leaf ASAP.    */
	&& (   ( oldTreeNode == (_TDL_TreeNode *) NULL           )
	    || ( oldTreeNode -> getIsDestroyedSubtree() == FALSE ) )
	)
    {
      newTreeNode = new _TDL_TreeNodeBranch();
      addObjectToDelete  ( (_TDL_TreeNodeBranch *) newTreeNode );
    }
    else /* Ie:  Descending into a node. */
    {
      if ( createObjects ( newStatementData, newTreeNode ) == FAILURE )
      {
	errorMessage = "Unable to create child node.";
      }

      else if ( newStatementData == (_TDL_Snode *) NULL )
      {
	errorMessage = "newStatementData is NULL!";
      }

      else if ( newTreeNode == (_TDL_TreeNode *) NULL )
      {
	errorMessage = "newTreeNode is NULL!";
      }

      else if ( addDataObject ( newStatementData ) == FAILURE )
      {
	errorMessage = "Unable to addDataObject ( newStatementData ).";
      }

      if ( errorMessage != (const char *) NULL )
      {
	TDL::getLogStream()
	  << "[_TDL_TDLStatement:cacheDescendInto("
	  << theChildIndex << "):\"" << getName() << "\"]  "
	  << "Error:  " << errorMessage << endl;
	deleteObjects ( newStatementData, newTreeNode );
	return;
      }

	/* If we are creating a destroyed child-leaf, then destroy it! */
      if (   ( oldTreeNode != (_TDL_TreeNode *) NULL          )
	  && ( oldTreeNode -> getIsDestroyedSubtree() == TRUE ) )
      {
	newTreeNode -> destroy();
      }

    } /* IF ( theIsDescendingIntoBranch == TRUE ) ... ELSE ... */


		/* Configure the new TreeNode. */
    newTreeNode -> setArrayIndex ( theChildIndex );
    if ( getTopmostTreeNode() == (_TDL_TreeNode *) NULL )
    {
      setTopmostTreeNode ( newTreeNode );
      newTreeNode -> setParent ( (_TDL_TreeNodeBranch *) NULL );
    }
    else
    {
      oldTreeNode -> getTreeNodeBranch() -> addChild ( newTreeNode );
      newTreeNode -> setParent ( oldTreeNode -> getTreeNodeBranch() );
    }
    setCachedTreeNode ( newTreeNode );

  } /* IF ( theCanCreateNewNodes == TRUE &&  hasCachedTreeNode() == FALSE ) */
} /* void _TDL_TDLStatement::cacheDescendInto ( ... ) */
Example #2
0
void RenderView::showDataObjectsImpl(const QList<DataObject *> & uncheckedDataObjects, QList<DataObject *> & incompatibleObjects, unsigned int /*subViewIndex*/)
{
    if (uncheckedDataObjects.isEmpty())
    {
        return;
    }

    const bool wasEmpty = m_contents.empty();

    if (wasEmpty)
    {
        updateImplementation(uncheckedDataObjects);
    }

    AbstractVisualizedData * aNewObject = nullptr;

    const auto && dataObjects = implementation().filterCompatibleObjects(uncheckedDataObjects, incompatibleObjects);

    if (dataObjects.isEmpty())
    {
        return;
    }

    for (auto dataObject : dataObjects)
    {
        auto previouslyRendered = m_dataObjectToVisualization.value(dataObject);

        // create new rendered representation
        if (!previouslyRendered)
        {
            aNewObject = addDataObject(dataObject);

            if (m_closingRequested) // just abort here, if we processed a close event while addDataObject()
            {
                return;
            }

            continue;
        }

        // reuse currently rendered / cached data

        auto contensIt = findUnique(m_contents, previouslyRendered);
        if (contensIt != m_contents.end())
        {
            continue;
        }

        aNewObject = previouslyRendered;

        auto cacheIt = findUnique(m_contentCache, previouslyRendered);
        m_contents.push_back(std::move(*cacheIt));
        m_contentCache.erase(cacheIt);

        previouslyRendered->setVisible(true);
    }

    if (aNewObject)
    {
        implementation().renderViewContentsChanged();

        updateGuiForSelectedData(aNewObject);

        emit visualizationsChanged();
    }

    if (aNewObject)
    {
        implementation().resetCamera(wasEmpty, 0);
    }

    resetFriendlyName();
    updateTitle();
}