1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 #ifndef ZORBA_RUNTIME_APPLY_UPDATES
18 #define ZORBA_RUNTIME_APPLY_UPDATES
19 
20 #include "runtime/base/unarybase.h"
21 
22 
23 namespace zorba
24 {
25 
26 /*******************************************************************************
27 
28 ********************************************************************************/
29 class ApplyIteratorState : public PlanIteratorState
30 {
31 public:
32   std::vector<store::Item_t>            theXDMItems;
33 
34   std::vector<store::Item_t>::iterator theXDMIte;
35   std::vector<store::Item_t>::iterator theXDMEnd;
36 
37 public:
38   void reset(PlanState& state);
39 };
40 
41 
42 /*******************************************************************************
43 
44 ********************************************************************************/
45 class ApplyIterator : public UnaryBaseIterator<ApplyIterator,
46                                                ApplyIteratorState>
47 {
48 private:
49   bool  theDiscardXDM;
50 
51 public:
52   SERIALIZABLE_CLASS(ApplyIterator);
53 
54   SERIALIZABLE_CLASS_CONSTRUCTOR2T(
55   ApplyIterator,
56   UnaryBaseIterator<ApplyIterator, ApplyIteratorState>);
57 
58   void serialize(::zorba::serialization::Archiver& ar);
59 
60 public:
61   ApplyIterator(
62         static_context* sctx,
63         const QueryLoc& loc,
64         bool discardXDM,
65         PlanIter_t& arg);
66 
67   void accept(PlanIterVisitor& v) const;
68 
69   bool nextImpl(store::Item_t& result, PlanState& planState) const;
70 };
71 
72 
73 void
74 apply_updates(
75       CompilerCB* ccb,
76       dynamic_context* gdctx,
77       static_context* sctx,
78       store::PUL* pul,
79       const QueryLoc& loc);
80 
81 
82 
83 }
84 
85 #endif
86 
87 /*
88  * Local variables:
89  * mode: c++
90  * End:
91  */
92 /* vim:set et sw=2 ts=2: */
93