Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
InMemoryDataSource Class Reference
Inheritance diagram for InMemoryDataSource:
Inheritance graph
[legend]
Collaboration diagram for InMemoryDataSource:
Collaboration graph
[legend]

List of all members.

Public Member Functions

AssertionGetForwardArcs (nsIRDFResource *u)
AssertionGetReverseArcs (nsIRDFNode *v)
void SetForwardArcs (nsIRDFResource *u, Assertion *as)
void SetReverseArcs (nsIRDFNode *v, Assertion *as)
nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Find an RDF resource that points to a given node over the specified arc & truth value.
nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Find all RDF resources that point to a given node over the specified arc & truth value.
nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue)
 Find a child of that is related to the source by the given arc arc and truth value.
nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue)
 Find all children of that are related to the source by the given arc arc and truth value.
void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Add an assertion to the graph.
void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget)
 Remove an assertion from the graph.
void Change (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aOldTarget, in nsIRDFNode aNewTarget)
 Change an assertion from.
void Move (in nsIRDFResource aOldSource, in nsIRDFResource aNewSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget)
 'Move' an assertion from
boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
 Query whether an assertion exists in this graph.
void AddObserver (in nsIRDFObserver aObserver)
 Add an observer to this data source.
void RemoveObserver (in nsIRDFObserver aObserver)
 Remove an observer from this data source.
nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode)
 Get a cursor to iterate over all the arcs that point into a node.
nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource)
 Get a cursor to iterate over all the arcs that originate in a resource.
nsISimpleEnumerator GetAllResources ()
 Retrieve all of the resources that the data source currently refers to.
boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments)
 Returns whether a given command is enabled for a set of sources.
void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments)
 Perform the specified command on set of sources.
nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource)
 Returns the set of all commands defined for a given source.
boolean hasArcIn (in nsIRDFNode aNode, in nsIRDFResource aArc)
 Returns true if the specified node is pointed to by the specified arc.
boolean hasArcOut (in nsIRDFResource aSource, in nsIRDFResource aArc)
 Returns true if the specified node has the specified outward arc.
void beginUpdateBatch ()
 Notify observers that the datasource is about to send several notifications at once.
void endUpdateBatch ()
 Notify observers that the datasource has completed issuing a notification group.
void EnsureFastContainment (in nsIRDFResource aSource)
boolean Mark (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue)
void Sweep ()
void visitAllSubjects (in rdfITripleVisitor aVisitor)
 Visit all the subject resources in the datasource.
void visitAllTriples (in rdfITripleVisitor aVisitor)
 Visit all the triples in the datasource.

Public Attributes

PRBool mPropagateChanges
readonly attribute string URI
 The "URI" of the data source.
attribute boolean propagateChanges
 Set this value to true to enable synchronization notifications.

Protected Member Functions

nsresult LockedAssert (nsIRDFResource *source, nsIRDFResource *property, nsIRDFNode *target, PRBool tv)
nsresult LockedUnassert (nsIRDFResource *source, nsIRDFResource *property, nsIRDFNode *target)
 InMemoryDataSource (nsISupports *aOuter)
virtual ~InMemoryDataSource ()
nsresult Init ()

Static Protected Member Functions

static PLDHashOperator PR_CALLBACK DeleteForwardArcsEntry (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)
static PLDHashOperator PR_CALLBACK ResourceEnumerator (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)
static PLDHashOperator PR_CALLBACK SweepForwardArcsEntries (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)

Protected Attributes

nsFixedSizeAllocator mAllocator
PLDHashTable mForwardArcs
PLDHashTable mReverseArcs
nsCOMArray< nsIRDFObservermObservers
PRUint32 mNumObservers
PRUint32 mReadCount

Friends

class InMemoryArcsEnumeratorImpl
class InMemoryAssertionEnumeratorImpl
class InMemoryResourceEnumeratorImpl
NS_IMETHODIMP NS_NewRDFInMemoryDataSource (nsISupports *aOuter, const nsIID &aIID, void **aResult)

Detailed Description

Definition at line 306 of file nsInMemoryDataSource.cpp.


Constructor & Destructor Documentation

InMemoryDataSource::InMemoryDataSource ( nsISupports *  aOuter) [protected]

Definition at line 890 of file nsInMemoryDataSource.cpp.

    : mNumObservers(0), mReadCount(0)
{
    NS_INIT_AGGREGATED(aOuter);

    static const size_t kBucketSizes[] = {
        sizeof(Assertion),
        sizeof(Entry),
        sizeof(InMemoryArcsEnumeratorImpl),
        sizeof(InMemoryAssertionEnumeratorImpl) };

    static const PRInt32 kNumBuckets = sizeof(kBucketSizes) / sizeof(size_t);

    // Per news://news.mozilla.org/39BEC105.5090206%40netscape.com
    static const PRInt32 kInitialSize = 1024;

    mAllocator.Init("nsInMemoryDataSource", kBucketSizes, kNumBuckets, kInitialSize);

    mForwardArcs.ops = nsnull;
    mReverseArcs.ops = nsnull;
    mPropagateChanges = PR_TRUE;
}
InMemoryDataSource::~InMemoryDataSource ( ) [protected, virtual]

Definition at line 943 of file nsInMemoryDataSource.cpp.

{
#ifdef DEBUG_REFS
    --gInstanceCount;
    fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount);
#endif

    if (mForwardArcs.ops) {
        // This'll release all of the Assertion objects that are
        // associated with this data source. We only need to do this
        // for the forward arcs, because the reverse arcs table
        // indexes the exact same set of resources.
        PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, &mAllocator);
        PL_DHashTableFinish(&mForwardArcs);
    }
    if (mReverseArcs.ops)
        PL_DHashTableFinish(&mReverseArcs);

    PR_LOG(gLog, PR_LOG_NOTICE,
           ("InMemoryDataSource(%p): destroyed.", this));

}

Here is the call graph for this function:


Member Function Documentation

Add an observer to this data source.

If the datasource supports observers, the datasource source should hold a strong reference to the observer.

Here is the caller graph for this function:

Get a cursor to iterate over all the arcs that point into a node.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that labels points to a valid (but possible empty) nsISimpleEnumerator object.

Here is the caller graph for this function:

Get a cursor to iterate over all the arcs that originate in a resource.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that labels points to a valid (but possible empty) nsISimpleEnumerator object.

Here is the caller graph for this function:

void nsIRDFDataSource::Assert ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Add an assertion to the graph.

Here is the caller graph for this function:

Notify observers that the datasource is about to send several notifications at once.

This must be followed by calling endUpdateBatch(), otherwise viewers will get out of sync.

void nsIRDFDataSource::Change ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aOldTarget,
in nsIRDFNode  aNewTarget 
) [inherited]

Change an assertion from.

[aSource]--[aProperty]-->[aOldTarget]

to

[aSource]--[aProperty]-->[aNewTarget]

Here is the caller graph for this function:

PLDHashOperator PR_CALLBACK InMemoryDataSource::DeleteForwardArcsEntry ( PLDHashTable aTable,
PLDHashEntryHdr aHdr,
PRUint32  aNumber,
void aArg 
) [static, protected]

Definition at line 967 of file nsInMemoryDataSource.cpp.

{
    Entry* entry = NS_REINTERPRET_CAST(Entry*, aHdr);
    nsFixedSizeAllocator* allocator = NS_STATIC_CAST(nsFixedSizeAllocator*, aArg);

    Assertion* as = entry->mAssertions;
    while (as) {
        Assertion* doomed = as;
        as = as->mNext;

        // Unlink, and release the datasource's reference.
        doomed->mNext = doomed->u.as.mInvNext = nsnull;
        doomed->Release(*allocator);
    }
    return PL_DHASH_NEXT;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRDFDataSource::DoCommand ( in nsISupportsArray  aSources,
in nsIRDFResource  aCommand,
in nsISupportsArray  aArguments 
) [inherited]

Perform the specified command on set of sources.

Here is the caller graph for this function:

Notify observers that the datasource has completed issuing a notification group.

Returns the set of all commands defined for a given source.

Here is the caller graph for this function:

Retrieve all of the resources that the data source currently refers to.

Here is the caller graph for this function:

Definition at line 387 of file nsInMemoryDataSource.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 394 of file nsInMemoryDataSource.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsIRDFResource nsIRDFDataSource::GetSource ( in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Find an RDF resource that points to a given node over the specified arc & truth value.

Returns:
NS_RDF_NO_VALUE if there is no source that leads to the target with the specified property.

Here is the caller graph for this function:

nsISimpleEnumerator nsIRDFDataSource::GetSources ( in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Find all RDF resources that point to a given node over the specified arc & truth value.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that nsISimpleEnumerator points to a valid (but possibly empty) cursor.

Here is the caller graph for this function:

nsIRDFNode nsIRDFDataSource::GetTarget ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in boolean  aTruthValue 
) [inherited]

Find a child of that is related to the source by the given arc arc and truth value.

Returns:
NS_RDF_NO_VALUE if there is no target accessable from the source via the specified property.

Here is the caller graph for this function:

nsISimpleEnumerator nsIRDFDataSource::GetTargets ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in boolean  aTruthValue 
) [inherited]

Find all children of that are related to the source by the given arc arc and truth value.

Returns:
NS_OK unless a catastrophic error occurs. If the method returns NS_OK, you may assume that nsISimpleEnumerator points to a valid (but possibly empty) cursor.

Here is the caller graph for this function:

boolean nsIRDFDataSource::hasArcIn ( in nsIRDFNode  aNode,
in nsIRDFResource  aArc 
) [inherited]

Returns true if the specified node is pointed to by the specified arc.

Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.

Returns true if the specified node has the specified outward arc.

Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.

boolean nsIRDFDataSource::HasAssertion ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]

Query whether an assertion exists in this graph.

Here is the caller graph for this function:

Definition at line 915 of file nsInMemoryDataSource.cpp.

{
    if (!PL_DHashTableInit(&mForwardArcs,
                           PL_DHashGetStubOps(),
                           nsnull,
                           sizeof(Entry),
                           PL_DHASH_MIN_SIZE)) {
        mForwardArcs.ops = nsnull;
        return NS_ERROR_OUT_OF_MEMORY;
    }
    if (!PL_DHashTableInit(&mReverseArcs,
                           PL_DHashGetStubOps(),
                           nsnull,
                           sizeof(Entry),
                           PL_DHASH_MIN_SIZE)) {
        mReverseArcs.ops = nsnull;
        return NS_ERROR_OUT_OF_MEMORY;
    }

#ifdef PR_LOGGING
    if (! gLog)
        gLog = PR_NewLogModule("InMemoryDataSource");
#endif

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIRDFDataSource::IsCommandEnabled ( in nsISupportsArray  aSources,
in nsIRDFResource  aCommand,
in nsISupportsArray  aArguments 
) [inherited]

Returns whether a given command is enabled for a set of sources.

Here is the caller graph for this function:

nsresult InMemoryDataSource::LockedAssert ( nsIRDFResource source,
nsIRDFResource property,
nsIRDFNode target,
PRBool  tv 
) [protected]

Definition at line 1284 of file nsInMemoryDataSource.cpp.

{
#ifdef PR_LOGGING
    LogOperation("ASSERT", aSource, aProperty, aTarget, aTruthValue);
#endif

    Assertion* next = GetForwardArcs(aSource);
    Assertion* prev = next;
    Assertion* as = nsnull;

    PRBool  haveHash = (next) ? next->mHashEntry : PR_FALSE;
    if (haveHash) {
        PLDHashEntryHdr* hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash, aProperty, PL_DHASH_LOOKUP);
        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
            ? NS_REINTERPRET_CAST(Entry*, hdr)->mAssertions
            : nsnull;
        while (val) {
            if (val->u.as.mTarget == aTarget) {
                // Wow, we already had the assertion. Make sure that the
                // truth values are correct and bail.
                val->u.as.mTruthValue = aTruthValue;
                return NS_OK;
            }
            val = val->mNext;
        }
    }
    else
    {
        while (next) {
            // check target first as its most unique
            if (aTarget == next->u.as.mTarget) {
                if (aProperty == next->u.as.mProperty) {
                    // Wow, we already had the assertion. Make sure that the
                    // truth values are correct and bail.
                    next->u.as.mTruthValue = aTruthValue;
                    return NS_OK;
                }
            }

            prev = next;
            next = next->mNext;
        }
    }

    as = Assertion::Create(mAllocator, aSource, aProperty, aTarget, aTruthValue);
    if (! as)
        return NS_ERROR_OUT_OF_MEMORY;

    // Add the datasource's owning reference.
    as->AddRef();

    if (haveHash)
    {
        PLDHashEntryHdr* hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash,
            aProperty, PL_DHASH_LOOKUP);
        Assertion *asRef = PL_DHASH_ENTRY_IS_BUSY(hdr)
            ? NS_REINTERPRET_CAST(Entry*, hdr)->mAssertions
            : nsnull;
        if (asRef)
        {
            as->mNext = asRef->mNext;
            asRef->mNext = as;
        }
        else
        {
            hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash,
                                            aProperty, PL_DHASH_ADD);
            if (hdr)
            {
                Entry* entry = NS_REINTERPRET_CAST(Entry*, hdr);
                entry->mNode = aProperty;
                entry->mAssertions = as;
            }
        }
    }
    else
    {
        // Link it in to the "forward arcs" table
        if (!prev) {
            SetForwardArcs(aSource, as);
        } else {
            prev->mNext = as;
        }
    }

    // Link it in to the "reverse arcs" table

    next = GetReverseArcs(aTarget);
    as->u.as.mInvNext = next;
    next = as;
    SetReverseArcs(aTarget, next);

    return NS_OK;
}

Here is the call graph for this function:

nsresult InMemoryDataSource::LockedUnassert ( nsIRDFResource source,
nsIRDFResource property,
nsIRDFNode target 
) [protected]

Definition at line 1427 of file nsInMemoryDataSource.cpp.

{
#ifdef PR_LOGGING
    LogOperation("UNASSERT", aSource, aProperty, aTarget);
#endif

    Assertion* next = GetForwardArcs(aSource);
    Assertion* prev = next;
    Assertion* root = next;
    Assertion* as = nsnull;
    
    PRBool  haveHash = (next) ? next->mHashEntry : PR_FALSE;
    if (haveHash) {
        PLDHashEntryHdr* hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash,
            aProperty, PL_DHASH_LOOKUP);
        prev = next = PL_DHASH_ENTRY_IS_BUSY(hdr)
            ? NS_REINTERPRET_CAST(Entry*, hdr)->mAssertions
            : nsnull;
        PRBool first = PR_TRUE;
        while (next) {
            if (aTarget == next->u.as.mTarget) {
                break;
            }
            first = PR_FALSE;
            prev = next;
            next = next->mNext;
        }
        // We don't even have the assertion, so just bail.
        if (!next)
            return NS_OK;

        as = next;

        if (first) {
            PL_DHashTableRawRemove(root->u.hash.mPropertyHash, hdr);

            if (next && next->mNext) {
                PLDHashEntryHdr* hdr = PL_DHashTableOperate(root->u.hash.mPropertyHash,
                                     aProperty, PL_DHASH_ADD);
                if (hdr) {
                    Entry* entry = NS_REINTERPRET_CAST(Entry*, hdr);
                    entry->mNode = aProperty;
                    entry->mAssertions = next->mNext;
                }
            }
            else {
                // If this second-level hash empties out, clean it up.
                if (!root->u.hash.mPropertyHash->entryCount) {
                    Assertion::Destroy(mAllocator, root);
                    SetForwardArcs(aSource, nsnull);
                }
            }
        }
        else {
            prev->mNext = next->mNext;
        }
    }
    else
    {
        while (next) {
            // check target first as its most unique
            if (aTarget == next->u.as.mTarget) {
                if (aProperty == next->u.as.mProperty) {
                    if (prev == next) {
                        SetForwardArcs(aSource, next->mNext);
                    } else {
                        prev->mNext = next->mNext;
                    }
                    as = next;
                    break;
                }
            }

            prev = next;
            next = next->mNext;
        }
    }
    // We don't even have the assertion, so just bail.
    if (!as)
        return NS_OK;

#ifdef DEBUG
    PRBool foundReverseArc = PR_FALSE;
#endif

    next = prev = GetReverseArcs(aTarget);
    while (next) {
        if (next == as) {
            if (prev == next) {
                SetReverseArcs(aTarget, next->u.as.mInvNext);
            } else {
                prev->u.as.mInvNext = next->u.as.mInvNext;
            }
#ifdef DEBUG
            foundReverseArc = PR_TRUE;
#endif
            break;
        }
        prev = next;
        next = next->u.as.mInvNext;
    }

#ifdef DEBUG
    NS_ASSERTION(foundReverseArc, "in-memory db corrupted: unable to find reverse arc");
#endif

    // Unlink, and release the datasource's reference
    as->mNext = as->u.as.mInvNext = nsnull;
    as->Release(mAllocator);

    return NS_OK;
}

Here is the call graph for this function:

boolean nsIRDFPurgeableDataSource::Mark ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget,
in boolean  aTruthValue 
) [inherited]
void nsIRDFDataSource::Move ( in nsIRDFResource  aOldSource,
in nsIRDFResource  aNewSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget 
) [inherited]

'Move' an assertion from

[aOldSource]--[aProperty]-->[aTarget]

to

[aNewSource]--[aProperty]-->[aTarget]

Here is the caller graph for this function:

Remove an observer from this data source.

Here is the caller graph for this function:

PLDHashOperator PR_CALLBACK InMemoryDataSource::ResourceEnumerator ( PLDHashTable aTable,
PLDHashEntryHdr aHdr,
PRUint32  aNumber,
void aArg 
) [static, protected]

Definition at line 1807 of file nsInMemoryDataSource.cpp.

{
    Entry* entry = NS_REINTERPRET_CAST(Entry*, aHdr);
    nsISupportsArray* resources = NS_STATIC_CAST(nsISupportsArray*, aArg);

    resources->AppendElement(entry->mNode);
    return PL_DHASH_NEXT;
}

Here is the call graph for this function:

Definition at line 401 of file nsInMemoryDataSource.cpp.

                                                     {
        PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mForwardArcs, u,
                                                    as ? PL_DHASH_ADD : PL_DHASH_REMOVE);
        if (as && hdr) {
            Entry* entry = NS_REINTERPRET_CAST(Entry*, hdr);
            entry->mNode = u;
            entry->mAssertions = as;
        } }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 411 of file nsInMemoryDataSource.cpp.

                                                 {
        PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mReverseArcs, v,
                                                    as ? PL_DHASH_ADD : PL_DHASH_REMOVE);
        if (as && hdr) {
            Entry* entry = NS_REINTERPRET_CAST(Entry*, hdr);
            entry->mNode = v;
            entry->mAssertions = as;
        } }

Here is the call graph for this function:

Here is the caller graph for this function:

PLDHashOperator PR_CALLBACK InMemoryDataSource::SweepForwardArcsEntries ( PLDHashTable aTable,
PLDHashEntryHdr aHdr,
PRUint32  aNumber,
void aArg 
) [static, protected]

Definition at line 2075 of file nsInMemoryDataSource.cpp.

{
    PLDHashOperator result = PL_DHASH_NEXT;
    Entry* entry = NS_REINTERPRET_CAST(Entry*, aHdr);
    SweepInfo* info = NS_STATIC_CAST(SweepInfo*, aArg);

    Assertion* as = entry->mAssertions;
    if (as && (as->mHashEntry))
    {
        // Stuff in sub-hashes must be swept recursively (max depth: 1)
        PL_DHashTableEnumerate(as->u.hash.mPropertyHash, 
                               SweepForwardArcsEntries, info);

        // If the sub-hash is now empty, clean it up.
        if (!as->u.hash.mPropertyHash->entryCount) {
            Assertion::Destroy(*info->mAllocator, as);
            result = PL_DHASH_REMOVE;
        }

        return result;
    }

    Assertion* prev = nsnull;
    while (as) {
        if (as->IsMarked()) {
            prev = as;
            as->Unmark();
            as = as->mNext;
        }
        else {
            // remove from the list of assertions in the datasource
            Assertion* next = as->mNext;
            if (prev) {
                prev->mNext = next;
            }
            else {
                // it's the first one. update the hashtable entry.
                entry->mAssertions = next;
            }

            // remove from the reverse arcs
            PLDHashEntryHdr* hdr =
                PL_DHashTableOperate(info->mReverseArcs, as->u.as.mTarget, PL_DHASH_LOOKUP);
            NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(hdr), "no assertion in reverse arcs");

            Entry* rentry = NS_REINTERPRET_CAST(Entry*, hdr);
            Assertion* ras = rentry->mAssertions;
            Assertion* rprev = nsnull;
            while (ras) {
                if (ras == as) {
                    if (rprev) {
                        rprev->u.as.mInvNext = ras->u.as.mInvNext;
                    }
                    else {
                        // it's the first one. update the hashtable entry.
                        rentry->mAssertions = ras->u.as.mInvNext;
                    }
                    as->u.as.mInvNext = nsnull; // for my sanity.
                    break;
                }
                rprev = ras;
                ras = ras->u.as.mInvNext;
            }

            // Wow, it was the _only_ one. Unhash it.
            if (! rentry->mAssertions)
            {
                PL_DHashTableRawRemove(info->mReverseArcs, hdr);
            }

            // add to the list of assertions to unassert
            as->mNext = info->mUnassertList;
            info->mUnassertList = as;

            // Advance to the next assertion
            as = next;
        }
    }

    // if no more assertions exist for this resource, then unhash it.
    if (! entry->mAssertions)
        result = PL_DHASH_REMOVE;

    return result;
}

Here is the call graph for this function:

void nsIRDFDataSource::Unassert ( in nsIRDFResource  aSource,
in nsIRDFResource  aProperty,
in nsIRDFNode  aTarget 
) [inherited]

Remove an assertion from the graph.

Here is the caller graph for this function:

Visit all the subject resources in the datasource.

The order is intederminate and may change from one invocation to the next. The subjects will be in the aSubject argument in calls into aVisitor, aPredicate and aObject will be null.

Note:
Implementations may throw NS_ERROR_NOT_IMPLEMENTED for this method, but in this case RDF serializations of this datasource will not be possible.

Visit all the triples in the datasource.

The order is intederminate and may change from one invocation to the next.

Note:
Implementations may throw NS_ERROR_NOT_IMPLEMENTED for this method, but in this case RDF serializations of this datasource will not be possible.

Friends And Related Function Documentation

friend class InMemoryArcsEnumeratorImpl [friend]

Definition at line 338 of file nsInMemoryDataSource.cpp.

friend class InMemoryAssertionEnumeratorImpl [friend]

Definition at line 339 of file nsInMemoryDataSource.cpp.

friend class InMemoryResourceEnumeratorImpl [friend]

Definition at line 340 of file nsInMemoryDataSource.cpp.

NS_IMETHODIMP NS_NewRDFInMemoryDataSource ( nsISupports *  aOuter,
const nsIID aIID,
void **  aResult 
) [friend]

Definition at line 861 of file nsInMemoryDataSource.cpp.

{
    NS_PRECONDITION(aResult != nsnull, "null ptr");
    if (! aResult)
        return NS_ERROR_NULL_POINTER;
    *aResult = nsnull;

    if (aOuter && !aIID.Equals(NS_GET_IID(nsISupports))) {
        NS_ERROR("aggregation requires nsISupports");
        return NS_ERROR_ILLEGAL_VALUE;
    }

    InMemoryDataSource* datasource = new InMemoryDataSource(aOuter);
    if (! datasource)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(datasource);

    nsresult rv = datasource->Init();
    if (NS_SUCCEEDED(rv)) {
        datasource->fAggregated.AddRef();
        rv = datasource->AggregatedQueryInterface(aIID, aResult); // This'll AddRef()
        datasource->fAggregated.Release();
    }

    NS_RELEASE(datasource);
    return rv;
}

Member Data Documentation

nsFixedSizeAllocator InMemoryDataSource::mAllocator [protected]

Definition at line 313 of file nsInMemoryDataSource.cpp.

Definition at line 320 of file nsInMemoryDataSource.cpp.

Definition at line 324 of file nsInMemoryDataSource.cpp.

Definition at line 323 of file nsInMemoryDataSource.cpp.

Definition at line 429 of file nsInMemoryDataSource.cpp.

Definition at line 328 of file nsInMemoryDataSource.cpp.

Definition at line 321 of file nsInMemoryDataSource.cpp.

Set this value to true to enable synchronization notifications.

Set this value to false to disable synchronization notifications.

By default, this value is true.

Definition at line 58 of file nsIRDFPropagatableDataSource.idl.

readonly attribute string nsIRDFDataSource::URI [inherited]

The "URI" of the data source.

This used by the RDF service's |GetDataSource()| method to cache datasources.

Definition at line 56 of file nsIRDFDataSource.idl.


The documentation for this class was generated from the following file: