static void recoverBrokenAdjacencies(Flower *flower, stList *recoveredCaps, Name referenceEventName) {
    /*
     * Find reference intervals that are book-ended by stubs created in a child flower.
     */
    Flower_GroupIterator *groupIt = flower_getGroupIterator(flower);
    Group *group;
    while((group = flower_getNextGroup(groupIt)) != NULL) {
        Flower *nestedFlower;
        if((nestedFlower = group_getNestedFlower(group)) != NULL) {
            Flower_EndIterator *endIt = flower_getEndIterator(nestedFlower);
            End *childEnd;
            while((childEnd = flower_getNextEnd(endIt)) != NULL) {
                if(end_isStubEnd(childEnd) && flower_getEnd(flower, end_getName(childEnd)) == NULL) { //We have a thread we need to promote
                    Cap *childCap = getCapForReferenceEvent(childEnd, referenceEventName); //The cap in the reference
                    assert(childCap != NULL);
                    assert(!end_isAttached(childEnd));
                    childCap = cap_getStrand(childCap) ? childCap : cap_getReverse(childCap);
                    if (!cap_getSide(childCap)) {
                        Cap *adjacentChildCap = NULL;
                        int64_t adjacencyLength = traceThreadLength(childCap, &adjacentChildCap);
                        Cap *cap = copyCapToParent(childCap, recoveredCaps);
                        assert(adjacentChildCap != NULL);
                        assert(!end_isAttached(cap_getEnd(adjacentChildCap)));
                        assert(!cap_getSide(cap));
                        Cap *adjacentCap = copyCapToParent(adjacentChildCap, recoveredCaps);
                        cap_makeAdjacent(cap, adjacentCap);
                        setAdjacencyLength(cap, adjacentCap, adjacencyLength);
                    }
                }
            }
            flower_destructEndIterator(endIt);
        }
    }
    flower_destructGroupIterator(groupIt);
}
Esempio n. 2
0
void testEnd_isAttachedOrFree(CuTest* testCase) {
    cactusEndTestSetup();
    End *end2 = end_construct(1, flower);
    End *end3 = end_construct(0, flower);
    Block *block = block_construct(2, flower);
    End *end4 = block_get5End(block);
    End *end5 = block_get3End(block);
    CuAssertTrue(testCase, end_isAttached(end2));
    CuAssertTrue(testCase, !end_isAttached(end3));
    CuAssertTrue(testCase, !end_isFree(end2));
    CuAssertTrue(testCase, end_isFree(end3));

    CuAssertTrue(testCase, !end_isAttached(end4));
    CuAssertTrue(testCase, !end_isAttached(end5));
    CuAssertTrue(testCase, end_isFree(end4));
    CuAssertTrue(testCase, end_isFree(end5));
    cactusEndTestTeardown();
}