Back to index

lightning-sunbird  0.9+nobinonly
nsIRDFService.idl
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsISupports.idl"
00039 #include "nsIRDFResource.idl"
00040 #include "nsIRDFLiteral.idl"
00041 #include "nsIRDFDataSource.idl"
00042 
00043 
00044 // The RDF service interface. This is a singleton object, and should be
00045 // obtained from the <tt>nsServiceManager</tt>.
00046 [scriptable, uuid(BFD05261-834C-11d2-8EAC-00805F29F370)]
00047 interface nsIRDFService : nsISupports {
00048     // Construct an RDF resource from a single-byte URI. <tt>nsIRDFSerivce</tt>
00049     // caches resources that are in-use, so multiple calls to <tt>GetResource()</tt>
00050     // for the same <tt>uri</tt> will return identical pointers. FindResource
00051     // is used to find out whether there already exists a resource corresponding to that url.
00052     nsIRDFResource GetResource(in AUTF8String aURI);
00053 
00054     // Construct an RDF resource from a Unicode URI. This is provided
00055     // as a convenience method, allowing automatic, in-line C++
00056     // conversion from <tt>nsString</tt> objects. The <tt>uri</tt> will
00057     // be converted to a single-byte representation internally.
00058     nsIRDFResource GetUnicodeResource(in AString aURI);
00059 
00060     nsIRDFResource GetAnonymousResource();
00061 
00062     // Construct an RDF literal from a Unicode string.
00063     nsIRDFLiteral  GetLiteral(in wstring aValue);
00064 
00065     // Construct an RDF literal from a PRTime.
00066     nsIRDFDate     GetDateLiteral(in long long aValue);
00067 
00068     // Construct an RDF literal from an int.
00069     nsIRDFInt      GetIntLiteral(in long aValue);
00070 
00071     // Construct an RDF literal from a data blob
00072     [noscript] nsIRDFBlob getBlobLiteral(in const_octet_ptr aValue, in long aLength);
00073 
00074     boolean IsAnonymousResource(in nsIRDFResource aResource);
00075 
00076     // Registers a resource with the RDF system, making it unique w.r.t.
00077     // GetResource.
00078     //
00079     // An implementation of nsIRDFResource should call this in its
00080     // Init() method if it wishes the resource to be globally unique
00081     // (which is usually the case).
00082     //
00083     // NOTE that the resource will <i>not</i> be ref-counted by the
00084     // RDF service: the assumption is that the resource implementation
00085     // will call nsIRDFService::UnregisterResource() when the last
00086     // reference to the resource is released.
00087     //
00088     // NOTE that the nsIRDFService implementation may choose to
00089     // maintain a reference to the resource's URI; therefore, the
00090     // resource implementation should ensure that the resource's URI
00091     // (accessable via nsIRDFResource::GetValue(const char* *aURI)) is
00092     // valid before calling RegisterResource(). Furthermore, the
00093     // resource implementation should ensure that this pointer
00094     // <i>remains</i> valid for the lifetime of the resource. (The
00095     // implementation of the resource cache in nsIRDFService uses the
00096     // URI maintained "internally" in the resource as a key into the
00097     // cache rather than copying the resource URI itself.)
00098     void RegisterResource(in nsIRDFResource aResource, in boolean aReplace);
00099 
00100     // Called to notify the resource manager that a resource is no
00101     // longer in use. This method should only be called from the
00102     // destructor of a "custom" resource implementation to notify the
00103     // RDF service that the last reference to the resource has been
00104     // released, so the resource is no longer valid.
00105     //
00106     // NOTE. As mentioned in nsIRDFResourceFactory::CreateResource(),
00107     // the RDF service will use the result of
00108     // nsIRDFResource::GetValue() as a key into its cache. For this
00109     // reason, you must always un-cache the resource <b>before</b>
00110     // releasing the storage for the <tt>const char*</tt> URI.
00111     void UnregisterResource(in nsIRDFResource aResource);
00112 
00113     // Register a <i>named data source</i>. The RDF service will call
00114     // <tt>nsIRDFDataSource::GetURI()</tt> to determine the URI under
00115     // which to register the data source.
00116     //
00117     // Note that the data source will <i>not</i> be refcounted by the
00118     // RDF service! The assumption is that an RDF data source
00119     // registers with the service once it is initialized (via
00120     // <tt>nsIRDFDataSource::Init()</tt>), and unregisters when the
00121     // last reference to the data source is released.
00122     void RegisterDataSource(in nsIRDFDataSource aDataSource,
00123                             in boolean          aReplace);
00124 
00125     // Unregister a <i>named data source</i>. The RDF service will call
00126     // <tt>nsIRDFDataSource::GetURI()</tt> to determine the URI under which the
00127     // data source was registered.
00128     void UnregisterDataSource(in nsIRDFDataSource aDataSource);
00129 
00130     // Get the <i>named data source</i> corresponding to the URI. If a data
00131     // source has been registered via <tt>RegisterDataSource()</tt>, that
00132     // data source will be returned.
00133     //
00134     // If no data source is currently
00135     // registered for the specified URI, and a data source <i>constructor</i>
00136     // function has been registered via <tt>RegisterDatasourceConstructor()</tt>,
00137     // the RDF service will call the constructor to attempt to construct a
00138     // new data source. If construction is successful, the data source will
00139     // be initialized via <tt>nsIRDFDataSource::Init()</tt>.
00140     nsIRDFDataSource GetDataSource(in string aURI);
00141 
00142     // Same as GetDataSource, but if a remote/XML data source needs to be
00143     // constructed, then this method will issue a <b>blocking</b> Refresh
00144     // call on that data source.
00145     nsIRDFDataSource GetDataSourceBlocking(in string aURI);
00146 };
00147 
00148 %{C++
00149 extern nsresult
00150 NS_NewRDFService(nsIRDFService** result);
00151 %}
00152