Lucene++ - a full-featured, c++ search engine
API Documentation

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TeeSinkTokenFilter.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6
7 #ifndef TEESINKTOKENFILTER_H
8 #define TEESINKTOKENFILTER_H
9
10 #include "TokenFilter.h"
11 #include "TokenStream.h"
12
13 namespace Lucene
14 {
62 class LPPAPI TeeSinkTokenFilter : public TokenFilter
63 {
64 public:
66 TeeSinkTokenFilter(TokenStreamPtr input);
67 virtual ~TeeSinkTokenFilter();
68
69 LUCENE_CLASS(TeeSinkTokenFilter);
70
71 protected:
72 Collection<SinkTokenStreamPtr> sinks;
73
74 public:
76 SinkTokenStreamPtr newSinkTokenStream();
77
81 SinkTokenStreamPtr newSinkTokenStream(SinkFilterPtr filter);
82
85 void addSinkTokenStream(SinkTokenStreamPtr sink);
86
90 void consumeAllTokens();
91
92 virtual bool incrementToken();
93 virtual void end();
94 };
95
96 class LPPAPI SinkFilter : public LuceneObject
97 {
98 public:
99 virtual ~SinkFilter();
100
101 LUCENE_CLASS(SinkFilter);
102
103 public:
105 virtual bool accept(AttributeSourcePtr source) = 0;
106
108 virtual void reset();
109 };
110
111 class LPPAPI AcceptAllSinkFilter : public SinkFilter
112 {
113 public:
114 virtual ~AcceptAllSinkFilter();
115
116 LUCENE_CLASS(AcceptAllSinkFilter);
117
118 public:
119 virtual bool accept(AttributeSourcePtr source);
120 };
121
123 class LPPAPI SinkTokenStream : public TokenStream
124 {
125 public:
126 SinkTokenStream(AttributeSourcePtr source, SinkFilterPtr filter);
127 virtual ~SinkTokenStream();
128
129 LUCENE_CLASS(SinkTokenStream);
130
131 protected:
132 Collection<AttributeSourceStatePtr> cachedStates;
133 AttributeSourceStatePtr finalState;
134 bool initIterator;
135 Collection<AttributeSourceStatePtr>::iterator it;
136 SinkFilterPtr filter;
137
138 protected:
139 bool accept(AttributeSourcePtr source);
140 void addState(AttributeSourceStatePtr state);
141 void setFinalState(AttributeSourceStatePtr finalState);
142
143 public:
144 virtual bool incrementToken();
145 virtual void end();
146 virtual void reset();
147
148 friend class TeeSinkTokenFilter;
149 };
150 }
151
152 #endif

clucene.sourceforge.net