Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsInMemoryDataSource.cpp File Reference
#include "nsAgg.h"
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsIOutputStream.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFLiteral.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFInMemoryDataSource.h"
#include "nsIRDFPropagatableDataSource.h"
#include "nsIRDFPurgeableDataSource.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsCOMArray.h"
#include "nsEnumeratorUtils.h"
#include "nsVoidArray.h"
#include "nsCRT.h"
#include "nsRDFCID.h"
#include "nsRDFBaseDataSources.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsXPIDLString.h"
#include "nsFixedSizeAllocator.h"
#include "rdfutil.h"
#include "pldhash.h"
#include "plstr.h"
#include "prlog.h"
#include "rdf.h"
#include "rdfIDataSource.h"
#include "rdfITripleVisitor.h"

Go to the source code of this file.

Classes

class  Assertion
struct  Entry
class  InMemoryDataSource
class  InMemoryAssertionEnumeratorImpl
 InMemoryAssertionEnumeratorImpl. More...
class  InMemoryArcsEnumeratorImpl
 This class is a little bit bizarre in that it implements both the nsIRDFArcsOutCursor and nsIRDFArcsInCursor interfaces. More...
struct  SweepInfo
class  VisitorClosure
class  TriplesInnerClosure
union  Assertion.u
struct  hash.u.hash
struct  as.u.as

Functions

NS_IMETHODIMP NS_NewRDFInMemoryDataSource (nsISupports *aOuter, const nsIID &aIID, void **aResult)
PLDHashOperator PR_CALLBACK SubjectEnumerator (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)
PLDHashOperator PR_CALLBACK TriplesInnerEnumerator (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)
PLDHashOperator PR_CALLBACK TriplesEnumerator (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)

Class Documentation

struct Entry

Definition at line 219 of file nsInMemoryDataSource.cpp.

Collaboration diagram for Entry:
Class Members
Assertion * mAssertions
PLDHashEntryHdr mHdr
nsIRDFNode * mNode
struct SweepInfo

Definition at line 2032 of file nsInMemoryDataSource.cpp.

Collaboration diagram for SweepInfo:
Class Members
nsFixedSizeAllocator * mAllocator
PLDHashTable * mReverseArcs
Assertion * mUnassertList
union Assertion.u

Definition at line 188 of file nsInMemoryDataSource.cpp.

Class Members
u as
u hash
struct Assertion::hash.u.hash

Definition at line 190 of file nsInMemoryDataSource.cpp.

Class Members
PLDHashTable * mPropertyHash
struct Assertion::as.u.as

Definition at line 194 of file nsInMemoryDataSource.cpp.

Class Members
Assertion * mInvNext
PRPackedBool mMarked
nsIRDFResource * mProperty
nsIRDFNode * mTarget
PRPackedBool mTruthValue

Function Documentation

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

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;
}

Here is the call graph for this function:

PLDHashOperator PR_CALLBACK SubjectEnumerator ( PLDHashTable aTable,
PLDHashEntryHdr aHdr,
PRUint32  aNumber,
void aArg 
)

Definition at line 2178 of file nsInMemoryDataSource.cpp.

                                                {
    Entry* entry = NS_REINTERPRET_CAST(Entry*, aHdr);
    VisitorClosure* closure = NS_STATIC_CAST(VisitorClosure*, aArg);

    nsresult rv;
    nsCOMPtr<nsIRDFNode> subject = do_QueryInterface(entry->mNode, &rv);
    NS_ENSURE_SUCCESS(rv, PL_DHASH_NEXT);

    closure->mRv = closure->mVisitor->Visit(subject, nsnull, nsnull, PR_TRUE);
    if (NS_FAILED(closure->mRv) || closure->mRv == NS_RDF_STOP_VISIT)
        return PL_DHASH_STOP;

    return PL_DHASH_NEXT;
}

Here is the call graph for this function:

PLDHashOperator PR_CALLBACK TriplesEnumerator ( PLDHashTable aTable,
PLDHashEntryHdr aHdr,
PRUint32  aNumber,
void aArg 
)

Definition at line 2241 of file nsInMemoryDataSource.cpp.

                                                {
    Entry* entry = NS_REINTERPRET_CAST(Entry*, aHdr);
    VisitorClosure* closure = NS_STATIC_CAST(VisitorClosure*, aArg);

    nsresult rv;
    nsCOMPtr<nsIRDFNode> subject = do_QueryInterface(entry->mNode, &rv);
    NS_ENSURE_SUCCESS(rv, PL_DHASH_NEXT);

    if (entry->mAssertions->mHashEntry) {
        TriplesInnerClosure cls(subject, closure);
        PL_DHashTableEnumerate(entry->mAssertions->u.hash.mPropertyHash,
                               TriplesInnerEnumerator, &cls);
        if (NS_FAILED(closure->mRv)) {
            return PL_DHASH_STOP;
        }
        return PL_DHASH_NEXT;
    }
    Assertion* assertion = entry->mAssertions;
    while (assertion) {
        NS_ASSERTION(!assertion->mHashEntry, "shouldn't have to hashes");
        closure->mRv = closure->mVisitor->Visit(subject,
                                                assertion->u.as.mProperty,
                                                assertion->u.as.mTarget,
                                                assertion->u.as.mTruthValue);
        if (NS_FAILED(closure->mRv) || closure->mRv == NS_RDF_STOP_VISIT) {
            return PL_DHASH_STOP;
        }
        assertion = assertion->mNext;
    }
    return PL_DHASH_NEXT;
}

Here is the call graph for this function:

Definition at line 2220 of file nsInMemoryDataSource.cpp.

                                                {
    Entry* entry = NS_REINTERPRET_CAST(Entry*, aHdr);
    Assertion* assertion = entry->mAssertions;
    TriplesInnerClosure* closure = 
        NS_STATIC_CAST(TriplesInnerClosure*, aArg);
    while (assertion) {
        NS_ASSERTION(!assertion->mHashEntry, "shouldn't have to hashes");
        VisitorClosure* cls = closure->mOuter;
        cls->mRv = cls->mVisitor->Visit(closure->mSubject,
                                        assertion->u.as.mProperty,
                                        assertion->u.as.mTarget,
                                        assertion->u.as.mTruthValue);
        if (NS_FAILED(cls->mRv) || cls->mRv == NS_RDF_STOP_VISIT) {
            return PL_DHASH_STOP;
        }
        assertion = assertion->mNext;
    }
    return PL_DHASH_NEXT;
}

Here is the caller graph for this function: