Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
InMemoryArcsEnumeratorImpl Class Reference

This class is a little bit bizarre in that it implements both the nsIRDFArcsOutCursor and nsIRDFArcsInCursor interfaces. More...

Inheritance diagram for InMemoryArcsEnumeratorImpl:
Inheritance graph
[legend]
Collaboration diagram for InMemoryArcsEnumeratorImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

boolean hasMoreElements ()
 Called to determine whether or not the enumerator has any elements that can be returned via getNext().
nsISupports getNext ()
 Called to retrieve the next element in the enumerator.

Static Public Member Functions

NS_DECL_ISUPPORTS static
NS_DECL_NSISIMPLEENUMERATOR
InMemoryArcsEnumeratorImpl
Create (InMemoryDataSource *aDataSource, nsIRDFResource *aSource, nsIRDFNode *aTarget)
static void Destroy (InMemoryArcsEnumeratorImpl *aEnumerator)

Private Member Functions

 InMemoryArcsEnumeratorImpl (InMemoryDataSource *aDataSource, nsIRDFResource *aSource, nsIRDFNode *aTarget)
virtual ~InMemoryArcsEnumeratorImpl ()

Static Private Member Functions

static voidoperator new (size_t) CPP_THROW_NEW
static void operator delete (void *, size_t)
static PLDHashOperator PR_CALLBACK ArcEnumerator (PLDHashTable *aTable, PLDHashEntryHdr *aHdr, PRUint32 aNumber, void *aArg)

Private Attributes

InMemoryDataSourcemDataSource
nsIRDFResourcemSource
nsIRDFNodemTarget
nsAutoVoidArray mAlreadyReturned
nsIRDFResourcemCurrent
AssertionmAssertion
nsCOMPtr< nsISupportsArraymHashArcs

Detailed Description

This class is a little bit bizarre in that it implements both the nsIRDFArcsOutCursor and nsIRDFArcsInCursor interfaces.

Because the structure of the in-memory graph is pretty flexible, it's fairly easy to parameterize this class. The only funky thing to watch out for is the mutliple inheiritance clashes.

Definition at line 641 of file nsInMemoryDataSource.cpp.


Constructor & Destructor Documentation

Definition at line 710 of file nsInMemoryDataSource.cpp.

    : mDataSource(aDataSource),
      mSource(aSource),
      mTarget(aTarget),
      mCurrent(nsnull)
{
    NS_ADDREF(mDataSource);
    NS_IF_ADDREF(mSource);
    NS_IF_ADDREF(mTarget);

    if (mSource) {
        // cast okay because it's a closed system
        mAssertion = mDataSource->GetForwardArcs(mSource);

        if (mAssertion && mAssertion->mHashEntry) {
            // its our magical HASH_ENTRY forward hash for assertions
            nsresult rv = NS_NewISupportsArray(getter_AddRefs(mHashArcs));
            if (NS_SUCCEEDED(rv)) {
                PL_DHashTableEnumerate(mAssertion->u.hash.mPropertyHash,
                    ArcEnumerator, mHashArcs.get());
            }
            mAssertion = nsnull;
        }
    }
    else {
        mAssertion = mDataSource->GetReverseArcs(mTarget);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 741 of file nsInMemoryDataSource.cpp.

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

    NS_RELEASE(mDataSource);
    NS_IF_RELEASE(mSource);
    NS_IF_RELEASE(mTarget);
    NS_IF_RELEASE(mCurrent);

    for (PRInt32 i = mAlreadyReturned.Count() - 1; i >= 0; --i) {
        nsIRDFResource* resource = (nsIRDFResource*) mAlreadyReturned[i];
        NS_RELEASE(resource);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

PLDHashOperator PR_CALLBACK InMemoryArcsEnumeratorImpl::ArcEnumerator ( PLDHashTable aTable,
PLDHashEntryHdr aHdr,
PRUint32  aNumber,
void aArg 
) [static, private]

Definition at line 698 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:

Here is the caller graph for this function:

NS_DECL_ISUPPORTS static NS_DECL_NSISIMPLEENUMERATOR InMemoryArcsEnumeratorImpl* InMemoryArcsEnumeratorImpl::Create ( InMemoryDataSource aDataSource,
nsIRDFResource aSource,
nsIRDFNode aTarget 
) [inline, static]

Definition at line 675 of file nsInMemoryDataSource.cpp.

                                {
        void* place = aDataSource->mAllocator.Alloc(sizeof(InMemoryArcsEnumeratorImpl));
        return place
            ? ::new (place) InMemoryArcsEnumeratorImpl(aDataSource, aSource, aTarget)
            : nsnull; }

Here is the call graph for this function:

static void InMemoryArcsEnumeratorImpl::Destroy ( InMemoryArcsEnumeratorImpl aEnumerator) [inline, static]

Definition at line 684 of file nsInMemoryDataSource.cpp.

                                                     {
        // Keep the datasource alive for the duration of the stack
        // frame so its allocator stays valid.
        nsCOMPtr<nsIRDFDataSource> kungFuDeathGrip = aEnumerator->mDataSource;

        // Grab the pool from the datasource; since we keep the
        // datasource alive, this has to be safe.
        nsFixedSizeAllocator& pool = aEnumerator->mDataSource->mAllocator;
        aEnumerator->~InMemoryArcsEnumeratorImpl();
        pool.Free(aEnumerator, sizeof(*aEnumerator)); }

Here is the call graph for this function:

nsISupports nsISimpleEnumerator::getNext ( ) [inherited]

Called to retrieve the next element in the enumerator.

The "next" element is the first element upon the first call. Must be pre-ceeded by a call to hasMoreElements() which returns PR_TRUE. This method is generally called within a loop to iterate over the elements in the enumerator.

See also:
hasMoreElements()
Returns:
NS_OK if the call succeeded in returning a non-null value through the out parameter. NS_ERROR_FAILURE if there are no more elements to enumerate.
the next element in the enumeration.

Here is the caller graph for this function:

Called to determine whether or not the enumerator has any elements that can be returned via getNext().

This method is generally used to determine whether or not to initiate or continue iteration over the enumerator, though it can be called without subsequent getNext() calls. Does not affect internal state of enumerator.

See also:
getNext()
Returns:
PR_TRUE if there are remaining elements in the enumerator. PR_FALSE if there are no more elements in the enumerator.

Here is the caller graph for this function:

static void InMemoryArcsEnumeratorImpl::operator delete ( void ,
size_t   
) [inline, static, private]

Definition at line 647 of file nsInMemoryDataSource.cpp.

{}
static void* InMemoryArcsEnumeratorImpl::operator new ( size_t  ) [inline, static, private]

Definition at line 646 of file nsInMemoryDataSource.cpp.

{ return 0; }

Member Data Documentation

Definition at line 652 of file nsInMemoryDataSource.cpp.

Definition at line 654 of file nsInMemoryDataSource.cpp.

Definition at line 653 of file nsInMemoryDataSource.cpp.

Definition at line 649 of file nsInMemoryDataSource.cpp.

Definition at line 655 of file nsInMemoryDataSource.cpp.

Definition at line 650 of file nsInMemoryDataSource.cpp.

Definition at line 651 of file nsInMemoryDataSource.cpp.


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