-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmeta_handlers.h
82 lines (66 loc) · 2 KB
/
meta_handlers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef __REFLECT_META_HANDLERS_HEADER__
#define __REFLECT_META_HANDLERS_HEADER__
#include "base_handlers.h"
#include <vector>
using namespace std;
class MetaDocumentHandler : public DocumentHandler, public vector<IDocumentHandler*>
{
public:
MetaDocumentHandler(IBatchHandler* batch_handler);
public:
void on_batch_begin();
void on_batch_end();
void process(Document& document, Matches& matches);
};
class MetaBatchHandler : public BatchHandler, public vector<IBatchHandler*>
{
public:
void on_batch_begin();
void on_batch_end();
virtual IDocumentHandler* create_document_handler();
};
////////////////////////////////////////////////////////////////////////////////
MetaDocumentHandler::MetaDocumentHandler(IBatchHandler* batch_handler)
: DocumentHandler(batch_handler)
{
}
void MetaDocumentHandler::on_batch_begin()
{
for (MetaDocumentHandler::iterator it = this->begin(); it != this->end(); it++) {
(*it)->on_batch_begin();
}
}
void MetaDocumentHandler::on_batch_end()
{
for (MetaDocumentHandler::iterator it = this->begin(); it != this->end(); it++) {
(*it)->on_batch_end();
}
}
void MetaDocumentHandler::process(Document& document, Matches& matches)
{
for (MetaDocumentHandler::iterator it = this->begin(); it != this->end(); it++) {
(*it)->process(document, matches);
}
}
////////////////////////////////////////////////////////////////////////////////
IDocumentHandler* MetaBatchHandler::create_document_handler()
{
MetaDocumentHandler* document_handler = new MetaDocumentHandler(this);
for (MetaBatchHandler::iterator it = this->begin(); it != this->end(); it++) {
document_handler->push_back((IDocumentHandler*)(*it)->create_document_handler());
}
return document_handler;
}
void MetaBatchHandler::on_batch_begin()
{
for (MetaBatchHandler::iterator it = this->begin(); it != this->end(); it++) {
(*it)->on_batch_begin();
}
}
void MetaBatchHandler::on_batch_end()
{
for (MetaBatchHandler::iterator it = this->begin(); it != this->end(); it++) {
(*it)->on_batch_end();
}
}
#endif