RCFProto

- Main Page
- Classes
- Files

- File List

All Classes Functions Typedefs
Config.hpp
1
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18
19 #ifndef INCLUDE_RCF_CONFIG_HPP
20 #define INCLUDE_RCF_CONFIG_HPP
21
22 #include <boost/config.hpp>
23 #include <boost/mpl/int.hpp>
24
25 #ifdef BOOST_NO_STD_WSTRING
26 #error RCF requires compiler support for std::wstring.
27 #endif
28
29 #ifdef RCF_USE_BOOST_THREADS
30 #error RCF_USE_BOOST_THREADS is no longer supported. RCF now uses an internal threading library.
31 #endif
32
33 #ifndef RCF_MAX_METHOD_COUNT
34 #define RCF_MAX_METHOD_COUNT 100
35 #endif
36
37 #if !defined(RCF_USE_SF_SERIALIZATION) && !defined(RCF_USE_BOOST_SERIALIZATION) && !defined(RCF_USE_BOOST_XML_SERIALIZATION)
38 #define RCF_USE_SF_SERIALIZATION
39 #endif
40
41 // On Cygwin, need to compile against external Boost.Asio.
42 #if defined(__CYGWIN__) && !defined(RCF_USE_BOOST_ASIO)
43 #define RCF_USE_BOOST_ASIO
44 #endif
45
46 //------------------------------------------------------------------------------
47 // Determine which features to compile.
48
49 // Check for predefined feature sets.
50
51 #if defined(RCF_BUILD_MIN)
52
53 #undef RCF_FEATURE_ZLIB
54 #undef RCF_FEATURE_OPENSSL
55 #undef RCF_FEATURE_IPV6
56 #undef RCF_FEATURE_PROTOBUF
57 #undef RCF_FEATURE_FILETRANSFER
58 #undef RCF_FEATURE_JSON
59 #undef RCF_FEATURE_CUSTOM_ALLOCATOR
60 #undef RCF_FEATURE_SSPI
61 #undef RCF_FEATURE_SERVER
62 #undef RCF_FEATURE_PUBSUB
63 #undef RCF_FEATURE_LEGACY
64 #undef RCF_FEATURE_HTTP
65 #undef RCF_FEATURE_UDP
66 #undef RCF_FEATURE_NAMEDPIPE
67 #undef RCF_FEATURE_LOCALSOCKET
68 #undef RCF_FEATURE_INPROCESS
69 #undef RCF_FEATURE_TCP
70
71 #define RCF_FEATURE_ZLIB 0
72 #define RCF_FEATURE_OPENSSL 0
73 #define RCF_FEATURE_IPV6 0
74 #define RCF_FEATURE_PROTOBUF 0
75 #define RCF_FEATURE_FILETRANSFER 0
76 #define RCF_FEATURE_JSON 0
77 #define RCF_FEATURE_CUSTOM_ALLOCATOR 0
78 #define RCF_FEATURE_SSPI 0
79 #define RCF_FEATURE_SERVER 0
80 #define RCF_FEATURE_PUBSUB 0
81 #define RCF_FEATURE_LEGACY 0
82 #define RCF_FEATURE_HTTP 0
83 #define RCF_FEATURE_UDP 0
84 #define RCF_FEATURE_NAMEDPIPE 0
85 #define RCF_FEATURE_LOCALSOCKET 0
86 #define RCF_FEATURE_INPROCESS 0
87 #define RCF_FEATURE_TCP 1
88
89 #elif defined(RCF_BUILD_REGULAR)
90
91 #undef RCF_FEATURE_ZLIB
92 #undef RCF_FEATURE_OPENSSL
93 #undef RCF_FEATURE_IPV6
94 #undef RCF_FEATURE_PROTOBUF
95 #undef RCF_FEATURE_FILETRANSFER
96 #undef RCF_FEATURE_JSON
97 #undef RCF_FEATURE_CUSTOM_ALLOCATOR
98 #undef RCF_FEATURE_SSPI
99 #undef RCF_FEATURE_SERVER
100 #undef RCF_FEATURE_PUBSUB
101 #undef RCF_FEATURE_LEGACY
102 #undef RCF_FEATURE_HTTP
103 #undef RCF_FEATURE_UDP
104 #undef RCF_FEATURE_NAMEDPIPE
105 #undef RCF_FEATURE_LOCALSOCKET
106 #undef RCF_FEATURE_INPROCESS
107 #undef RCF_FEATURE_TCP
108
109 #define RCF_FEATURE_ZLIB 0
110 #define RCF_FEATURE_OPENSSL 0
111 #define RCF_FEATURE_IPV6 0
112 #define RCF_FEATURE_PROTOBUF 0
113 #define RCF_FEATURE_FILETRANSFER 0
114 #define RCF_FEATURE_JSON 0
115 #define RCF_FEATURE_CUSTOM_ALLOCATOR 0
116 #define RCF_FEATURE_SSPI 1
117 #define RCF_FEATURE_SERVER 1
118 #define RCF_FEATURE_PUBSUB 1
119 #define RCF_FEATURE_LEGACY 1
120 #define RCF_FEATURE_HTTP 1
121 #define RCF_FEATURE_UDP 1
122 #define RCF_FEATURE_NAMEDPIPE 1
123 #define RCF_FEATURE_LOCALSOCKET 1
124 #define RCF_FEATURE_INPROCESS 1
125 #define RCF_FEATURE_TCP 1
126
127 #elif defined(RCF_BUILD_MAX)
128
129 #undef RCF_FEATURE_ZLIB
130 #undef RCF_FEATURE_OPENSSL
131 #undef RCF_FEATURE_IPV6
132 #undef RCF_FEATURE_PROTOBUF
133 #undef RCF_FEATURE_FILETRANSFER
134 #undef RCF_FEATURE_JSON
135 #undef RCF_FEATURE_CUSTOM_ALLOCATOR
136 #undef RCF_FEATURE_SSPI
137 #undef RCF_FEATURE_SERVER
138 #undef RCF_FEATURE_PUBSUB
139 #undef RCF_FEATURE_LEGACY
140 #undef RCF_FEATURE_HTTP
141 #undef RCF_FEATURE_UDP
142 #undef RCF_FEATURE_NAMEDPIPE
143 #undef RCF_FEATURE_LOCALSOCKET
144 #undef RCF_FEATURE_INPROCESS
145 #undef RCF_FEATURE_TCP
146
147 #define RCF_FEATURE_ZLIB 1
148 #define RCF_FEATURE_OPENSSL 1
149 #define RCF_FEATURE_IPV6 1
150 #define RCF_FEATURE_PROTOBUF 1
151 #define RCF_FEATURE_FILETRANSFER 1
152 #define RCF_FEATURE_JSON 1
153 #define RCF_FEATURE_CUSTOM_ALLOCATOR 1
154 #define RCF_FEATURE_SSPI 1
155 #define RCF_FEATURE_SERVER 1
156 #define RCF_FEATURE_PUBSUB 1
157 #define RCF_FEATURE_LEGACY 1
158 #define RCF_FEATURE_HTTP 1
159 #define RCF_FEATURE_UDP 1
160 #define RCF_FEATURE_NAMEDPIPE 1
161 #define RCF_FEATURE_LOCALSOCKET 1
162 #define RCF_FEATURE_INPROCESS 1
163 #define RCF_FEATURE_TCP 1
164
165 #endif
166
167 // If no predefined feature set is in use, determine the defaults for
168 // the various features.
169
170 #if defined(BOOST_WINDOWS) && defined(RCF_FEATURE_LOCALSOCKET)
171 // Local sockets only supported on non-Windows platforms.
172 #define RCF_FEATURE_LOCALSOCKET 0
173 #endif
174
175 #if !defined(BOOST_WINDOWS) && defined(RCF_FEATURE_NAMEDPIPE)
176 // Win32 named pipes only supported on Windows platforms.
177 #define RCF_FEATURE_NAMEDPIPE 1
178 #endif
179
180 // Zlib feature.
181 #ifndef RCF_FEATURE_ZLIB
182 #ifdef RCF_USE_ZLIB
183 #define RCF_FEATURE_ZLIB 1
184 #else
185 #define RCF_FEATURE_ZLIB 0
186 #endif
187 #endif
188
189 // OpenSSL feature.
190 #ifndef RCF_FEATURE_OPENSSL
191 #ifdef RCF_USE_OPENSSL
192 #define RCF_FEATURE_OPENSSL 1
193 #else
194 #define RCF_FEATURE_OPENSSL 0
195 #endif
196 #endif
197
198 // SSPI feature.
199 #ifndef RCF_FEATURE_SSPI
200 #ifdef BOOST_WINDOWS
201 #define RCF_FEATURE_SSPI 1
202 #else
203 #define RCF_FEATURE_SSPI 0
204 #endif
205 #endif
206
207 // File transfer feature
208 #ifndef RCF_FEATURE_FILETRANSFER
209 #ifdef RCF_USE_BOOST_FILESYSTEM
210 #define RCF_FEATURE_FILETRANSFER 1
211 #else
212 #define RCF_FEATURE_FILETRANSFER 0
213 #endif
214 #endif
215
216 // Server feature
217 #ifndef RCF_FEATURE_SERVER
218 #define RCF_FEATURE_SERVER 1
219 #endif
220
221 // Publish/subscribe feature.
222 #ifndef RCF_FEATURE_PUBSUB
223 #define RCF_FEATURE_PUBSUB 1
224 #endif
225
226 // Legacy feature
227 #ifndef RCF_FEATURE_LEGACY
228 #define RCF_FEATURE_LEGACY 1
229 #endif
230
231 // HTTP/HTTPS feature.
232 #ifndef RCF_FEATURE_HTTP
233 #define RCF_FEATURE_HTTP 1
234 #endif
235
236 // UDP feature
237 #ifndef RCF_FEATURE_UDP
238 #define RCF_FEATURE_UDP 1
239 #endif
240
241 // Win32 named pipes feature.
242 #ifndef RCF_FEATURE_NAMEDPIPE
243 #ifdef BOOST_WINDOWS
244 #define RCF_FEATURE_NAMEDPIPE 1
245 #else
246 #define RCF_FEATURE_NAMEDPIPE 0
247 #endif
248 #endif
249
250 // Unix local sockets feature.
251 #ifndef RCF_FEATURE_LOCALSOCKET
252 #ifdef BOOST_WINDOWS
253 #define RCF_FEATURE_LOCALSOCKET 0
254 #else
255 #define RCF_FEATURE_LOCALSOCKET 1
256 #endif
257 #endif
258
259 // In process transport feature.
260 #ifndef RCF_FEATURE_INPROCESS
261 #define RCF_FEATURE_INPROCESS 1
262 #endif
263
264 // TCP feature.
265 #ifndef RCF_FEATURE_TCP
266 #define RCF_FEATURE_TCP 1
267 #endif
268
269 // JSON feature
270 #ifndef RCF_FEATURE_JSON
271 #define RCF_FEATURE_JSON 0
272 #endif
273
274 // IPv6 feature
275 #ifndef RCF_FEATURE_IPV6
276 #define RCF_FEATURE_IPV6 1
277 #endif
278
279 // Protocol Buffers feature
280 #ifndef RCF_FEATURE_PROTOBUF
281 #define RCF_FEATURE_PROTOBUF 0
282 #endif
283
284 // Custom allocator feature.
285 #ifndef RCF_FEATURE_CUSTOM_ALLOCATOR
286 #ifdef RCF_USE_CUSTOM_ALLOCATOR
287 #define RCF_FEATURE_CUSTOM_ALLOCATOR 1
288 #else
289 #define RCF_FEATURE_CUSTOM_ALLOCATOR 0
290 #endif
291 #endif
292
293 //------------------------------------------------------------------------------
294
295 // Detect TR1 availability.
296 #ifndef RCF_USE_TR1
297
298 // MSVC
299 #if defined(_MSC_VER) && (_MSC_VER >= 1600 || (_MSC_VER == 1500 && _MSC_FULL_VER >= 150030729))
300 #define RCF_USE_TR1
301 #define RCF_TR1_HEADER(x) <x>
302 #endif
303
304 // GCC
305 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
306 #define RCF_USE_TR1
307 #define RCF_TR1_HEADER(x) <tr1/x>
308 #endif
309
310 #endif // RCF_USE_TR1
311
312 // Detect hash_map/hash_set availability.
313 #ifndef RCF_USE_HASH_MAP
314
315 #if (defined(_MSC_VER) && _MSC_VER >= 1310) || (defined(__GNUC__) && __GNUC__ == 3)
316 #define RCF_USE_HASH_MAP
317 #if defined(_MSC_VER)
318 #define RCF_HASH_MAP_HEADER(x) <x>
319 #define RCF_HASH_MAP_NS stdext
320 #elif defined(__GNUC__)
321 #define RCF_HASH_MAP_HEADER(x) <ext/x>
322 #define RCF_HASH_MAP_NS __gnu_cxx
323 #endif
324 #endif
325
326 #endif // RCF_USE_HASH_MAP
327
328 namespace RCF {
329
330 #ifndef RCF_USE_SF_SERIALIZATION
331 typedef boost::mpl::int_<0> RcfConfig_SF;
332 #else
333 typedef boost::mpl::int_<1> RcfConfig_SF;
334 #endif
335
336 #ifndef RCF_USE_BOOST_SERIALIZATION
337 typedef boost::mpl::int_<0> RcfConfig_BSer;
338 #else
339 typedef boost::mpl::int_<1> RcfConfig_BSer;
340 #endif
341
342 #ifndef RCF_USE_BOOST_FILESYSTEM
343 typedef boost::mpl::int_<0> RcfConfig_BFs;
344 #else
345 typedef boost::mpl::int_<1> RcfConfig_BFs;
346 #endif
347
348 #if RCF_FEATURE_JSON==0
349 typedef boost::mpl::int_<0> RcfConfig_Json;
350 #else
351 typedef boost::mpl::int_<1> RcfConfig_Json;
352 #endif
353
354 template<int N1, int N2, int N3, int N4>
355 struct RcfConfigurationMismatchDetected
356 {
357 };
358
359 typedef RcfConfigurationMismatchDetected<
360 RcfConfig_SF::value,
361 RcfConfig_BSer::value,
362 RcfConfig_BFs::value,
363 RcfConfig_Json::value> RcfConfigT;
364
365 } // namespace RCF
366
367 #endif // ! INCLUDE_RCF_CONFIG_HPP