1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Jan Varga <varga@ku.sk>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include
"nsISupports.idl"
40 #include
"nsISupportsArray.idl"
41 #include
"nsIRDFResource.idl"
42 #include
"nsIRDFNode.idl"
43 #include
"nsISimpleEnumerator.idl"
44 #include
"nsIRDFObserver.idl"
47 #include
"nsISupportsArray.h"
50 [scriptable
, uuid(0F78DA58
-8321-11d2
-8EAC
-00805F29F370
)]
51 interface nsIRDFDataSource
: nsISupports
53 /** The "URI" of the data source. This used by the RDF service's
54 * |GetDataSource()| method to cache datasources.
56 readonly attribute
string URI
;
58 /** Find an RDF resource that points to a given node over the
59 * specified arc & truth value
61 * @return NS_RDF_NO_VALUE if there is no source that leads
62 * to the target with the specified property.
64 nsIRDFResource GetSource
(in nsIRDFResource aProperty
,
65 in nsIRDFNode aTarget
,
66 in boolean aTruthValue
);
69 * Find all RDF resources that point to a given node over the
70 * specified arc & truth value
72 * @return NS_OK unless a catastrophic error occurs. If the
73 * method returns NS_OK, you may assume that nsISimpleEnumerator points
74 * to a valid (but possibly empty) cursor.
76 nsISimpleEnumerator GetSources
(in nsIRDFResource aProperty
,
77 in nsIRDFNode aTarget
,
78 in boolean aTruthValue
);
81 * Find a child of that is related to the source by the given arc
84 * @return NS_RDF_NO_VALUE if there is no target accessible from the
85 * source via the specified property.
87 nsIRDFNode GetTarget
(in nsIRDFResource aSource
,
88 in nsIRDFResource aProperty
,
89 in boolean aTruthValue
);
92 * Find all children of that are related to the source by the given arc
93 * arc and truth value.
95 * @return NS_OK unless a catastrophic error occurs. If the
96 * method returns NS_OK, you may assume that nsISimpleEnumerator points
97 * to a valid (but possibly empty) cursor.
99 nsISimpleEnumerator GetTargets
(in nsIRDFResource aSource
,
100 in nsIRDFResource aProperty
,
101 in boolean aTruthValue
);
104 * Add an assertion to the graph.
106 void Assert
(in nsIRDFResource aSource
,
107 in nsIRDFResource aProperty
,
108 in nsIRDFNode aTarget
,
109 in boolean aTruthValue
);
112 * Remove an assertion from the graph.
114 void Unassert
(in nsIRDFResource aSource
,
115 in nsIRDFResource aProperty
,
116 in nsIRDFNode aTarget
);
119 * Change an assertion from
121 * [aSource]--[aProperty]-->[aOldTarget]
125 * [aSource]--[aProperty]-->[aNewTarget]
127 void Change
(in nsIRDFResource aSource
,
128 in nsIRDFResource aProperty
,
129 in nsIRDFNode aOldTarget
,
130 in nsIRDFNode aNewTarget
);
133 * 'Move' an assertion from
135 * [aOldSource]--[aProperty]-->[aTarget]
139 * [aNewSource]--[aProperty]-->[aTarget]
141 void Move
(in nsIRDFResource aOldSource
,
142 in nsIRDFResource aNewSource
,
143 in nsIRDFResource aProperty
,
144 in nsIRDFNode aTarget
);
147 * Query whether an assertion exists in this graph.
149 boolean HasAssertion
(in nsIRDFResource aSource
,
150 in nsIRDFResource aProperty
,
151 in nsIRDFNode aTarget
,
152 in boolean aTruthValue
);
155 * Add an observer to this data source. If the datasource
156 * supports observers, the datasource source should hold a strong
157 * reference to the observer.
159 void AddObserver
(in nsIRDFObserver aObserver
);
162 * Remove an observer from this data source.
164 void RemoveObserver
(in nsIRDFObserver aObserver
);
167 * Get a cursor to iterate over all the arcs that point into a node.
169 * @return NS_OK unless a catastrophic error occurs. If the method
170 * returns NS_OK, you may assume that labels points to a valid (but
171 * possible empty) nsISimpleEnumerator object.
173 nsISimpleEnumerator ArcLabelsIn
(in nsIRDFNode aNode
);
176 * Get a cursor to iterate over all the arcs that originate in
179 * @return NS_OK unless a catastrophic error occurs. If the method
180 * returns NS_OK, you may assume that labels points to a valid (but
181 * possible empty) nsISimpleEnumerator object.
183 nsISimpleEnumerator ArcLabelsOut
(in nsIRDFResource aSource
);
186 * Retrieve all of the resources that the data source currently
189 nsISimpleEnumerator GetAllResources
();
192 * Returns whether a given command is enabled for a set of sources.
194 boolean IsCommandEnabled
(in nsISupportsArray aSources
,
195 in nsIRDFResource aCommand
,
196 in nsISupportsArray aArguments
);
199 * Perform the specified command on set of sources.
201 void DoCommand
(in nsISupportsArray aSources
,
202 in nsIRDFResource aCommand
,
203 in nsISupportsArray aArguments
);
206 * Returns the set of all commands defined for a given source.
208 nsISimpleEnumerator GetAllCmds
(in nsIRDFResource aSource
);
211 * Returns true if the specified node is pointed to by the specified arc.
212 * Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.
214 boolean hasArcIn
(in nsIRDFNode aNode
, in nsIRDFResource aArc
);
217 * Returns true if the specified node has the specified outward arc.
218 * Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.
220 boolean hasArcOut
(in nsIRDFResource aSource
, in nsIRDFResource aArc
);
223 * Notify observers that the datasource is about to send several
224 * notifications at once.
225 * This must be followed by calling endUpdateBatch(), otherwise
226 * viewers will get out of sync.
228 void beginUpdateBatch
();
231 * Notify observers that the datasource has completed issuing
232 * a notification group.
234 void endUpdateBatch
();