~zorba-coders/zorba/bug1123016

« back to all changes in this revision

Viewing changes to src/runtime/function_item/dynamic_fncall_iterator.h

  • Committer: Sorin Marian Nasoi
  • Date: 2013-04-09 11:44:43 UTC
  • mfrom: (11301.1.53 zorba)
  • Revision ID: spungi@gmail.com-20130409114443-89vz57gpyjzwoiok
Merged lp:zorba trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#ifndef ZORBA_RUNTIME_DYNAMIC_FNCALL_ITERATOR
17
 
#define ZORBA_RUNTIME_DYNAMIC_FNCALL_ITERATOR
18
 
 
19
 
 
20
 
#include "common/shared_types.h"
21
 
 
22
 
#include "runtime/base/narybase.h"
23
 
 
24
 
#include "runtime/base/noarybase.h"
25
 
 
26
 
 
27
 
namespace zorba
28
 
{
29
 
 
30
 
/*******************************************************************************
31
 
 
32
 
********************************************************************************/
33
 
class ArgumentPlaceholderIterator: public NoaryBaseIterator<ArgumentPlaceholderIterator,PlanIteratorState>
34
 
{
35
 
public:
36
 
  SERIALIZABLE_CLASS(ArgumentPlaceholderIterator);
37
 
  SERIALIZABLE_CLASS_CONSTRUCTOR2T(ArgumentPlaceholderIterator,
38
 
  NoaryBaseIterator<ArgumentPlaceholderIterator, PlanIteratorState>);
39
 
  void serialize( ::zorba::serialization::Archiver& ar)
40
 
  {
41
 
    serialize_baseclass(ar,
42
 
    (NoaryBaseIterator<ArgumentPlaceholderIterator, PlanIteratorState>*)this);
43
 
  }
44
 
 
45
 
public:
46
 
   ArgumentPlaceholderIterator(
47
 
      static_context* sctx,
48
 
      const QueryLoc& loc)
49
 
    :
50
 
    NoaryBaseIterator<ArgumentPlaceholderIterator, PlanIteratorState>(sctx, loc)
51
 
  {
52
 
  }
53
 
 
54
 
  void accept(PlanIterVisitor& v) const;
55
 
 
56
 
  bool nextImpl(store::Item_t& result, PlanState& planState) const { return false; };
57
 
};
58
 
 
59
 
 
60
 
/*******************************************************************************
61
 
 
62
 
********************************************************************************/
63
 
class DynamicFnCallIteratorState : public PlanIteratorState
64
 
{
65
 
public:
66
 
  PlanState  * thePlanState;
67
 
  PlanIter_t   thePlan;
68
 
  bool         theIsOpen;
69
 
 
70
 
  uint32_t     theUDFStateOffset;
71
 
 
72
 
  DynamicFnCallIteratorState();
73
 
 
74
 
  ~DynamicFnCallIteratorState();
75
 
 
76
 
  void init(PlanState&);
77
 
  void reset(PlanState&);
78
 
};
79
 
 
80
 
 
81
 
/*******************************************************************************
82
 
  The 1st child iterator returns the functionItem obj to invoke. The rest of
83
 
  the child iterators compute the args to pass to the invocation.
84
 
********************************************************************************/
85
 
class DynamicFnCallIterator : public NaryBaseIterator<DynamicFnCallIterator,
86
 
                                                      DynamicFnCallIteratorState>
87
 
{
88
 
protected:
89
 
  // This variable counts the number of children that hold DOT variables. They 
90
 
  // are placed at the end of the children array.
91
 
  unsigned int theDotVarsCount; 
92
 
  bool         theIsPartialApply;
93
 
  
94
 
public:
95
 
  SERIALIZABLE_CLASS(DynamicFnCallIterator);
96
 
 
97
 
  SERIALIZABLE_CLASS_CONSTRUCTOR2T(DynamicFnCallIterator,
98
 
  NaryBaseIterator<DynamicFnCallIterator, DynamicFnCallIteratorState>);
99
 
 
100
 
  void serialize( ::zorba::serialization::Archiver& ar);
101
 
 
102
 
public:
103
 
  DynamicFnCallIterator(
104
 
      static_context* sctx,
105
 
      const QueryLoc& loc,
106
 
      std::vector<PlanIter_t>& args,
107
 
      unsigned int dotVarsCount,
108
 
      bool isPartialApply,
109
 
      xqtref_t coercionTargetType = NULL)
110
 
    :
111
 
    NaryBaseIterator<DynamicFnCallIterator, DynamicFnCallIteratorState>(sctx, loc, args),
112
 
    theDotVarsCount(dotVarsCount),
113
 
    theIsPartialApply(isPartialApply)
114
 
  {
115
 
  }
116
 
 
117
 
  void accept(PlanIterVisitor& v) const;
118
 
 
119
 
  uint32_t getStateSizeOfSubtree() const;
120
 
 
121
 
  void openImpl(PlanState& planState, uint32_t& offset);
122
 
 
123
 
  bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
124
 
 
125
 
  void resetImpl(PlanState& planState) const;
126
 
};
127
 
 
128
 
 
129
 
}
130
 
 
131
 
#endif
132
 
/*
133
 
 * Local variables:
134
 
 * mode: c++
135
 
 * End:
136
 
 */
137
 
/* vim:set et sw=2 ts=2: */