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-2008
5  * Oracle. All rights reserved.
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  * $Id$
20  */
21 
22 #ifndef _EVENTGENERATOR_HPP
23 #define _EVENTGENERATOR_HPP
24 
25 #include <xqilla/framework/XQillaExport.hpp>
28 
29 class DynamicContext;
30 class EventHandler;
31 class ASTNode;
32 class QueryPathNode;
33 
34 class XQILLA_API EventGenerator : public ReferenceCounted
35 {
36 public:
38 
39  virtual ~EventGenerator() {}
40 
43  virtual EventGenerator::Ptr generateEvents(EventHandler *events, DynamicContext *context) = 0;
44 
45  static void generateAndTailCall(const EventGenerator::Ptr &generator, EventHandler *events,
46  DynamicContext *context)
47  {
48  EventGenerator::Ptr gen = generator;
49  while(gen.notNull()) {
50  gen = gen->generateEvents(events, context);
51  }
52  }
53 
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 class XQILLA_API GenerateEventsResult : public ResultImpl
69 {
70 public:
71  GenerateEventsResult(const ASTNode *ast, const QueryPathNode *projection);
72 
73  virtual Item::Ptr nextOrTail(Result &tail, DynamicContext *context);
74 
75 private:
76  const ASTNode *ast_;
77  const QueryPathNode *projection_;
78 };
79 
80 #endif