Qt 4.8
|
Responsible for handling requests for opening files and node collections. More...
#include <qresourceloader_p.h>
Public Types | |
typedef QExplicitlySharedDataPointer< ResourceLoader > | Ptr |
enum | Usage { MayUse, WillUse } |
Public Functions | |
virtual SequenceType::Ptr | announceCollection (const QUrl &uri) |
May be called by the compilation framework at compile time to report that an node collection referenced by uri will be loaded at runtime. More... | |
virtual SequenceType::Ptr | announceDocument (const QUrl &uri, const Usage usageHint) |
May be called by the compilation framework at compile time to report that an XML document referenced by uri will be loaded at runtime. More... | |
virtual ItemType::Ptr | announceUnparsedText (const QUrl &uri) |
May be called by the compilation framework at compile time to report that an unparsed text(plain text) file referenced by uri will be loaded at runtime. More... | |
virtual void | clear (const QUrl &uri) |
Asks to unload uri from its document pool, such that a subsequent request will require a new read. More... | |
virtual bool | isDocumentAvailable (const QUrl &uri) |
Calls to this function are generated by calls to the fn:doc-available() function. More... | |
virtual bool | isUnparsedTextAvailable (const QUrl &uri, const QString &encoding) |
Calls to this function are generated by calls to the fn:unparsed-text-available() function. More... | |
virtual Item::Iterator::Ptr | openCollection (const QUrl &uri) |
Calls to this function are generated by calls to the fn:collection() function. More... | |
virtual Item | openDocument (const QUrl &uri, const ReportContext::Ptr &context) |
Calls to this function are generated by calls to the fn:document() or fn:doc() function. More... | |
virtual Item | openUnparsedText (const QUrl &uri, const QString &encoding, const ReportContext::Ptr &context, const SourceLocationReflection *const where) |
Calls to this function are generated by calls to the fn:unparsed-text() function. More... | |
ResourceLoader () | |
virtual | ~ResourceLoader () |
Public Functions inherited from QSharedData | |
QSharedData () | |
Constructs a QSharedData object with a reference count of 0. More... | |
QSharedData (const QSharedData &) | |
Constructs a QSharedData object with reference count 0. More... | |
Additional Inherited Members | |
Public Variables inherited from QSharedData | |
QAtomicInt | ref |
Responsible for handling requests for opening files and node collections.
ResourceLoader is a callback used for opening files, requested via the functions fn:document()
and fn:unparsed-text()
; and node collections, requested via fn:collection()
. Patternist uses the ResourceLoader at compile time, via StaticContext::resourceLoader(), and at runtime, via DynamicContext::resourceLoader().
The ResourceLoader takes care of loading "external resources" in a way specific to the data model Patternist is using. For example, perhaps the opening of documents should pass a security policy, or a collection should map to nodes in a virtual filesystem or a database.
From Patternist's perspective, the ResourceLoader provides two things:
From the user's or the data model's perspective, the ResourceLoader most notably provides a hint to what resources a query will load at runtime, and therefore provides an opportunity to prepare in advance for that. For example, between the compile and runtime stage, the ResourceLoader sub-class can be asked to pre-load documents in an asynchronous and simultaneous way, such that the runtime stage is faster and doesn't freeze a graphical interface.
The announce functions are not guaranteed to be called. The loading functions can be called with an URI that an announce function hasn't been called with.
The default implementations of ResourceLoader's virtual functions all signals that no resources can be loaded. This means ResourceLoader must be sub-classed, in order to be able to load resources.
Definition at line 106 of file qresourceloader_p.h.
Definition at line 128 of file qresourceloader_p.h.
Definition at line 109 of file qresourceloader_p.h.
|
inline |
Definition at line 129 of file qresourceloader_p.h.
|
virtual |
Definition at line 51 of file qresourceloader.cpp.
|
virtual |
May be called by the compilation framework at compile time to report that an node collection referenced by uri
will be loaded at runtime.
This function can be called an arbitrary amount of times for the same URI. How many times it is called for a URI has no meaning(beyond the first call, that is). For what queries the compilation framework can determine what always will be loaded is generally undefined. It depends on factors such as how simple the query is what information that is statically available and subsequently what optimizations that can apply.
Calls to this function are generated by calls to the fn:collection()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
null
if the ResourceLoader can determine at this stage that no document referenced by uri
will ever be possible to load.uri
succeeds at runtime. This must be CommonSequenceTypes::zeroOrMoreNodes or a sequence type that is a sub type of it. Reimplemented in QPatternist::ResourceDelegator.
Definition at line 121 of file qresourceloader.cpp.
Referenced by QPatternist::ResourceDelegator::announceCollection().
|
virtual |
May be called by the compilation framework at compile time to report that an XML document referenced by uri
will be loaded at runtime.
This function can be called an arbitrary amount of times for the same URI, but different usageHint
values. How many times it is called for a URI has no meaning(beyond the first call, that is). For what queries the compilation framework can determine what always will be loaded is generally undefined. It depends on factors such as the complexity of the query, what information that is statically available and subsequently what optimizations that can be applied.
Calls to this function are generated by calls to the fn:document()
or fn:doc()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
usageHint | A hint to how the URI will be used. |
null
if the ResourceLoader can determine at this stage that no document referenced by uri
will ever be possible to load.uri
succeeds at runtime. This must be CommonSequenceTypes::zeroOrOneDocument, CommonSequenceTypes::exactlyOneDocument or a sequence type that is a sub type of it. Reimplemented in QPatternist::AccelTreeResourceLoader, and QPatternist::ResourceDelegator.
Definition at line 97 of file qresourceloader.cpp.
Referenced by QPatternist::ResourceDelegator::announceDocument(), and QPatternist::DocFN::typeCheck().
|
virtual |
May be called by the compilation framework at compile time to report that an unparsed text(plain text) file referenced by uri
will be loaded at runtime.
This function can be called an arbitrary amount of times for the same URI. How many times it is called for a URI has no meaning(beyond the first call, that is). For what queries the compilation framework can determine what always will be loaded is generally undefined. It depends on factors such as how simple the query is what information that is statically available and subsequently what optimizations that can apply.
Calls to this function are generated by calls to the fn:unparsed-text()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
null
if no unparsed file can be loaded for uri
uri
will be an instance of. This is typically xs:string
Reimplemented in QPatternist::ResourceDelegator.
Definition at line 65 of file qresourceloader.cpp.
Referenced by QPatternist::ResourceDelegator::announceUnparsedText().
|
virtual |
Asks to unload uri
from its document pool, such that a subsequent request will require a new read.
The default implementation does nothing.
Reimplemented in QPatternist::AccelTreeResourceLoader.
Definition at line 129 of file qresourceloader.cpp.
|
virtual |
Calls to this function are generated by calls to the fn:doc-available()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
true
if calling openDocument() while passing uri
will successfully load the document. Reimplemented in QPatternist::AccelTreeResourceLoader, and QPatternist::ResourceDelegator.
Definition at line 105 of file qresourceloader.cpp.
Referenced by QPatternist::DocAvailableFN::evaluateEBV(), and QPatternist::ResourceDelegator::isDocumentAvailable().
Calls to this function are generated by calls to the fn:unparsed-text-available()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
true
if calling openUnparsedText() while passing uri
will successfully load the document. Reimplemented in QPatternist::AccelTreeResourceLoader, and QPatternist::ResourceDelegator.
Definition at line 55 of file qresourceloader.cpp.
Referenced by QPatternist::UnparsedTextAvailableFN::evaluateEBV(), and QPatternist::ResourceDelegator::isUnparsedTextAvailable().
|
virtual |
Calls to this function are generated by calls to the fn:collection()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
null
if no node collection can be loaded for uri
uri
. Remember that the content of the QAbstractXmlForwardIterator must match the sequence type returned by announceCollection() Reimplemented in QPatternist::ResourceDelegator.
Definition at line 113 of file qresourceloader.cpp.
Referenced by QPatternist::ResourceDelegator::openCollection().
|
virtual |
Calls to this function are generated by calls to the fn:document()
or fn:doc()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
null
if no document can be loaded for uri
uri
. Remember that the QXmlNodeModelIndex must match the sequence type returned by announceDocument() Reimplemented in QPatternist::AccelTreeResourceLoader, and QPatternist::ResourceDelegator.
Definition at line 87 of file qresourceloader.cpp.
Referenced by QPatternist::DocFN::evaluateSingleton(), and QPatternist::ResourceDelegator::openDocument().
|
virtual |
Calls to this function are generated by calls to the fn:unparsed-text()
function.
uri | A URI identifying the resource to retrieve. The URI is guaranteed to be valid(QUrl::isValid() returns true ) and to be absolute(QUrl::isRelative() returns false ). |
encoding | the encoding to use. If empty, the user hasn't expressed any encoding to use. |
null
if no unparsed file can be loaded for uri
xs:string
value(or subtype) containing the content of the file identified by uri
as text. Remember that its type must match the sequence type returned by announceUnparsedText() Reimplemented in QPatternist::AccelTreeResourceLoader, and QPatternist::ResourceDelegator.
Definition at line 73 of file qresourceloader.cpp.
Referenced by QPatternist::UnparsedTextFN::evaluateSingleton(), and QPatternist::ResourceDelegator::openUnparsedText().