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

LuceneFactory.h
Go to the documentation of this file.
1 // 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 LUCENEFACTORY_H
8 #define LUCENEFACTORY_H
9
10 #include <boost/make_shared.hpp>
11 #include <boost/version.hpp>
12
13 namespace Lucene {
14
15 template <class T>
16 boost::shared_ptr<T> newInstance() {
17 #if BOOST_VERSION <= 103800
18 return boost::shared_ptr<T>(new T);
19 #else
20 return boost::make_shared<T>();
21 #endif
22 }
23
24 template <class T, class A1>
25 boost::shared_ptr<T> newInstance(A1 const& a1) {
26 #if BOOST_VERSION <= 103800
27 return boost::shared_ptr<T>(new T(a1));
28 #else
29 return boost::make_shared<T>(a1);
30 #endif
31 }
32
33 template <class T, class A1, class A2>
34 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2) {
35 #if BOOST_VERSION <= 103800
36 return boost::shared_ptr<T>(new T(a1, a2));
37 #else
38 return boost::make_shared<T>(a1, a2);
39 #endif
40 }
41
42 template <class T, class A1, class A2, class A3>
43 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3) {
44 #if BOOST_VERSION <= 103800
45 return boost::shared_ptr<T>(new T(a1, a2, a3));
46 #else
47 return boost::make_shared<T>(a1, a2, a3);
48 #endif
49 }
50
51 template <class T, class A1, class A2, class A3, class A4>
52 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4) {
53 #if BOOST_VERSION <= 103800
54 return boost::shared_ptr<T>(new T(a1, a2, a3, a4));
55 #else
56 return boost::make_shared<T>(a1, a2, a3, a4);
57 #endif
58 }
59
60 template <class T, class A1, class A2, class A3, class A4, class A5>
61 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5) {
62 #if BOOST_VERSION <= 103800
63 return boost::shared_ptr<T>(new T(a1, a2, a3, a4, a5));
64 #else
65 return boost::make_shared<T>(a1, a2, a3, a4, a5);
66 #endif
67 }
68
69 template <class T, class A1, class A2, class A3, class A4, class A5, class A6>
70 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6) {
71 #if BOOST_VERSION <= 103800
72 return boost::shared_ptr<T>(new T(a1, a2, a3, a4, a5, a6));
73 #else
74 return boost::make_shared<T>(a1, a2, a3, a4, a5, a6);
75 #endif
76 }
77
78 template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
79 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6, A7 const& a7) {
80 #if BOOST_VERSION <= 103800
81 return boost::shared_ptr<T>(new T(a1, a2, a3, a4, a5, a6, a7));
82 #else
83 return boost::make_shared<T>(a1, a2, a3, a4, a5, a6, a7);
84 #endif
85 }
86
87 template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
88 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6, A7 const& a7, A8 const& a8) {
89 #if BOOST_VERSION <= 103800
90 return boost::shared_ptr<T>(new T(a1, a2, a3, a4, a5, a6, a7, a8));
91 #else
92 return boost::make_shared<T>(a1, a2, a3, a4, a5, a6, a7, a8);
93 #endif
94 }
95
96 template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
97 boost::shared_ptr<T> newInstance(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6, A7 const& a7, A8 const& a8, A9 const& a9) {
98 #if BOOST_VERSION <= 103800
99 return boost::shared_ptr<T>(new T(a1, a2, a3, a4, a5, a6, a7, a8, a9));
100 #else
101 return boost::make_shared<T>(a1, a2, a3, a4, a5, a6, a7, a8, a9);
102 #endif
103 }
104
105 template <class T>
106 boost::shared_ptr<T> newLucene() {
107 boost::shared_ptr<T> instance(newInstance<T>());
108 instance->initialize();
109 return instance;
110 }
111
112 template <class T, class A1>
113 boost::shared_ptr<T> newLucene(A1 const& a1) {
114 boost::shared_ptr<T> instance(newInstance<T>(a1));
115 instance->initialize();
116 return instance;
117 }
118
119 template <class T, class A1, class A2>
120 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2) {
121 boost::shared_ptr<T> instance(newInstance<T>(a1, a2));
122 instance->initialize();
123 return instance;
124 }
125
126 template <class T, class A1, class A2, class A3>
127 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3) {
128 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3));
129 instance->initialize();
130 return instance;
131 }
132
133 template <class T, class A1, class A2, class A3, class A4>
134 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4) {
135 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3, a4));
136 instance->initialize();
137 return instance;
138 }
139
140 template <class T, class A1, class A2, class A3, class A4, class A5>
141 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5) {
142 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3, a4, a5));
143 instance->initialize();
144 return instance;
145 }
146
147 template <class T, class A1, class A2, class A3, class A4, class A5, class A6>
148 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6) {
149 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3, a4, a5, a6));
150 instance->initialize();
151 return instance;
152 }
153
154 template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
155 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6, A7 const& a7) {
156 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3, a4, a5, a6, a7));
157 instance->initialize();
158 return instance;
159 }
160
161 template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
162 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6, A7 const& a7, A8 const& a8) {
163 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3, a4, a5, a6, a7, a8));
164 instance->initialize();
165 return instance;
166 }
167
168 template <class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
169 boost::shared_ptr<T> newLucene(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5, A6 const& a6, A7 const& a7, A8 const& a8, A9 const& a9) {
170 boost::shared_ptr<T> instance(newInstance<T>(a1, a2, a3, a4, a5, a6, a7, a8, a9));
171 instance->initialize();
172 return instance;
173 }
174
175 }
176
177 #endif
Lucene::newLucene
boost::shared_ptr< T > newLucene()
Definition: LuceneFactory.h:106
Lucene::newInstance
boost::shared_ptr< T > newInstance()
Definition: LuceneFactory.h:16
Lucene
Definition: AbstractAllTermDocs.h:12

clucene.sourceforge.net