rdf/base/idl/nsIRDFService.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 "nsIRDFResource.idl"
     8 #include "nsIRDFLiteral.idl"
     9 #include "nsIRDFDataSource.idl"
    12 /**
    13  * The RDF service interface. This is a singleton object which should be
    14  * obtained from the <code>nsServiceManager</code>.
    15  */
    16 [scriptable, uuid(BFD05261-834C-11d2-8EAC-00805F29F370)]
    17 interface nsIRDFService : nsISupports {
    18     /**
    19      * Construct an RDF resource from a single-byte URI. <code>nsIRDFService</code>
    20      * caches resources that are in-use, so multiple calls to <code>GetResource()</code>
    21      * for the same <code>uri</code> will return identical pointers. FindResource
    22      * is used to find out whether there already exists a resource corresponding to that url.
    23      */
    24     nsIRDFResource GetResource(in AUTF8String aURI);
    26     /**
    27      * Construct an RDF resource from a Unicode URI. This is provided
    28      * as a convenience method, allowing automatic, in-line C++
    29      * conversion from <code>nsString</code> objects. The <code>uri</code> will
    30      * be converted to a single-byte representation internally.
    31      */
    32     nsIRDFResource GetUnicodeResource(in AString aURI);
    34     nsIRDFResource GetAnonymousResource();
    36     /**
    37      * Construct an RDF literal from a Unicode string.
    38      */
    39     nsIRDFLiteral  GetLiteral(in wstring aValue);
    41     /**
    42      * Construct an RDF literal from a PRTime.
    43      */
    44     nsIRDFDate     GetDateLiteral(in PRTime aValue);
    46     /**
    47      * Construct an RDF literal from an int.
    48      */
    49     nsIRDFInt      GetIntLiteral(in long aValue);
    51     /**
    52      * Construct an RDF literal from a data blob
    53      */
    54     [noscript] nsIRDFBlob getBlobLiteral(in const_octet_ptr aValue, in long aLength);
    56     boolean IsAnonymousResource(in nsIRDFResource aResource);
    58     /**
    59      * Registers a resource with the RDF system, making it unique w.r.t.
    60      * GetResource.
    61      *
    62      * An implementation of nsIRDFResource should call this in its
    63      * Init() method if it wishes the resource to be globally unique
    64      * (which is usually the case).
    65      *
    66      * @note that the resource will <i>not</i> be ref-counted by the
    67      * RDF service: the assumption is that the resource implementation
    68      * will call nsIRDFService::UnregisterResource() when the last
    69      * reference to the resource is released.
    70      *
    71      * @note that the nsIRDFService implementation may choose to
    72      * maintain a reference to the resource's URI; therefore, the
    73      * resource implementation should ensure that the resource's URI
    74      * (accessible via nsIRDFResource::GetValue(const char* *aURI)) is
    75      * valid before calling RegisterResource(). Furthermore, the
    76      * resource implementation should ensure that this pointer
    77      * <i>remains</i> valid for the lifetime of the resource. (The
    78      * implementation of the resource cache in nsIRDFService uses the
    79      * URI maintained "internally" in the resource as a key into the
    80      * cache rather than copying the resource URI itself.)
    81      */
    82     void RegisterResource(in nsIRDFResource aResource, in boolean aReplace);
    84     /**
    85      * Called to notify the resource manager that a resource is no
    86      * longer in use. This method should only be called from the
    87      * destructor of a "custom" resource implementation to notify the
    88      * RDF service that the last reference to the resource has been
    89      * released, so the resource is no longer valid.
    90      *
    91      * @note As mentioned in nsIRDFResourceFactory::CreateResource(),
    92      * the RDF service will use the result of
    93      * nsIRDFResource::GetValue() as a key into its cache. For this
    94      * reason, you must always un-cache the resource <b>before</b>
    95      * releasing the storage for the <code>const char*</code> URI.
    96      */
    97     void UnregisterResource(in nsIRDFResource aResource);
    99     /**
   100      * Register a <i>named data source</i>. The RDF service will call
   101      * <code>nsIRDFDataSource::GetURI()</code> to determine the URI under
   102      * which to register the data source.
   103      *
   104      * @note that the data source will <i>not</i> be refcounted by the
   105      * RDF service! The assumption is that an RDF data source
   106      * registers with the service once it is initialized (via
   107      * <code>nsIRDFDataSource::Init()</code>), and unregisters when the
   108      * last reference to the data source is released.
   109      */
   110     void RegisterDataSource(in nsIRDFDataSource aDataSource,
   111                             in boolean          aReplace);
   113     /**
   114      * Unregister a <i>named data source</i>. The RDF service will call
   115      * <code>nsIRDFDataSource::GetURI()</code> to determine the URI under which the
   116      * data source was registered.
   117      */
   118     void UnregisterDataSource(in nsIRDFDataSource aDataSource);
   120     /**
   121      * Get the <i>named data source</i> corresponding to the URI. If a data
   122      * source has been registered via <code>RegisterDataSource()</code>, that
   123      * data source will be returned.
   124      *
   125      * If no data source is currently
   126      * registered for the specified URI, and a data source <i>constructor</i>
   127      * function has been registered via <code>RegisterDatasourceConstructor()</code>,
   128      * the RDF service will call the constructor to attempt to construct a
   129      * new data source. If construction is successful, the data source will
   130      * be initialized via <code>nsIRDFDataSource::Init()</code>.
   131      */
   132     nsIRDFDataSource GetDataSource(in string aURI);
   134     /**
   135      * Same as GetDataSource, but if a remote/XML data source needs to be
   136      * constructed, then this method will issue a <b>blocking</b> Refresh
   137      * call on that data source.
   138      */
   139     nsIRDFDataSource GetDataSourceBlocking(in string aURI);
   140 };
   142 %{C++
   143 extern nsresult
   144 NS_NewRDFService(nsIRDFService** result);
   145 %}

mercurial