Ejemplo n.º 1
0
/** Node checking routine */
bool Edge::checkNodes( Node* _pred, Node* _succ)
{
    return isNotNullP( _pred)
           && isNotNullP( _succ)
           && areEqP( this->graph(), _pred->graph())
           && areEqP( _pred->graph(), _succ->graph());
}
Ejemplo n.º 2
0
/* Other edge's node */
GNode *
NodeNav::otherEnd( GEdge *edge) const
{
    if ( areEqP( node_priv, edge->pred()))
    {
        return edge->succ();
    } else if ( areEqP( node_priv, edge->succ()))
    {
        return edge->pred();
    }
    return NULL;
}
Ejemplo n.º 3
0
/**
 * Destructor for node - removes edge controls on incidient edges and disconnects item from scene
 */
GNode::~GNode()
{
    graph()->invalidateRanking();
    if ( ( isEdgeControl() || isEdgeLabel())
         && isNotNullP( firstPred()) 
         && isNotNullP( firstSucc())
         && isNotNullP( firstPred()->pred())
         && isNotNullP( firstSucc()->succ()))
    {
        GRAPH_ASSERTD( areEqP( firstPred()->style(), firstSucc()->style()),
                       "Different styles on the same edge");
        GEdge *e = graph()->newEdge( firstPred()->pred(), firstSucc()->succ());
        e->setStyle( firstPred()->style());
    } else if ( isSimple())
    {
        QList< GNode *> nodes;
        GEdge* edge;
		Marker m = graph()->newMarker();
        for ( edge = firstSucc(); isNotNullP( edge); edge = edge->nextSucc())
        {
            edge->item()->adjust();
            GNode* succ = edge->succ();

            while ( succ->isEdgeControl() || succ->isEdgeLabel())
            {
                assert( isNotNullP( succ->firstSucc()));
                if ( succ->mark( m))
				{
					nodes << succ;
				}
                succ = succ->firstSucc()->succ();
            }
        }
        for ( edge = firstPred(); isNotNullP( edge); edge = edge->nextPred())
        {
            if ( edge->isSelf()) // We've already processed this one in previous loop
				continue;

			edge->item()->adjust();
            GNode* pred = edge->pred();

            while ( pred->isEdgeControl() || pred->isEdgeLabel())
            {
                assert( isNotNullP( pred->firstPred()));
                if ( pred->mark( m))
				{
					nodes << pred;
				}
                pred = pred->firstPred()->pred();
            }
        }
        
        foreach ( GNode *n, nodes)
        {
            graph()->deleteNode( n);
        }
		graph()->freeMarker( m);
    }
Ejemplo n.º 4
0
/**
 * Test simple singleton
 */
bool uTestSingle()
{
    SingleA::init();

    classA* a1 = SingleA::instance();
    classA* a2 = SingleA::instance();
    ASSERT( areEqP( a1, a2));
    SingleA::deinit();
    return true;
}
Ejemplo n.º 5
0
    /**
     * Test simple singleton
     */
    static bool uTestSingle( UnitTest *utest_p)
    {
        SingleA::init();

        A* a1 = SingleA::instance();
        A* a2 = SingleA::instance();
        UTEST_CHECK( utest_p, areEqP( a1, a2));
        SingleA::deinit();
        return true;
    }
Ejemplo n.º 6
0
void
CFNode< MdesType>::toStream(ostream& os)
{
    /* Begin with node header */
    os << "CF Node " << this->id();
    
    /* Print node start/stop property */
    if ( this->isStart() )
    {
        os << " Start";
    } else if ( this->isStop() )
    {
        os << " Stop";
    }
    /* Node header done */
    os << endl;

    /* Iterating over predecessors */
    for ( typename CFNode< MdesType>::Pred
            pred_iter = this->predsBegin(),
            pred_iter_end = this->predsEnd();
          pred_iter != pred_iter_end;
          pred_iter++ )
    {
         CFEdge< MdesType> *edge = *pred_iter;
         os << *edge;
    }

    /* Print all operations */
    for ( Operation< MdesType> * oper = firstOper();
          isNotNullP( oper);
          oper = oper->nextOper() )
    {
        os << oper;
        
        if ( areEqP( oper, lastOper()) )
            break;
    }

    /* Iterating over successors */
    for ( typename CFNode< MdesType>::Succ
              succ_iter = this->succsBegin(),
              succ_iter_end = this->succsEnd();
          succ_iter != succ_iter_end;
          ++succ_iter )
    {
         CFEdge< MdesType> *edge = *succ_iter;
         os << *edge;        
    }
}
Ejemplo n.º 7
0
/** MList testing */
static bool uTestMList()
{
    B *obj1 = new B();
    B *obj2 = new B();
    B *obj3 = new B();
    obj1->attach( LIST_ONE, obj2);
    obj1->attach( LIST_TWO, obj3);
    ASSERT( areEqP( obj1->next( LIST_ONE), obj2));
    ASSERT( areEqP( obj1->next( LIST_TWO), obj3));
    ASSERT( isNullP( obj1->prev( LIST_ONE)));
    ASSERT( isNullP( obj1->prev( LIST_TWO)));
    ASSERT( areEqP( obj2->prev( LIST_ONE), obj1));
    ASSERT( areEqP( obj3->prev( LIST_TWO), obj1));
    ASSERT( isNullP( obj3->prev( LIST_ONE)));
    ASSERT( isNullP( obj2->prev( LIST_TWO)));
    ASSERT( isNullP( obj2->next( LIST_ONE)));
    ASSERT( isNullP( obj3->next( LIST_TWO)));
    obj2->detachAll();
    delete obj2;
    delete obj1;
    delete obj3;
    return true;
}
Ejemplo n.º 8
0
bool
CFNode<MdesType>::isStop() const
{
    return areEqP( this->graph()->stopNode(), this);
}