35 PSpaceRoots

A PSpace has a set of named roots. These are recorded in an instance of a PSpaceRoots.

A PSpace has a single PSpaceRoots object used to record a set of named persistent roots. In the following picture the object labelled r1 is a named persistent root.

Usage by PSpace

$adt+ implement PSpace isa IObject
{
    PSpace(OID oid, bool creating) :
        m_roots(oid,creating)
    {
    }

    void VisitObjects(IObjectVisitor& v) const
    {
        m_roots.VisitObjects(v);
    }

    ptr<IPersistable> GetRoot(ConstStringZ name)
    {
        cxAssert(HaveReadOrWriteAccess());
        return m_roots.GetRoot(name);
    }

    bool AddRoot(ConstStringZ name, ptr<IPersistable> root)
    {
        cxAssert(HaveWriteAccess());
        cxAssert(GetAssociatedCSpace(root) == m_cspace);
        return m_roots.AddRoot(this,name,root);
    }

    bool RemoveRoot(ConstStringZ name)
    {
        cxAssert(HaveWriteAccess());
        return m_roots.RemoveRoot(name);
    }

    void WriteDirtyObjectsToLss(ILssTransaction& txn)
    {
        // Write the PSpace roots, if dirty
        m_roots.WriteToLssIfDirty(txn);
        ...
    }
    PSpaceRoots m_roots;
};

Implementation

PSpaceRoots is essentially a map from string to pref<IPersistable> object. It is a requirement that RepresentsSubTree() returns true for every root object added to the PSpaceRoots.

PSpaceRoots itself persists in a single serial element in the LSS. It becomes dirty whenever roots are added or removed


PSpaceRoots.h

Source: Ceda/cxPersistStore/src/PSpaceRoots.h


PSpaceRoots.cpp

Source: Ceda/cxPersistStore/src/PSpaceRoots.cpp