/*! Fills this changelist with entries that represent the current state of
    the system starting at the container with the given id.
    Prototypes are skipped unless skipPrototypes is false.

    For every container a 'Create' entry and a 'Change' entry (marking all fields
    as modified) is added and as many 'AddReference' entries as the ref count
    of the container.
 */
void ChangeList::fillFromCurrentState(UInt32 uiFieldContainerId,
                                      bool   skipPrototypes     )
{
    this->clear();

    UInt32 uiNumContainers = 
        FieldContainerFactory::the()->getNumContainers();

    if(uiNumContainers <= uiFieldContainerId)
    {
        return;
    }

    for(UInt32 i = uiFieldContainerId; i < uiNumContainers; ++i)
    {
        FieldContainer *pContainer = 
            FieldContainerFactory::the()->getContainer(i);

        // skip destroyed FC
        if(pContainer == NULL)
          continue;

        // skip prototypes - unless requested
        if(skipPrototypes == true &&
           (pContainer->getType().getPrototype() == pContainer ||
            pContainer->getType().getPrototype() == NULL         ))
        {
            continue;
        }

        this->addCreated(i, TypeTraits<BitVector>::BitsClear);

        for(Int32 j = 0; j < pContainer->getRefCount(); ++j)
            this->addAddRefd(i);

        ContainerChangeEntry *pEntry = this->getNewEntry();

        pEntry->uiEntryDesc   = ContainerChangeEntry::Change;
        pEntry->pFieldFlags   = pContainer->getFieldFlags();
        pEntry->uiContainerId = i;
        pEntry->whichField    = FieldBits::AllFields;
        pEntry->pList         = this;
    }
}
Пример #2
0
void printFieldContainer() {
    int N = FieldContainerFactory::the()->getNumTotalContainers();
    for (int i=0;i<N;++i) {
        FieldContainer* fc = FieldContainerFactory::the()->getContainer(i);
        if(fc == 0) continue;

        // skip prototypes
        if(fc->getType().getPrototype() == 0 || fc->getType().getPrototype() == fc  ) continue;

        //cout << "\nFC id: " << fc->getId() << flush;

        AttachmentContainer* ac = dynamic_cast<AttachmentContainer*>(fc);
        if (ac == 0) {
            Attachment* a = dynamic_cast<Attachment*>(fc);
            if (a != 0) {
                FieldContainer* dad = 0;
                if (a->getMFParents()->size() > 0) dad = a->getParents(0);
                ac = dynamic_cast<AttachmentContainer*>(dad);
            }
        }

        const Char8* name = getName(ac);
        if (name != 0) printf("Detected living FC %s (%s) %p refcount %d ID %d\n", fc->getTypeName(), name, fc, fc->getRefCount(), fc->getId());
        else printf( "Detected living FC %s %p refcount %d ID %d\n", fc->getTypeName(), fc, fc->getRefCount(), fc->getId() );
    }
}