1 /* 2 * Copyright 2006-2012 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 17 // ****************************************** 18 // * * 19 // * THIS IS A GENERATED FILE. DO NOT EDIT! * 20 // * SEE .xml FILE WITH SAME NAME * 21 // * * 22 // ****************************************** 23 #ifndef ZORBA_RUNTIME_RANDOM_RANDOM_H 24 #define ZORBA_RUNTIME_RANDOM_RANDOM_H 25 26 27 #include "common/shared_types.h" 28 29 30 31 #include "runtime/base/narybase.h" 32 33 34 namespace zorba { 35 36 /** 37 * 38 * Function for generating pseudo random integers 39 * 40 * Author: Zorba Team 41 */ 42 class SeededRandomIteratorState : public PlanIteratorState 43 { 44 public: 45 xs_integer theSeqLength; // 46 xs_integer theCurrCounter; // 47 48 SeededRandomIteratorState(); 49 50 ~SeededRandomIteratorState(); 51 52 void init(PlanState&); 53 void reset(PlanState&); 54 }; 55 56 class SeededRandomIterator : public NaryBaseIterator<SeededRandomIterator, SeededRandomIteratorState> 57 { 58 public: 59 SERIALIZABLE_CLASS(SeededRandomIterator); 60 61 SERIALIZABLE_CLASS_CONSTRUCTOR2T(SeededRandomIterator, 62 NaryBaseIterator<SeededRandomIterator, SeededRandomIteratorState>); 63 64 void serialize( ::zorba::serialization::Archiver& ar); 65 SeededRandomIterator(static_context * sctx,const QueryLoc & loc,std::vector<PlanIter_t> & children)66 SeededRandomIterator( 67 static_context* sctx, 68 const QueryLoc& loc, 69 std::vector<PlanIter_t>& children) 70 : 71 NaryBaseIterator<SeededRandomIterator, SeededRandomIteratorState>(sctx, loc, children) 72 {} 73 74 virtual ~SeededRandomIterator(); 75 76 void accept(PlanIterVisitor& v) const; 77 78 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; 79 }; 80 81 82 /** 83 * 84 * Function for generating random integers. 85 * The function uses srand and passes the current time in millis as seed 86 * 87 * Author: Zorba Team 88 */ 89 class RandomIteratorState : public PlanIteratorState 90 { 91 public: 92 xs_integer theSeqLength; // 93 xs_integer theCurrCounter; // 94 95 RandomIteratorState(); 96 97 ~RandomIteratorState(); 98 99 void init(PlanState&); 100 void reset(PlanState&); 101 }; 102 103 class RandomIterator : public NaryBaseIterator<RandomIterator, RandomIteratorState> 104 { 105 public: 106 SERIALIZABLE_CLASS(RandomIterator); 107 108 SERIALIZABLE_CLASS_CONSTRUCTOR2T(RandomIterator, 109 NaryBaseIterator<RandomIterator, RandomIteratorState>); 110 111 void serialize( ::zorba::serialization::Archiver& ar); 112 RandomIterator(static_context * sctx,const QueryLoc & loc,std::vector<PlanIter_t> & children)113 RandomIterator( 114 static_context* sctx, 115 const QueryLoc& loc, 116 std::vector<PlanIter_t>& children) 117 : 118 NaryBaseIterator<RandomIterator, RandomIteratorState>(sctx, loc, children) 119 {} 120 121 virtual ~RandomIterator(); 122 123 void accept(PlanIterVisitor& v) const; 124 125 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; 126 }; 127 128 129 /** 130 * generates UUID 131 * Author: Zorba Team 132 */ 133 class UuidIterator : public NaryBaseIterator<UuidIterator, PlanIteratorState> 134 { 135 public: 136 SERIALIZABLE_CLASS(UuidIterator); 137 138 SERIALIZABLE_CLASS_CONSTRUCTOR2T(UuidIterator, 139 NaryBaseIterator<UuidIterator, PlanIteratorState>); 140 141 void serialize( ::zorba::serialization::Archiver& ar); 142 UuidIterator(static_context * sctx,const QueryLoc & loc,std::vector<PlanIter_t> & children)143 UuidIterator( 144 static_context* sctx, 145 const QueryLoc& loc, 146 std::vector<PlanIter_t>& children) 147 : 148 NaryBaseIterator<UuidIterator, PlanIteratorState>(sctx, loc, children) 149 {} 150 151 virtual ~UuidIterator(); 152 153 void accept(PlanIterVisitor& v) const; 154 155 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; 156 }; 157 158 159 } 160 #endif 161 /* 162 * Local variables: 163 * mode: c++ 164 * End: 165 */ 166