1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org> 2 3 #ifndef HELPERROWCREATOR_H 4 #define HELPERROWCREATOR_H 5 6 #include "injector.h" 7 #include "estringlist.h" 8 #include "ustringlist.h" 9 #include "integerset.h" 10 #include "dict.h" 11 12 13 class HelperRowCreator 14 : public EventHandler 15 { 16 public: 17 HelperRowCreator( const EString &, class Transaction *, const EString & ); 18 19 bool done() const; 20 21 void execute(); 22 23 virtual uint id( const EString & ); 24 25 bool inserted() const; 26 27 protected: 28 virtual void add( const EString &, uint ); 29 30 private: 31 virtual Query * makeSelect() = 0; 32 virtual void processSelect( Query * ); 33 virtual Query * makeCopy() = 0; 34 virtual void postprocess( Transaction * ); 35 36 private: 37 class HelperRowCreatorData * d; 38 }; 39 40 41 class FlagCreator 42 : public HelperRowCreator 43 { 44 public: 45 FlagCreator( const EStringList &, class Transaction * ); 46 allFlags()47 EStringList * allFlags() { return &names; } 48 49 private: 50 Query * makeSelect(); 51 Query * makeCopy(); 52 53 private: 54 EStringList names; 55 }; 56 57 58 class FieldNameCreator 59 : public HelperRowCreator 60 { 61 public: 62 FieldNameCreator( const EStringList &, class Transaction * ); 63 64 private: 65 Query * makeSelect(); 66 Query * makeCopy(); 67 68 private: 69 EStringList names; 70 }; 71 72 73 class AnnotationNameCreator 74 : public HelperRowCreator 75 { 76 public: 77 AnnotationNameCreator( const EStringList &, class Transaction * ); 78 79 private: 80 Query * makeSelect(); 81 Query * makeCopy(); 82 83 private: 84 EStringList names; 85 }; 86 87 88 class AddressCreator 89 : public HelperRowCreator 90 { 91 public: 92 AddressCreator( Dict<Address> *, class Transaction * ); 93 AddressCreator( Address *, class Transaction * ); 94 AddressCreator( List<Address> *, class Transaction * ); 95 96 static EString key( Address * ); 97 98 void execute(); 99 100 private: 101 Query * makeSelect(); 102 void processSelect( Query * ); 103 Query * makeCopy(); 104 105 private: 106 uint param( Dict<uint> *, const EString &, uint &, Query * ); 107 108 private: 109 Dict<Address> * a; 110 List<Address> asked; 111 bool bulk; 112 bool decided; 113 Transaction * base; 114 Transaction * sub; 115 Query * insert; 116 Query * obtain; 117 }; 118 119 120 class ThreadRootCreator 121 : public HelperRowCreator 122 { 123 public: 124 class Message 125 : public Garbage 126 { 127 public: Message()128 Message(): Garbage() {} ~Message()129 virtual ~Message() {} 130 131 virtual EStringList references() const = 0; 132 virtual EString messageId() const = 0; 133 }; 134 135 ThreadRootCreator( List<class ThreadRootCreator::Message> *, 136 class Transaction * ); 137 138 class ThreadNode 139 : public Garbage 140 { 141 public: ThreadNode(const EString & messageId)142 ThreadNode( const EString & messageId ) 143 : Garbage(), id( messageId ), parent( 0 ), trid( 0 ) {} 144 145 EString id; 146 class ThreadNode * parent; 147 uint trid; 148 }; 149 threadNodes()150 Dict<ThreadNode> * threadNodes() const { return nodes; } 151 152 uint id( const EString & ); 153 154 private: 155 Query * makeSelect(); 156 Query * makeCopy(); 157 void postprocess( Transaction * ); 158 159 void add( const EString &, uint ); 160 161 private: 162 List<Message> * messages; 163 Dict<ThreadNode> * nodes; 164 bool first; 165 IntegerSet merged; 166 }; 167 168 169 170 #endif 171