1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/rdf/base/idl/nsIRDFDataSource.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,182 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 +#include "nsISupportsArray.idl" 1.11 +#include "nsIRDFResource.idl" 1.12 +#include "nsIRDFNode.idl" 1.13 +#include "nsISimpleEnumerator.idl" 1.14 +#include "nsIRDFObserver.idl" 1.15 + 1.16 +[scriptable, uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)] 1.17 +interface nsIRDFDataSource : nsISupports 1.18 +{ 1.19 + /** The "URI" of the data source. This used by the RDF service's 1.20 + * |GetDataSource()| method to cache datasources. 1.21 + */ 1.22 + readonly attribute string URI; 1.23 + 1.24 + /** Find an RDF resource that points to a given node over the 1.25 + * specified arc & truth value 1.26 + * 1.27 + * @throws NS_RDF_NO_VALUE if there is no source that leads 1.28 + * to the target with the specified property. 1.29 + */ 1.30 + nsIRDFResource GetSource(in nsIRDFResource aProperty, 1.31 + in nsIRDFNode aTarget, 1.32 + in boolean aTruthValue); 1.33 + 1.34 + /** 1.35 + * Find all RDF resources that point to a given node over the 1.36 + * specified arc & truth value 1.37 + */ 1.38 + nsISimpleEnumerator GetSources(in nsIRDFResource aProperty, 1.39 + in nsIRDFNode aTarget, 1.40 + in boolean aTruthValue); 1.41 + 1.42 + /** 1.43 + * Find a child of that is related to the source by the given arc 1.44 + * arc and truth value 1.45 + * 1.46 + * @throws NS_RDF_NO_VALUE if there is no target accessible from the 1.47 + * source via the specified property. 1.48 + */ 1.49 + nsIRDFNode GetTarget(in nsIRDFResource aSource, 1.50 + in nsIRDFResource aProperty, 1.51 + in boolean aTruthValue); 1.52 + 1.53 + /** 1.54 + * Find all children of that are related to the source by the given arc 1.55 + * arc and truth value. 1.56 + */ 1.57 + nsISimpleEnumerator GetTargets(in nsIRDFResource aSource, 1.58 + in nsIRDFResource aProperty, 1.59 + in boolean aTruthValue); 1.60 + 1.61 + /** 1.62 + * Add an assertion to the graph. 1.63 + */ 1.64 + void Assert(in nsIRDFResource aSource, 1.65 + in nsIRDFResource aProperty, 1.66 + in nsIRDFNode aTarget, 1.67 + in boolean aTruthValue); 1.68 + 1.69 + /** 1.70 + * Remove an assertion from the graph. 1.71 + */ 1.72 + void Unassert(in nsIRDFResource aSource, 1.73 + in nsIRDFResource aProperty, 1.74 + in nsIRDFNode aTarget); 1.75 + 1.76 + /** 1.77 + * Change an assertion from 1.78 + * 1.79 + * [aSource]--[aProperty]-->[aOldTarget] 1.80 + * 1.81 + * to 1.82 + * 1.83 + * [aSource]--[aProperty]-->[aNewTarget] 1.84 + */ 1.85 + void Change(in nsIRDFResource aSource, 1.86 + in nsIRDFResource aProperty, 1.87 + in nsIRDFNode aOldTarget, 1.88 + in nsIRDFNode aNewTarget); 1.89 + 1.90 + /** 1.91 + * 'Move' an assertion from 1.92 + * 1.93 + * [aOldSource]--[aProperty]-->[aTarget] 1.94 + * 1.95 + * to 1.96 + * 1.97 + * [aNewSource]--[aProperty]-->[aTarget] 1.98 + */ 1.99 + void Move(in nsIRDFResource aOldSource, 1.100 + in nsIRDFResource aNewSource, 1.101 + in nsIRDFResource aProperty, 1.102 + in nsIRDFNode aTarget); 1.103 + 1.104 + /** 1.105 + * Query whether an assertion exists in this graph. 1.106 + */ 1.107 + boolean HasAssertion(in nsIRDFResource aSource, 1.108 + in nsIRDFResource aProperty, 1.109 + in nsIRDFNode aTarget, 1.110 + in boolean aTruthValue); 1.111 + 1.112 + /** 1.113 + * Add an observer to this data source. If the datasource 1.114 + * supports observers, the datasource source should hold a strong 1.115 + * reference to the observer. 1.116 + */ 1.117 + void AddObserver(in nsIRDFObserver aObserver); 1.118 + 1.119 + /** 1.120 + * Remove an observer from this data source. 1.121 + */ 1.122 + void RemoveObserver(in nsIRDFObserver aObserver); 1.123 + 1.124 + /** 1.125 + * Get a cursor to iterate over all the arcs that point into a node. 1.126 + */ 1.127 + nsISimpleEnumerator ArcLabelsIn(in nsIRDFNode aNode); 1.128 + 1.129 + /** 1.130 + * Get a cursor to iterate over all the arcs that originate in 1.131 + * a resource. 1.132 + */ 1.133 + nsISimpleEnumerator ArcLabelsOut(in nsIRDFResource aSource); 1.134 + 1.135 + /** 1.136 + * Retrieve all of the resources that the data source currently 1.137 + * refers to. 1.138 + */ 1.139 + nsISimpleEnumerator GetAllResources(); 1.140 + 1.141 + /** 1.142 + * Returns whether a given command is enabled for a set of sources. 1.143 + */ 1.144 + boolean IsCommandEnabled(in nsISupportsArray aSources, 1.145 + in nsIRDFResource aCommand, 1.146 + in nsISupportsArray aArguments); 1.147 + 1.148 + /** 1.149 + * Perform the specified command on set of sources. 1.150 + */ 1.151 + void DoCommand(in nsISupportsArray aSources, 1.152 + in nsIRDFResource aCommand, 1.153 + in nsISupportsArray aArguments); 1.154 + 1.155 + /** 1.156 + * Returns the set of all commands defined for a given source. 1.157 + */ 1.158 + nsISimpleEnumerator GetAllCmds(in nsIRDFResource aSource); 1.159 + 1.160 + /** 1.161 + * Returns true if the specified node is pointed to by the specified arc. 1.162 + * Equivalent to enumerating ArcLabelsIn and comparing for the specified arc. 1.163 + */ 1.164 + boolean hasArcIn(in nsIRDFNode aNode, in nsIRDFResource aArc); 1.165 + 1.166 + /** 1.167 + * Returns true if the specified node has the specified outward arc. 1.168 + * Equivalent to enumerating ArcLabelsOut and comparing for the specified arc. 1.169 + */ 1.170 + boolean hasArcOut(in nsIRDFResource aSource, in nsIRDFResource aArc); 1.171 + 1.172 + /** 1.173 + * Notify observers that the datasource is about to send several 1.174 + * notifications at once. 1.175 + * This must be followed by calling endUpdateBatch(), otherwise 1.176 + * viewers will get out of sync. 1.177 + */ 1.178 + void beginUpdateBatch(); 1.179 + 1.180 + /** 1.181 + * Notify observers that the datasource has completed issuing 1.182 + * a notification group. 1.183 + */ 1.184 + void endUpdateBatch(); 1.185 +};