1 | /* This file is part of Strigi Desktop Search |
2 | * |
3 | * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef STRIGI_ANALYZERPLUGIN_H |
22 | #define STRIGI_ANALYZERPLUGIN_H |
23 | #include <strigi/strigiconfig.h> |
24 | |
25 | #include <list> |
26 | |
27 | namespace Strigi { |
28 | class StreamEndAnalyzerFactory; |
29 | class StreamThroughAnalyzerFactory; |
30 | class StreamSaxAnalyzerFactory; |
31 | class StreamLineAnalyzerFactory; |
32 | class StreamEventAnalyzerFactory; |
33 | |
34 | /** |
35 | * @brief Provides a list of analyzer factories present within a plugin. |
36 | * |
37 | * Each loadable plugin has one AnalyzerFactoryFactory. This factory |
38 | * can pass the available factories to the application that loads the plugin. |
39 | */ |
40 | class AnalyzerFactoryFactory { |
41 | public: |
42 | /** Destructor */ |
43 | virtual ~AnalyzerFactoryFactory() {} |
44 | |
45 | /** |
46 | * @brief Return instances of the StreamEndAnalyzerFactories available |
47 | * in this plugin. |
48 | * |
49 | * The default implementation returns an empty list. A particular plugin |
50 | * should subclass the AnalyzerFactoryFactory and overload this function |
51 | * if it implements any StreamEndAnalyzers. |
52 | */ |
53 | virtual std::list<StreamEndAnalyzerFactory*> |
54 | streamEndAnalyzerFactories() const { |
55 | std::list<StreamEndAnalyzerFactory*> af; |
56 | return af; |
57 | } |
58 | /** |
59 | * @brief Return instances of the StreamThroughAnalyzerFactories available |
60 | * in this plugin. |
61 | * |
62 | * The default implementation returns an empty list. A particular plugin |
63 | * should subclass the AnalyzerFactoryFactory and overload this function |
64 | * if it implements any StreamThroughAnalyzers. |
65 | */ |
66 | virtual std::list<StreamThroughAnalyzerFactory*> |
67 | streamThroughAnalyzerFactories() const { |
68 | std::list<StreamThroughAnalyzerFactory*> af; |
69 | return af; |
70 | } |
71 | /** |
72 | * @brief Return instances of the StreamSaxAnalyzerFactories available |
73 | * in this plugin. |
74 | * |
75 | * The default implementation returns an empty list. A particular plugin |
76 | * should subclass the AnalyzerFactoryFactory and overload this function |
77 | * if it implements any StreamSaxAnalyzers. |
78 | */ |
79 | virtual std::list<StreamSaxAnalyzerFactory*> |
80 | streamSaxAnalyzerFactories() const { |
81 | std::list<StreamSaxAnalyzerFactory*> af; |
82 | return af; |
83 | } |
84 | /** |
85 | * @brief Return instances of the StreamLineAnalyzerFactories available |
86 | * in this plugin. |
87 | * |
88 | * The default implementation returns an empty list. A particular plugin |
89 | * should subclass the AnalyzerFactoryFactory and overload this function |
90 | * if it implements any StreamLineAnalyzers. |
91 | */ |
92 | virtual std::list<StreamLineAnalyzerFactory*> |
93 | streamLineAnalyzerFactories() const { |
94 | std::list<StreamLineAnalyzerFactory*> af; |
95 | return af; |
96 | } |
97 | /** |
98 | * @brief Return instances of the StreamEventAnalyzerFactories available |
99 | * in this plugin. |
100 | * |
101 | * The default implementation returns an empty list. A particular plugin |
102 | * should subclass the AnalyzerFactoryFactory and overload this function |
103 | * if it implements any StreamEventAnalyzers. |
104 | */ |
105 | virtual std::list<StreamEventAnalyzerFactory*> |
106 | streamEventAnalyzerFactories() const { |
107 | std::list<StreamEventAnalyzerFactory*> af; |
108 | return af; |
109 | } |
110 | }; |
111 | } |
112 | |
113 | /** @deprecated use STRIGI_EXPORT instead */ |
114 | #define STRIGI_PLUGIN_API STRIGI_EXPORT |
115 | |
116 | /** |
117 | * @brief Export a Strigi::AnalyzerFactoryFactory in a plugin |
118 | * |
119 | * @param CLASS the name of the subclass of Strigi::AnalyzerFactoryFactory |
120 | * that provides the analyzer factories available in this plugin. |
121 | */ |
122 | #define STRIGI_ANALYZER_FACTORY(CLASS) extern "C" { STRIGI_EXPORT \ |
123 | const Strigi::AnalyzerFactoryFactory* strigiAnalyzerFactory() { \ |
124 | return new CLASS(); \ |
125 | } \ |
126 | STRIGI_EXPORT \ |
127 | void deleteStrigiAnalyzerFactory(const Strigi::AnalyzerFactoryFactory* f) { \ |
128 | delete f; \ |
129 | } \ |
130 | } |
131 | #endif |
132 | |
133 | |