michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsISupportsArray.idl" michael@0: #include "nsIRDFResource.idl" michael@0: #include "nsIRDFNode.idl" michael@0: #include "nsISimpleEnumerator.idl" michael@0: #include "nsIRDFObserver.idl" michael@0: michael@0: [scriptable, uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)] michael@0: interface nsIRDFDataSource : nsISupports michael@0: { michael@0: /** The "URI" of the data source. This used by the RDF service's michael@0: * |GetDataSource()| method to cache datasources. michael@0: */ michael@0: readonly attribute string URI; michael@0: michael@0: /** Find an RDF resource that points to a given node over the michael@0: * specified arc & truth value michael@0: * michael@0: * @throws NS_RDF_NO_VALUE if there is no source that leads michael@0: * to the target with the specified property. michael@0: */ michael@0: nsIRDFResource GetSource(in nsIRDFResource aProperty, michael@0: in nsIRDFNode aTarget, michael@0: in boolean aTruthValue); michael@0: michael@0: /** michael@0: * Find all RDF resources that point to a given node over the michael@0: * specified arc & truth value michael@0: */ michael@0: nsISimpleEnumerator GetSources(in nsIRDFResource aProperty, michael@0: in nsIRDFNode aTarget, michael@0: in boolean aTruthValue); michael@0: michael@0: /** michael@0: * Find a child of that is related to the source by the given arc michael@0: * arc and truth value michael@0: * michael@0: * @throws NS_RDF_NO_VALUE if there is no target accessible from the michael@0: * source via the specified property. michael@0: */ michael@0: nsIRDFNode GetTarget(in nsIRDFResource aSource, michael@0: in nsIRDFResource aProperty, michael@0: in boolean aTruthValue); michael@0: michael@0: /** michael@0: * Find all children of that are related to the source by the given arc michael@0: * arc and truth value. michael@0: */ michael@0: nsISimpleEnumerator GetTargets(in nsIRDFResource aSource, michael@0: in nsIRDFResource aProperty, michael@0: in boolean aTruthValue); michael@0: michael@0: /** michael@0: * Add an assertion to the graph. michael@0: */ michael@0: void Assert(in nsIRDFResource aSource, michael@0: in nsIRDFResource aProperty, michael@0: in nsIRDFNode aTarget, michael@0: in boolean aTruthValue); michael@0: michael@0: /** michael@0: * Remove an assertion from the graph. michael@0: */ michael@0: void Unassert(in nsIRDFResource aSource, michael@0: in nsIRDFResource aProperty, michael@0: in nsIRDFNode aTarget); michael@0: michael@0: /** michael@0: * Change an assertion from michael@0: * michael@0: * [aSource]--[aProperty]-->[aOldTarget] michael@0: * michael@0: * to michael@0: * michael@0: * [aSource]--[aProperty]-->[aNewTarget] michael@0: */ michael@0: void Change(in nsIRDFResource aSource, michael@0: in nsIRDFResource aProperty, michael@0: in nsIRDFNode aOldTarget, michael@0: in nsIRDFNode aNewTarget); michael@0: michael@0: /** michael@0: * 'Move' an assertion from michael@0: * michael@0: * [aOldSource]--[aProperty]-->[aTarget] michael@0: * michael@0: * to michael@0: * michael@0: * [aNewSource]--[aProperty]-->[aTarget] michael@0: */ michael@0: void Move(in nsIRDFResource aOldSource, michael@0: in nsIRDFResource aNewSource, michael@0: in nsIRDFResource aProperty, michael@0: in nsIRDFNode aTarget); michael@0: michael@0: /** michael@0: * Query whether an assertion exists in this graph. michael@0: */ michael@0: boolean HasAssertion(in nsIRDFResource aSource, michael@0: in nsIRDFResource aProperty, michael@0: in nsIRDFNode aTarget, michael@0: in boolean aTruthValue); michael@0: michael@0: /** michael@0: * Add an observer to this data source. If the datasource michael@0: * supports observers, the datasource source should hold a strong michael@0: * reference to the observer. michael@0: */ michael@0: void AddObserver(in nsIRDFObserver aObserver); michael@0: michael@0: /** michael@0: * Remove an observer from this data source. michael@0: */ michael@0: void RemoveObserver(in nsIRDFObserver aObserver); michael@0: michael@0: /** michael@0: * Get a cursor to iterate over all the arcs that point into a node. michael@0: */ michael@0: nsISimpleEnumerator ArcLabelsIn(in nsIRDFNode aNode); michael@0: michael@0: /** michael@0: * Get a cursor to iterate over all the arcs that originate in michael@0: * a resource. michael@0: */ michael@0: nsISimpleEnumerator ArcLabelsOut(in nsIRDFResource aSource); michael@0: michael@0: /** michael@0: * Retrieve all of the resources that the data source currently michael@0: * refers to. michael@0: */ michael@0: nsISimpleEnumerator GetAllResources(); michael@0: michael@0: /** michael@0: * Returns whether a given command is enabled for a set of sources. michael@0: */ michael@0: boolean IsCommandEnabled(in nsISupportsArray aSources, michael@0: in nsIRDFResource aCommand, michael@0: in nsISupportsArray aArguments); michael@0: michael@0: /** michael@0: * Perform the specified command on set of sources. michael@0: */ michael@0: void DoCommand(in nsISupportsArray aSources, michael@0: in nsIRDFResource aCommand, michael@0: in nsISupportsArray aArguments); michael@0: michael@0: /** michael@0: * Returns the set of all commands defined for a given source. michael@0: */ michael@0: nsISimpleEnumerator GetAllCmds(in nsIRDFResource aSource); michael@0: michael@0: /** michael@0: * Returns true if the specified node is pointed to by the specified arc. michael@0: * Equivalent to enumerating ArcLabelsIn and comparing for the specified arc. michael@0: */ michael@0: boolean hasArcIn(in nsIRDFNode aNode, in nsIRDFResource aArc); michael@0: michael@0: /** michael@0: * Returns true if the specified node has the specified outward arc. michael@0: * Equivalent to enumerating ArcLabelsOut and comparing for the specified arc. michael@0: */ michael@0: boolean hasArcOut(in nsIRDFResource aSource, in nsIRDFResource aArc); michael@0: michael@0: /** michael@0: * Notify observers that the datasource is about to send several michael@0: * notifications at once. michael@0: * This must be followed by calling endUpdateBatch(), otherwise michael@0: * viewers will get out of sync. michael@0: */ michael@0: void beginUpdateBatch(); michael@0: michael@0: /** michael@0: * Notify observers that the datasource has completed issuing michael@0: * a notification group. michael@0: */ michael@0: void endUpdateBatch(); michael@0: };