SourceForge.net Logo

EventGenerator.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001, 2008,
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004, 2011,
00005  *     Oracle and/or its affiliates. All rights reserved.
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 
00020 #ifndef _EVENTGENERATOR_HPP
00021 #define _EVENTGENERATOR_HPP
00022 
00023 #include <xqilla/framework/XQillaExport.hpp>
00024 #include <xqilla/framework/ReferenceCounted.hpp>
00025 #include <xqilla/runtime/ResultImpl.hpp>
00026 
00027 class DynamicContext;
00028 class EventHandler;
00029 class ASTNode;
00030 class QueryPathNode;
00031 
00032 class XQILLA_API EventGenerator : public ReferenceCounted
00033 {
00034 public:
00035   typedef RefCountPointer<EventGenerator> Ptr;
00036 
00037   virtual ~EventGenerator() {}
00038 
00041   virtual EventGenerator::Ptr generateEvents(EventHandler *events, DynamicContext *context) = 0;
00042 
00043   static void generateAndTailCall(const EventGenerator::Ptr &generator, EventHandler *events,
00044                                   DynamicContext *context)
00045   {
00046     EventGenerator::Ptr gen = generator;
00047     while(gen.notNull()) {
00048       gen = gen->generateEvents(events, context);
00049     }
00050   }
00051 
00052   static Result createResult(const ASTNode *ast, const QueryPathNode *projection,
00053     DynamicContext *context);
00054 };
00055 
00056 class XQILLA_API ASTNodeEventGenerator : public EventGenerator
00057 {
00058 public:
00059   ASTNodeEventGenerator(const ASTNode *ast, bool preserveNS, bool preserveType);
00060 
00061   virtual EventGenerator::Ptr generateEvents(EventHandler *events, DynamicContext *context);
00062 
00063 protected:
00064   const ASTNode *ast_;
00065   bool preserveNS_, preserveType_;
00066 };
00067 
00068 #endif