2
* Copyright 2006-2008 The FLWOR Foundation.
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
16
#ifndef ZORBA_RUNTIME_DYNAMIC_FNCALL_ITERATOR
17
#define ZORBA_RUNTIME_DYNAMIC_FNCALL_ITERATOR
20
#include "common/shared_types.h"
22
#include "runtime/base/narybase.h"
24
#include "runtime/base/noarybase.h"
30
/*******************************************************************************
32
********************************************************************************/
33
class ArgumentPlaceholderIterator: public NoaryBaseIterator<ArgumentPlaceholderIterator,PlanIteratorState>
36
SERIALIZABLE_CLASS(ArgumentPlaceholderIterator);
37
SERIALIZABLE_CLASS_CONSTRUCTOR2T(ArgumentPlaceholderIterator,
38
NoaryBaseIterator<ArgumentPlaceholderIterator, PlanIteratorState>);
39
void serialize( ::zorba::serialization::Archiver& ar)
41
serialize_baseclass(ar,
42
(NoaryBaseIterator<ArgumentPlaceholderIterator, PlanIteratorState>*)this);
46
ArgumentPlaceholderIterator(
50
NoaryBaseIterator<ArgumentPlaceholderIterator, PlanIteratorState>(sctx, loc)
54
void accept(PlanIterVisitor& v) const;
56
bool nextImpl(store::Item_t& result, PlanState& planState) const { return false; };
60
/*******************************************************************************
62
********************************************************************************/
63
class DynamicFnCallIteratorState : public PlanIteratorState
66
PlanState * thePlanState;
70
uint32_t theUDFStateOffset;
72
DynamicFnCallIteratorState();
74
~DynamicFnCallIteratorState();
76
void init(PlanState&);
77
void reset(PlanState&);
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>
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;
95
SERIALIZABLE_CLASS(DynamicFnCallIterator);
97
SERIALIZABLE_CLASS_CONSTRUCTOR2T(DynamicFnCallIterator,
98
NaryBaseIterator<DynamicFnCallIterator, DynamicFnCallIteratorState>);
100
void serialize( ::zorba::serialization::Archiver& ar);
103
DynamicFnCallIterator(
104
static_context* sctx,
106
std::vector<PlanIter_t>& args,
107
unsigned int dotVarsCount,
109
xqtref_t coercionTargetType = NULL)
111
NaryBaseIterator<DynamicFnCallIterator, DynamicFnCallIteratorState>(sctx, loc, args),
112
theDotVarsCount(dotVarsCount),
113
theIsPartialApply(isPartialApply)
117
void accept(PlanIterVisitor& v) const;
119
uint32_t getStateSizeOfSubtree() const;
121
void openImpl(PlanState& planState, uint32_t& offset);
123
bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
125
void resetImpl(PlanState& planState) const;
137
/* vim:set et sw=2 ts=2: */