Qt 4.8
Public Functions | Properties | List of all members
QPatternist::ResourceDelegator Class Reference

Delegates to another ResourceLoader, but in case a URI is in an exception list, it delegates to a different loader. More...

#include <qresourcedelegator_p.h>

Inheritance diagram for QPatternist::ResourceDelegator:
QPatternist::DeviceResourceLoader QPatternist::ResourceLoader QSharedData

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 QSet< QUrldeviceURIs () const
 
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...
 
 ResourceDelegator (const QSet< QUrl > &needsOverride, const ResourceLoader::Ptr &parentLoader, const ResourceLoader::Ptr &forDeviceLoader)
 
- Public Functions inherited from QPatternist::ResourceLoader
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...
 
 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...
 

Properties

const ResourceDelegator::Ptr m_forDeviceLoader
 
const QSet< QUrlm_needsOverride
 
const ResourceLoader::Ptr m_parentLoader
 

Additional Inherited Members

- Public Types inherited from QPatternist::DeviceResourceLoader
typedef QExplicitlySharedDataPointer< DeviceResourceLoaderPtr
 
- Public Types inherited from QPatternist::ResourceLoader
typedef QExplicitlySharedDataPointer< ResourceLoaderPtr
 
enum  Usage { MayUse, WillUse }
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Delegates to another ResourceLoader, but in case a URI is in an exception list, it delegates to a different loader.

This is used for handling device variables, since when a device variable is rebound, a resource loader needs to carry that binding, while the resource loader for the other query remains as is.

Since
4.5
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 76 of file qresourcedelegator_p.h.

Constructors and Destructors

◆ ResourceDelegator()

QPatternist::ResourceDelegator::ResourceDelegator ( const QSet< QUrl > &  needsOverride,
const ResourceLoader::Ptr parentLoader,
const ResourceLoader::Ptr forDeviceLoader 
)
inline

Definition at line 79 of file qresourcedelegator_p.h.

81  : m_needsOverride(needsOverride)
82  , m_parentLoader(parentLoader)
83  , m_forDeviceLoader(forDeviceLoader)
84 
85  {
87  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const ResourceLoader::Ptr m_parentLoader
const ResourceDelegator::Ptr m_forDeviceLoader

Functions

◆ announceCollection()

SequenceType::Ptr ResourceDelegator::announceCollection ( const QUrl uri)
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.

Note
This function is responsible for execution stability. Subsequent calls to this function with the same URI should result in QXmlNodeModelIndex instances that have the same identity. However, in some cases this stability is not of interest, see the specification for details.
Parameters
uriA 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).
Returns
  • null if the ResourceLoader can determine at this stage that no document referenced by uri will ever be possible to load.
  • The appropriate sequence type if loading uri succeeds at runtime. This must be CommonSequenceTypes::zeroOrMoreNodes or a sequence type that is a sub type of it.
See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.6 fn:collection

Reimplemented from QPatternist::ResourceLoader.

Definition at line 91 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

92 {
94 }
const ResourceLoader::Ptr m_parentLoader
virtual SequenceType::Ptr announceCollection(const QUrl &uri)
May be called by the compilation framework at compile time to report that an node collection referenc...

◆ announceDocument()

SequenceType::Ptr ResourceDelegator::announceDocument ( const QUrl uri,
const Usage  usageHint 
)
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.

Parameters
uriA 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).
usageHintA hint to how the URI will be used.
Returns
  • null if the ResourceLoader can determine at this stage that no document referenced by uri will ever be possible to load.
  • The appropriate sequence type if loading uri succeeds at runtime. This must be CommonSequenceTypes::zeroOrOneDocument, CommonSequenceTypes::exactlyOneDocument or a sequence type that is a sub type of it.
See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.4 fn:doc
XSL Transformations (XSLT) Version 2.0, 16.1 Multiple Source Documents

Reimplemented from QPatternist::ResourceLoader.

Definition at line 76 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

77 {
78  return m_parentLoader->announceDocument(uri, usageHint);
79 }
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 ...
const ResourceLoader::Ptr m_parentLoader

◆ announceUnparsedText()

ItemType::Ptr ResourceDelegator::announceUnparsedText ( const QUrl uri)
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.

Parameters
uriA 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).
See also
XSL Transformations (XSLT) Version 2.0, 16.2 Reading Text Files
Returns
  • null if no unparsed file can be loaded for uri
  • The item type that the value loaded by uri will be an instance of. This is typically xs:string

Reimplemented from QPatternist::ResourceLoader.

Definition at line 54 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

55 {
57 }
const ResourceLoader::Ptr m_parentLoader
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...

◆ deviceURIs()

QSet< QUrl > ResourceDelegator::deviceURIs ( ) const
virtual

Returns the union of the deviceURIs() that ResourceDelegator's two resource loaders has.

Implements QPatternist::DeviceResourceLoader.

Definition at line 96 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

97 {
99  uris |= m_forDeviceLoader->deviceURIs();
100  return uris;
101 }
virtual QSet< QUrl > deviceURIs() const =0
Returns the URIs for device variables that this ResourceLoader has loaded.
const ResourceDelegator::Ptr m_forDeviceLoader

◆ isDocumentAvailable()

bool ResourceDelegator::isDocumentAvailable ( const QUrl uri)
virtual

Calls to this function are generated by calls to the fn:doc-available() function.

Parameters
uriA 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).
Returns
true if calling openDocument() while passing uri will successfully load the document.
See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.5 fn:doc-available
XSL Transformations (XSLT) Version 2.0, 16.1 Multiple Source Documents

Reimplemented from QPatternist::ResourceLoader.

Definition at line 81 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

82 {
84 }
virtual bool isDocumentAvailable(const QUrl &uri)
Calls to this function are generated by calls to the fn:doc-available() function. ...
const ResourceLoader::Ptr m_parentLoader

◆ isUnparsedTextAvailable()

bool ResourceDelegator::isUnparsedTextAvailable ( const QUrl uri,
const QString encoding 
)
virtual

Calls to this function are generated by calls to the fn:unparsed-text-available() function.

Parameters
uriA 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).
Returns
true if calling openUnparsedText() while passing uri will successfully load the document.
See also
XSL Transformations (XSLT) Version 2.0, 16.2 Reading Text Files

Reimplemented from QPatternist::ResourceLoader.

Definition at line 48 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

50 {
51  return m_parentLoader->isUnparsedTextAvailable(uri, encoding);
52 }
virtual bool isUnparsedTextAvailable(const QUrl &uri, const QString &encoding)
Calls to this function are generated by calls to the fn:unparsed-text-available() function...
const ResourceLoader::Ptr m_parentLoader

◆ openCollection()

Item::Iterator::Ptr ResourceDelegator::openCollection ( const QUrl uri)
virtual

Calls to this function are generated by calls to the fn:collection() function.

Parameters
uriA 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).
See also
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.6 fn:collection
Returns

Reimplemented from QPatternist::ResourceLoader.

Definition at line 86 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

87 {
88  return m_parentLoader->openCollection(uri);
89 }
const ResourceLoader::Ptr m_parentLoader
virtual Item::Iterator::Ptr openCollection(const QUrl &uri)
Calls to this function are generated by calls to the fn:collection() function.

◆ openDocument()

Item ResourceDelegator::openDocument ( const QUrl uri,
const ReportContext::Ptr context 
)
virtual

Calls to this function are generated by calls to the fn:document() or fn:doc() function.

Note
This function is responsible for execution stability. Subsequent calls to this function with the same URI should result in QXmlNodeModelIndex instances that have the same identity. However, in some cases this stability is not of interest, see the specification for details.
Parameters
uriA 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).
See also
QXmlNodeModelIndex::identity()
XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.4 fn:doc
XSL Transformations (XSLT) Version 2.0, 16.1 Multiple Source Documents
Returns

Reimplemented from QPatternist::ResourceLoader.

Definition at line 67 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

69 {
70  if(m_needsOverride.contains(uri))
71  return m_forDeviceLoader->openDocument(uri, context);
72  else
73  return m_parentLoader->openDocument(uri, context);
74 }
const ResourceLoader::Ptr m_parentLoader
bool contains(const T &value) const
Definition: qset.h:91
const ResourceDelegator::Ptr m_forDeviceLoader
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.

◆ openUnparsedText()

Item ResourceDelegator::openUnparsedText ( const QUrl uri,
const QString encoding,
const ReportContext::Ptr context,
const SourceLocationReflection *const  where 
)
virtual

Calls to this function are generated by calls to the fn:unparsed-text() function.

Parameters
uriA 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).
encodingthe encoding to use. If empty, the user hasn't expressed any encoding to use.
See also
XSL Transformations (XSLT) Version 2.0, 16.2 Reading Text Files
Returns
  • null if no unparsed file can be loaded for uri
  • An 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 from QPatternist::ResourceLoader.

Definition at line 59 of file qresourcedelegator.cpp.

Referenced by ResourceDelegator().

63 {
64  return m_parentLoader->openUnparsedText(uri, encoding, context, where);
65 }
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. ...
const ResourceLoader::Ptr m_parentLoader

Properties

◆ m_forDeviceLoader

const ResourceDelegator::Ptr QPatternist::ResourceDelegator::m_forDeviceLoader
private

Definition at line 112 of file qresourcedelegator_p.h.

Referenced by deviceURIs(), and openDocument().

◆ m_needsOverride

const QSet<QUrl> QPatternist::ResourceDelegator::m_needsOverride
private

Definition at line 110 of file qresourcedelegator_p.h.

Referenced by deviceURIs(), and openDocument().

◆ m_parentLoader

const ResourceLoader::Ptr QPatternist::ResourceDelegator::m_parentLoader
private

The documentation for this class was generated from the following files: