rdf/base/idl/nsIRDFDataSource.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "nsISupports.idl"
     7 #include "nsISupportsArray.idl"
     8 #include "nsIRDFResource.idl"
     9 #include "nsIRDFNode.idl"
    10 #include "nsISimpleEnumerator.idl"
    11 #include "nsIRDFObserver.idl"
    13 [scriptable, uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)]
    14 interface nsIRDFDataSource : nsISupports
    15 {
    16     /** The "URI" of the data source. This used by the RDF service's
    17      * |GetDataSource()| method to cache datasources.
    18      */
    19     readonly attribute string URI;
    21     /** Find an RDF resource that points to a given node over the
    22      * specified arc & truth value
    23      *
    24      * @throws NS_RDF_NO_VALUE if there is no source that leads
    25      * to the target with the specified property.
    26      */
    27     nsIRDFResource GetSource(in nsIRDFResource aProperty,
    28                              in nsIRDFNode     aTarget,
    29                              in boolean        aTruthValue);
    31     /**
    32      * Find all RDF resources that point to a given node over the
    33      * specified arc & truth value
    34      */
    35     nsISimpleEnumerator GetSources(in nsIRDFResource aProperty,
    36                                    in nsIRDFNode     aTarget,
    37                                    in boolean        aTruthValue);
    39     /**
    40      * Find a child of that is related to the source by the given arc
    41      * arc and truth value
    42      *
    43      * @throws NS_RDF_NO_VALUE if there is no target accessible from the
    44      * source via the specified property.
    45      */
    46     nsIRDFNode GetTarget(in nsIRDFResource aSource,
    47                          in nsIRDFResource aProperty,
    48                          in boolean        aTruthValue);
    50     /**
    51      * Find all children of that are related to the source by the given arc
    52      * arc and truth value.
    53      */
    54     nsISimpleEnumerator GetTargets(in nsIRDFResource aSource,
    55                                    in nsIRDFResource aProperty,
    56                                    in boolean aTruthValue);
    58     /**
    59      * Add an assertion to the graph.
    60      */
    61     void Assert(in nsIRDFResource aSource, 
    62                 in nsIRDFResource aProperty, 
    63                 in nsIRDFNode     aTarget,
    64                 in boolean        aTruthValue);
    66     /**
    67      * Remove an assertion from the graph.
    68      */
    69     void Unassert(in nsIRDFResource aSource,
    70                   in nsIRDFResource aProperty,
    71                   in nsIRDFNode     aTarget);
    73     /**
    74      * Change an assertion from
    75      *
    76      *   [aSource]--[aProperty]-->[aOldTarget]
    77      *
    78      * to
    79      * 
    80      *   [aSource]--[aProperty]-->[aNewTarget]
    81      */
    82     void Change(in nsIRDFResource aSource,
    83                 in nsIRDFResource aProperty,
    84                 in nsIRDFNode     aOldTarget,
    85                 in nsIRDFNode     aNewTarget);
    87     /**
    88      * 'Move' an assertion from
    89      *
    90      *   [aOldSource]--[aProperty]-->[aTarget]
    91      *
    92      * to
    93      * 
    94      *   [aNewSource]--[aProperty]-->[aTarget]
    95      */
    96     void Move(in nsIRDFResource aOldSource,
    97               in nsIRDFResource aNewSource,
    98               in nsIRDFResource aProperty,
    99               in nsIRDFNode     aTarget);
   101     /**
   102      * Query whether an assertion exists in this graph.
   103      */
   104     boolean HasAssertion(in nsIRDFResource aSource,
   105                          in nsIRDFResource aProperty,
   106                          in nsIRDFNode     aTarget,
   107                          in boolean        aTruthValue);
   109     /**
   110      * Add an observer to this data source. If the datasource
   111      * supports observers, the datasource source should hold a strong
   112      * reference to the observer.
   113      */
   114     void AddObserver(in nsIRDFObserver aObserver);
   116     /**
   117      * Remove an observer from this data source.
   118      */
   119     void RemoveObserver(in nsIRDFObserver aObserver);
   121     /**
   122      * Get a cursor to iterate over all the arcs that point into a node.
   123      */
   124     nsISimpleEnumerator ArcLabelsIn(in nsIRDFNode aNode);
   126     /**
   127      * Get a cursor to iterate over all the arcs that originate in
   128      * a resource.
   129      */
   130     nsISimpleEnumerator ArcLabelsOut(in nsIRDFResource aSource);
   132     /**
   133      * Retrieve all of the resources that the data source currently
   134      * refers to.
   135      */
   136     nsISimpleEnumerator GetAllResources();
   138     /**
   139      * Returns whether a given command is enabled for a set of sources. 
   140      */
   141     boolean IsCommandEnabled(in nsISupportsArray aSources,
   142                              in nsIRDFResource   aCommand,
   143                              in nsISupportsArray aArguments);
   145     /**
   146      * Perform the specified command on set of sources.
   147      */
   148     void DoCommand(in nsISupportsArray aSources,
   149                    in nsIRDFResource   aCommand,
   150                    in nsISupportsArray aArguments);
   152     /**
   153      * Returns the set of all commands defined for a given source.
   154      */
   155     nsISimpleEnumerator GetAllCmds(in nsIRDFResource aSource);
   157     /**
   158      * Returns true if the specified node is pointed to by the specified arc.
   159      * Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.
   160      */
   161     boolean hasArcIn(in nsIRDFNode aNode, in nsIRDFResource aArc);
   163     /**
   164      * Returns true if the specified node has the specified outward arc.
   165      * Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.
   166      */
   167     boolean hasArcOut(in nsIRDFResource aSource, in nsIRDFResource aArc);
   169     /**
   170      * Notify observers that the datasource is about to send several
   171      * notifications at once.
   172      * This must be followed by calling endUpdateBatch(), otherwise
   173      * viewers will get out of sync.
   174      */
   175     void beginUpdateBatch();
   177     /**
   178      * Notify observers that the datasource has completed issuing
   179      * a notification group.
   180      */
   181     void endUpdateBatch();
   182 };

mercurial