SourceForge.net Logo
EventGenerator.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001, 2008,
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef _EVENTGENERATOR_HPP
21 #define _EVENTGENERATOR_HPP
22 
23 #include <xqilla/framework/XQillaExport.hpp>
26 
27 class DynamicContext;
28 class EventHandler;
29 class ASTNode;
30 class QueryPathNode;
31 
32 class XQILLA_API EventGenerator : public ReferenceCounted
33 {
34 public:
36 
37  virtual ~EventGenerator() {}
38 
41  virtual EventGenerator::Ptr generateEvents(EventHandler *events, DynamicContext *context) = 0;
42 
43  static void generateAndTailCall(const EventGenerator::Ptr &generator, EventHandler *events,
44  DynamicContext *context)
45  {
46  EventGenerator::Ptr gen = generator;
47  while(gen.notNull()) {
48  gen = gen->generateEvents(events, context);
49  }
50  }
51 
52  static Result createResult(const ASTNode *ast, const QueryPathNode *projection,
53  DynamicContext *context);
54 };
55 
56 class XQILLA_API ASTNodeEventGenerator : public EventGenerator
57 {
58 public:
59  ASTNodeEventGenerator(const ASTNode *ast, bool preserveNS, bool preserveType);
60 
62 
63 protected:
64  const ASTNode *ast_;
65  bool preserveNS_, preserveType_;
66 };
67 
68 #endif
static void generateAndTailCall(const EventGenerator::Ptr &generator, EventHandler *events, DynamicContext *context)
Definition: EventGenerator.hpp:43
Definition: EventHandler.hpp:29
Super class for reference counted classes.
Definition: ReferenceCounted.hpp:30
Definition: EventGenerator.hpp:56
Super class of all the reference counted wrappers for Items.
Definition: ReferenceCounted.hpp:61
RefCountPointer< EventGenerator > Ptr
Definition: EventGenerator.hpp:35
virtual EventGenerator::Ptr generateEvents(EventHandler *events, DynamicContext *context)=0
Returns the result of this expression via the EventHandler provided.
A scoped pointer wrapper for the lazily evaluated query result.
Definition: Result.hpp:37
virtual ~EventGenerator()
Definition: EventGenerator.hpp:37
bool preserveType_
Definition: EventGenerator.hpp:65
Definition: EventGenerator.hpp:32
The execution time dynamic context interface.
Definition: DynamicContext.hpp:38
bool notNull() const
Definition: ReferenceCounted.hpp:114
const ASTNode * ast_
Definition: EventGenerator.hpp:64