RDF:Interfaces

From MozillaWiki
Revision as of 12:02, 24 March 2005 by AxelHecht (talk | contribs) (partly port over from my wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To prevent namespace conflicts with the existing interfaces, these new interfaces use the rdfI* prefix, instead of nsI* They use interCaps naming, so that there is no confusion in JS between the old and new interfaces. They also use the subject/predicate/object terminology contained in the RDF specification, instead of source/property/target.

The RDF node and service implementations are thread-safe. Each RDF datasource can define its own thread-safety model.

The enumeration methods are replaced almost entirely with visitors. A visitor uses synchronous callbacks to return results in a "snapshot" without expensive intermediate storage allocations.

Support for reading, enumerating, and manipulating rdf:_1/_2 arcs in an ordered way is added as an intrinsic part of a datasource. This has the potential to reduce codesize and increase performance dramatically throughout the tree.

rdfINode

The RDF implementations of these interfaces will support nsIClassInfo, so that JS will automatically flatten the interface. They will also support nsISecurityCheckedComponent (allowing all access, except for rdfIResourceInternal, which we may not need at all).

interface rdfINode : nsISupports
{
    boolean equals(rdfINode aOther);
    readonly unsigned long hashCode;
    /**
     * As a shortcut to QueryInterface, c++ may use these methods to obtain a weak pointer to the
     * resource or literal of this node.
     */
    [noscript, notxpcom] rdfIResource GetResource();
    [noscript, notxpcom] rdfILiteral  GetLiteral();
};

The noscript methods may be a premature optimization. The major drawback is that if we have noscript methods, COM can't proxy or remote this interface.

rdfIResource

Note: we are getting rid of resource factories, so nobody is allowed to implement RDF resources except the internal RDF service implementations.

interface rdfIResource : rdfINode
{
    readonly attribute AUTF8String value;
    readonly attribute boolean isAnonymous;
    /**
     * The numeric value of an RDF ordinal predicate (rdf:_1)
     * Throws NS_RDF_NO_VALUE if the resource is not an ordinal.
     */
    readonly attribute long ordinal;
};
/* This functionality was originally provided by resource factories, which
   are a security problem. However, I don't see why a hashtable mapping
   resources->whatever wouldn't be just as good. Can we just drop this 
   altogether?
   This will *not* be available from untrusted content. */
interface rdfIResourceInternal : rdfIResource
{
    getDelegate(in AUTF8String aKey, in nsIIDRef aIID,
                [iid_is(aIID),retval] out nsQIResult aResult);
    releaseDelegate(in AUTF8String aKey);
};

RdfLiterals

RdfDataSource

RdfService

RdfLoadAndSave

RdfTripleVisitor