1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 //
41 //  W A R N I N G
42 //  -------------
43 //
44 // This file is not part of the Qt API.  It exists purely as an
45 // implementation detail.  This header file may change from version to
46 // version without notice, or even be removed.
47 //
48 // We mean it.
49 
50 #ifndef Patternist_GenericDynamicContext_H
51 #define Patternist_GenericDynamicContext_H
52 
53 #include <QDateTime>
54 #include <QVector>
55 
56 #include <private/qdaytimeduration_p.h>
57 #include <private/qstackcontextbase_p.h>
58 #include <private/qexpression_p.h>
59 
60 QT_BEGIN_NAMESPACE
61 
62 namespace QPatternist
63 {
64     /**
65      * @short A DynamicContext supplying basic information that always is used.
66      *
67      * This DynamicContext is the first DynamicContext used during
68      * a run and is always used. In addition, more contexts, such as
69      * a Focus can be created.
70      *
71      * @author Frans Englich <frans.englich@nokia.com>
72      */
73     class GenericDynamicContext : public StackContextBase<DynamicContext>
74     {
75     public:
76         typedef QExplicitlySharedDataPointer<GenericDynamicContext> Ptr;
77 
78         GenericDynamicContext(const NamePool::Ptr &np,
79                               QAbstractMessageHandler *const messageHandler,
80                               const LocationHash &locations);
81 
82         virtual xsInteger contextPosition() const;
83         /**
84          * @returns always @c null, the focus is always undefined when an GenericDynamicContext
85          * is used.
86          */
87         virtual Item contextItem() const;
88         virtual xsInteger contextSize();
89 
90         virtual void setFocusIterator(const Item::Iterator::Ptr &it);
91         virtual Item::Iterator::Ptr focusIterator() const;
92 
93         virtual QAbstractMessageHandler * messageHandler() const;
94         virtual QExplicitlySharedDataPointer<DayTimeDuration> implicitTimezone() const;
95         virtual QDateTime currentDateTime() const;
96 
97         virtual QAbstractXmlReceiver *outputReceiver() const;
98         void setOutputReceiver(QAbstractXmlReceiver *const receiver);
99 
100         virtual NodeBuilder::Ptr nodeBuilder(const QUrl &baseURI) const;
101         void setNodeBuilder(NodeBuilder::Ptr &builder);
102 
103         virtual ResourceLoader::Ptr resourceLoader() const;
104         void setResourceLoader(const ResourceLoader::Ptr &loader);
105 
106         virtual ExternalVariableLoader::Ptr externalVariableLoader() const;
107         void setExternalVariableLoader(const ExternalVariableLoader::Ptr &loader);
108         virtual NamePool::Ptr namePool() const;
109         virtual QSourceLocation locationFor(const SourceLocationReflection *const reflection) const;
110         virtual void addNodeModel(const QAbstractXmlNodeModel::Ptr &nm);
111         virtual const QAbstractUriResolver *uriResolver() const;
112         virtual ItemCacheCell &globalItemCacheCell(const VariableSlotID slot);
113         virtual ItemSequenceCacheCell::Vector &globalItemSequenceCacheCells(const VariableSlotID slot);
114 
115         void setUriResolver(const QAbstractUriResolver *const resolver);
116 
117         /**
118          * We return a null item, we have no focus.
119          */
120         virtual Item currentItem() const;
121 
122         /**
123          * @short Returns always @c null, since we're always
124          * a top-level context.
125          */
126         virtual DynamicContext::Ptr previousContext() const;
127 
128         virtual QExplicitlySharedDataPointer<TemplateMode> currentTemplateMode() const;
129 
130     private:
131         QAbstractMessageHandler *       m_messageHandler;
132         const QDateTime                 m_currentDateTime;
133         const DayTimeDuration::Ptr      m_zoneOffset;
134         QAbstractXmlReceiver *          m_outputReceiver;
135         mutable NodeBuilder::Ptr        m_nodeBuilder;
136         ExternalVariableLoader::Ptr     m_externalVariableLoader;
137         ResourceLoader::Ptr             m_resourceLoader;
138         NamePool::Ptr                   m_namePool;
139         const LocationHash              m_locations;
140         QAbstractXmlNodeModel::List     m_nodeModels;
141         const QAbstractUriResolver *    m_uriResolver;
142         ItemCacheCell::Vector           m_globalItemCacheCells;
143         ItemSequenceCacheCell::Vector   m_globalItemSequenceCacheCells;
144     };
145 }
146 
147 QT_END_NAMESPACE
148 
149 #endif
150