mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 18631. Add GetDataSources() method to nsIRDFCompositeDataSource. r=scottip,rjc
This commit is contained in:
parent
f428189b73
commit
46e921da0f
@ -448,6 +448,11 @@ NS_IMETHODIMP nsMessageViewDataSource::RemoveDataSource(nsIRDFDataSource* source
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::GetDataSources(nsISimpleEnumerator** _result)
|
||||
{
|
||||
return NS_NewSingletonEnumerator(_result, mDataSource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
|
@ -22,19 +22,60 @@
|
||||
|
||||
#include "nsIRDFDataSource.idl"
|
||||
|
||||
// An nsIRDFCompositeDataSource composes individual data sources, providing
|
||||
// the illusion of a single, coherent RDF graph.
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
/**
|
||||
* An nsIRDFCompositeDataSource composes individual data sources, providing
|
||||
* the illusion of a single, coherent RDF graph.
|
||||
*/
|
||||
[scriptable, uuid(96343820-307C-11D2-BC15-00805F912FE7)]
|
||||
interface nsIRDFCompositeDataSource : nsIRDFDataSource {
|
||||
|
||||
attribute boolean allowNegativeAssertions; // true by default
|
||||
attribute boolean coalesceDuplicateArcs; // true by default
|
||||
/**
|
||||
*
|
||||
* Set this value to <code>true</code> if the composite datasource
|
||||
* may contains at least one datasource that has <em>negative</em>
|
||||
* assertions. (This is the default.)
|
||||
*
|
||||
* Set this value to <code>false</code> if none of the datasources
|
||||
* being composed contains a negative assertion. This allows the
|
||||
* composite datasource to perform some query optimizations.
|
||||
*
|
||||
* By default, this value is <code>true</true>.
|
||||
*/
|
||||
attribute boolean allowNegativeAssertions;
|
||||
|
||||
// Add a datasource the the database.
|
||||
/**
|
||||
* Set to <code>true</code> if the composite datasource should
|
||||
* take care to coalesce duplicate arcs when returning values from
|
||||
* queries. (This is the default.)
|
||||
*
|
||||
* Set to <code>false</code> if the composite datasource shouldn't
|
||||
* bother to check for duplicates. This allows the composite
|
||||
* datasource to more efficiently answer queries.
|
||||
*
|
||||
* By default, this value is <code>true</code>.
|
||||
*/
|
||||
attribute boolean coalesceDuplicateArcs;
|
||||
|
||||
/**
|
||||
* Add a datasource the the composite data source.
|
||||
* @param aDataSource the datasource to add to composite
|
||||
*/
|
||||
void AddDataSource(in nsIRDFDataSource aDataSource);
|
||||
|
||||
// Remove a datasource from the database
|
||||
/**
|
||||
* Remove a datasource from the composite data source.
|
||||
* @param aDataSource the datasource to remove from the composite
|
||||
*/
|
||||
void RemoveDataSource(in nsIRDFDataSource aDataSource);
|
||||
|
||||
/**
|
||||
* Retrieve the datasources in the composite data source.
|
||||
* @return an nsISimpleEnumerator that will enumerate each
|
||||
* of the datasources in the composite
|
||||
*/
|
||||
nsISimpleEnumerator GetDataSources();
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
@ -65,8 +65,10 @@ PRLogModuleInfo* nsRDFLog = nsnull;
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// CompositeDataSourceImpl
|
||||
//
|
||||
|
||||
class CompositeDataSourceImpl : public nsIRDFCompositeDataSource,
|
||||
public nsIRDFObserver
|
||||
@ -102,9 +104,7 @@ protected:
|
||||
virtual ~CompositeDataSourceImpl(void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// CompositeEnumeratorImpl
|
||||
//
|
||||
@ -158,11 +158,6 @@ CompositeEnumeratorImpl::CompositeEnumeratorImpl(CompositeDataSourceImpl* aCompo
|
||||
|
||||
CompositeEnumeratorImpl::~CompositeEnumeratorImpl(void)
|
||||
{
|
||||
#ifdef DEBUG_REFS
|
||||
--gInstanceCount;
|
||||
fprintf(stdout, "%d - RDF: CompositeEnumeratorImpl\n", gInstanceCount);
|
||||
#endif
|
||||
|
||||
if (mCoalesceDuplicateArcs == PR_TRUE)
|
||||
{
|
||||
for (PRInt32 i = mAlreadyReturned.Count() - 1; i >= 0; --i)
|
||||
@ -341,7 +336,7 @@ CompositeEnumeratorImpl::GetNext(nsISupports** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// CompositeArcsInOutEnumeratorImpl
|
||||
//
|
||||
@ -391,11 +386,6 @@ CompositeArcsInOutEnumeratorImpl::CompositeArcsInOutEnumeratorImpl(
|
||||
|
||||
CompositeArcsInOutEnumeratorImpl::~CompositeArcsInOutEnumeratorImpl()
|
||||
{
|
||||
#ifdef DEBUG_REFS
|
||||
--gInstanceCount;
|
||||
fprintf(stdout, "%d - RDF: CompositeArcsInOutEnumeratorImpl\n", gInstanceCount);
|
||||
#endif
|
||||
|
||||
NS_RELEASE(mNode);
|
||||
}
|
||||
|
||||
@ -425,7 +415,7 @@ CompositeArcsInOutEnumeratorImpl::HasNegation(
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// CompositeAssertionEnumeratorImpl
|
||||
//
|
||||
@ -482,11 +472,6 @@ CompositeAssertionEnumeratorImpl::CompositeAssertionEnumeratorImpl(
|
||||
|
||||
CompositeAssertionEnumeratorImpl::~CompositeAssertionEnumeratorImpl()
|
||||
{
|
||||
#ifdef DEBUG_REFS
|
||||
--gInstanceCount;
|
||||
fprintf(stdout, "%d - RDF: CompositeAssertionEnumeratorImpl\n", gInstanceCount);
|
||||
#endif
|
||||
|
||||
NS_IF_RELEASE(mSource);
|
||||
NS_RELEASE(mProperty);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
@ -552,14 +537,12 @@ CompositeDataSourceImpl::CompositeDataSourceImpl(void)
|
||||
|
||||
CompositeDataSourceImpl::~CompositeDataSourceImpl(void)
|
||||
{
|
||||
#ifdef DEBUG_REFS
|
||||
--gInstanceCount;
|
||||
fprintf(stdout, "%d - RDF: CompositeDataSourceImpl\n", gInstanceCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsISupports interface
|
||||
//
|
||||
|
||||
NS_IMPL_ADDREF(CompositeDataSourceImpl);
|
||||
|
||||
@ -620,8 +603,10 @@ CompositeDataSourceImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFDataSource interface
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetURI(char* *uri)
|
||||
@ -1369,6 +1354,24 @@ CompositeDataSourceImpl::RemoveDataSource(nsIRDFDataSource* aDataSource)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetDataSources(nsISimpleEnumerator** _result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Create an nsISupportsArray, copy the datasources into it, then
|
||||
// use that to create an array enumerator.
|
||||
nsCOMPtr<nsISupportsArray> temp;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(temp));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
for (PRInt32 i = 0; i < mDataSources.Count(); ++i)
|
||||
temp->AppendElement(NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]));
|
||||
|
||||
return NS_NewArrayEnumerator(_result, temp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::OnAssert(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
|
Loading…
x
Reference in New Issue
Block a user