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

Loading...
Searching...
No Matches
TeeSinkTokenFilter.h
Go to the documentation of this file.
1
2// Copyright (c) 2009-2014 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 public:
65 TeeSinkTokenFilter(const TokenStreamPtr& input);
66 virtual ~TeeSinkTokenFilter();
67
68 LUCENE_CLASS(TeeSinkTokenFilter);
69
70 protected:
71 Collection<SinkTokenStreamPtr> sinks;
72
73 public:
75 SinkTokenStreamPtr newSinkTokenStream();
76
80 SinkTokenStreamPtr newSinkTokenStream(const SinkFilterPtr& filter);
81
84 void addSinkTokenStream(const SinkTokenStreamPtr& sink);
85
89 void consumeAllTokens();
90
91 virtual bool incrementToken();
92 virtual void end();
93};
94
95 class LPPAPI SinkFilter : public LuceneObject {
96 public:
97 virtual ~SinkFilter();
98
99 LUCENE_CLASS(SinkFilter);
100
101 public:
103 virtual bool accept(const AttributeSourcePtr& source) = 0;
104
106 virtual void reset();
107};
108
109 class LPPAPI AcceptAllSinkFilter : public SinkFilter {
110 public:
111 virtual ~AcceptAllSinkFilter();
112
113 LUCENE_CLASS(AcceptAllSinkFilter);
114
115 public:
116 virtual bool accept(const AttributeSourcePtr& source);
117};
118
120 class LPPAPI SinkTokenStream : public TokenStream {
121 public:
122 SinkTokenStream(const AttributeSourcePtr& source, const SinkFilterPtr& filter);
123 virtual ~SinkTokenStream();
124
125 LUCENE_CLASS(SinkTokenStream);
126
127 protected:
128 Collection<AttributeSourceStatePtr> cachedStates;
129 AttributeSourceStatePtr finalState;
130 bool initIterator;
131 Collection<AttributeSourceStatePtr>::iterator it;
132 SinkFilterPtr filter;
133
134 protected:
135 bool accept(const AttributeSourcePtr& source);
136 void addState(const AttributeSourceStatePtr& state);
137 void setFinalState(const AttributeSourceStatePtr& finalState);
138
139 public:
140 virtual bool incrementToken();
141 virtual void end();
142 virtual void reset();
143
144 friend class TeeSinkTokenFilter;
145};
146
147}
148
149#endif
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
TokenFilter.h
TokenStream.h
Lucene::AcceptAllSinkFilter
Definition TeeSinkTokenFilter.h:109
Lucene::AcceptAllSinkFilter::accept
virtual bool accept(const AttributeSourcePtr &source)
Returns true, if the current state of the passed-in AttributeSource shall be stored in the sink.
Lucene::AcceptAllSinkFilter::~AcceptAllSinkFilter
virtual ~AcceptAllSinkFilter()
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Lucene::Collection::iterator
collection_type::iterator iterator
Definition Collection.h:22
Lucene::LuceneObject
Base class for all Lucene classes.
Definition LuceneObject.h:31
Lucene::SinkFilter
Definition TeeSinkTokenFilter.h:95
Lucene::SinkFilter::reset
virtual void reset()
Called by SinkTokenStream#reset(). This method does nothing by default and can optionally be overridd...
Lucene::SinkFilter::accept
virtual bool accept(const AttributeSourcePtr &source)=0
Returns true, if the current state of the passed-in AttributeSource shall be stored in the sink.
Lucene::SinkFilter::~SinkFilter
virtual ~SinkFilter()
Lucene::SinkTokenStream
A filter that decides which AttributeSource states to store in the sink.
Definition TeeSinkTokenFilter.h:120
Lucene::SinkTokenStream::setFinalState
void setFinalState(const AttributeSourceStatePtr &finalState)
Lucene::SinkTokenStream::incrementToken
virtual bool incrementToken()
Consumers (ie., IndexWriter) use this method to advance the stream to the next token....
Lucene::SinkTokenStream::accept
bool accept(const AttributeSourcePtr &source)
Lucene::SinkTokenStream::SinkTokenStream
SinkTokenStream(const AttributeSourcePtr &source, const SinkFilterPtr &filter)
Lucene::SinkTokenStream::finalState
AttributeSourceStatePtr finalState
Definition TeeSinkTokenFilter.h:129
Lucene::SinkTokenStream::filter
SinkFilterPtr filter
Definition TeeSinkTokenFilter.h:132
Lucene::SinkTokenStream::addState
void addState(const AttributeSourceStatePtr &state)
Lucene::SinkTokenStream::cachedStates
Collection< AttributeSourceStatePtr > cachedStates
Definition TeeSinkTokenFilter.h:128
Lucene::SinkTokenStream::reset
virtual void reset()
Resets this stream to the beginning. This is an optional operation, so subclasses may or may not impl...
Lucene::SinkTokenStream::it
Collection< AttributeSourceStatePtr >::iterator it
Definition TeeSinkTokenFilter.h:131
Lucene::SinkTokenStream::end
virtual void end()
This method is called by the consumer after the last token has been consumed, after incrementToken() ...
Lucene::SinkTokenStream::initIterator
bool initIterator
Definition TeeSinkTokenFilter.h:130
Lucene::SinkTokenStream::~SinkTokenStream
virtual ~SinkTokenStream()
Lucene::TeeSinkTokenFilter
This TokenFilter provides the ability to set aside attribute states that have already been analyzed....
Definition TeeSinkTokenFilter.h:62
Lucene::TeeSinkTokenFilter::end
virtual void end()
Performs end-of-stream operations, if any, and calls then end() on the input TokenStream....
Lucene::TeeSinkTokenFilter::~TeeSinkTokenFilter
virtual ~TeeSinkTokenFilter()
Lucene::TeeSinkTokenFilter::sinks
Collection< SinkTokenStreamPtr > sinks
Definition TeeSinkTokenFilter.h:71
Lucene::TeeSinkTokenFilter::newSinkTokenStream
SinkTokenStreamPtr newSinkTokenStream(const SinkFilterPtr &filter)
Returns a new SinkTokenStream that receives all tokens consumed by this stream that pass the supplied...
Lucene::TeeSinkTokenFilter::newSinkTokenStream
SinkTokenStreamPtr newSinkTokenStream()
Returns a new SinkTokenStream that receives all tokens consumed by this stream.
Lucene::TeeSinkTokenFilter::consumeAllTokens
void consumeAllTokens()
TeeSinkTokenFilter passes all tokens to the added sinks when itself is consumed. To be sure,...
Lucene::TeeSinkTokenFilter::incrementToken
virtual bool incrementToken()
Consumers (ie., IndexWriter) use this method to advance the stream to the next token....
Lucene::TeeSinkTokenFilter::TeeSinkTokenFilter
TeeSinkTokenFilter(const TokenStreamPtr &input)
Instantiates a new TeeSinkTokenFilter.
Lucene::TeeSinkTokenFilter::addSinkTokenStream
void addSinkTokenStream(const SinkTokenStreamPtr &sink)
Adds a SinkTokenStream created by another TeeSinkTokenFilter to this one. The supplied stream will al...
Lucene::TokenFilter
A TokenFilter is a TokenStream whose input is another TokenStream.
Definition TokenFilter.h:18
Lucene::TokenStream
A TokenStream enumerates the sequence of tokens, either from Fields of a Document or from query text.
Definition TokenStream.h:44
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::AttributeSourcePtr
boost::shared_ptr< AttributeSource > AttributeSourcePtr
Definition LuceneTypes.h:520
Lucene::SinkFilterPtr
boost::shared_ptr< SinkFilter > SinkFilterPtr
Definition LuceneTypes.h:47
Lucene::TokenStreamPtr
boost::shared_ptr< TokenStream > TokenStreamPtr
Definition LuceneTypes.h:63
Lucene::SinkTokenStreamPtr
boost::shared_ptr< SinkTokenStream > SinkTokenStreamPtr
Definition LuceneTypes.h:48
Lucene::AttributeSourceStatePtr
boost::shared_ptr< AttributeSourceState > AttributeSourceStatePtr
Definition LuceneTypes.h:521

clucene.sourceforge.net