All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Config.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib 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
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/common/Config.h
22 
23  \brief Configuration flags for the TerraLib Common Runtime module.
24 
25  \todo We need to move some configuration variables to build system.
26 */
27 
28 #ifndef __TERRALIB_COMMON_INTERNAL_CONFIG_H
29 #define __TERRALIB_COMMON_INTERNAL_CONFIG_H
30 
31 // TerraLib
32 #include "../Config.h"
33 
34 #define TE_COMMON_MODULE_NAME "te.common"
35 
36 /** @name File Defines
37  * Flags for TerraLib special files name and location.
38  */
39 //@{
40 
41 /*!
42  \def TERRALIB_DIR
43 
44  \brief The folder name on the system where terralib data is stored (on windows: app/terralib).
45 */
46 #ifndef TERRALIB_DIR
47  #define TERRALIB_DIR "terralib"
48 #endif
49 
50 /*!
51  \def TERRALIB_DIR_ENVVAR
52 
53  \brief Environment variable name with the TerraLib install path.
54 */
55 #ifndef TERRALIB_DIR_ENVVAR
56  #define TERRALIB_DIR_ENVVAR "TERRALIB_DIR"
57 #endif
58 
59 /*!
60  \def TERRALIB_CONFIG_DIR
61 
62  \brief Folder location with application config files.
63 */
64 #ifndef TERRALIB_CONFIG_DIR
65  #define TERRALIB_CONFIG_DIR "../../conf"
66 #endif
67 
68 /*!
69  \def TERRALIB_CONFIG_DIR
70 
71  \brief Main application config file.
72 */
73 #ifndef TERRALIB_SYSTEM_SETTINGS_FILE
74  #define TERRALIB_SYSTEM_SETTINGS_FILE "config.xml"
75 #endif
76 
77 /*!
78  \def TERRALIB_USER_SETTINGS_FILE
79 
80  \brief User settings file name
81 */
82 #ifndef TERRALIB_USER_SETTINGS_FILE
83  #define TERRALIB_USER_SETTINGS_FILE "user_settings.xml"
84 #endif
85 
86 //@}
87 
88 /** @name Internationalization Defines
89  * Flags for TerraLib code internationalization.
90  */
91 //@{
92 
93 // Check if the TR macro has already been defined
94 // by another application... if so, it will output
95 // an error message and stop compiling!
96 #if TE_TRANSLATOR_ENABLED
97  #ifdef TR
98  #error "The TR macro has been already defined by another application or code. Please, inform TerraLib Development Team <developers@terralib.org>, we will be glad to help solving this problem!"
99  #endif
100 #endif
101 
102 /*!
103  \def TE_ADD_TEXT_DOMAIN
104 
105  \brief It adds the given text domain located at domain-dir with the given codeset to the multilingual system.
106 
107  \note This macro will check if the domain already exists before doing anyting.
108 */
109 #if TE_TRANSLATOR_ENABLED
110  #define TE_ADD_TEXT_DOMAIN(domain, domaindir, codeset) \
111  if(!te::common::Translator::getInstance().exist(domain)) \
112  { \
113  te::common::Translator::getInstance().addTextDomain(domain, domaindir); \
114  te::common::Translator::getInstance().setTextDomainCodeSet(domain, codeset); \
115  } \
116  ((void)0)
117 #else
118  #define TE_ADD_TEXT_DOMAIN(domain, domaindir, codeset) ((void)0)
119 #endif
120 
121 /*!
122  \def TR
123 
124  \brief Try to translate the message according to the given domain. See the TR_COMMON macro for more infomation on how to create a translation mark for your code.
125 */
126 #if TE_TRANSLATOR_ENABLED
127  #define TR(message, domain) te::common::Translator::getInstance().getInstance().translate(message, domain)
128 #else
129  #define TR(message, domain) message
130 #endif
131 
132 /*!
133  \def TR_PLURAL
134 
135  \brief Try to translate the message according to the given domain and plural form. See the TR_PLURAL_COMMON macro for more infomation on how to create a translation mark for your code.
136 */
137 #if TE_TRANSLATOR_ENABLED
138  #define TR_PLURAL(domain, message1, message2, n) te::common::Translator::getInstance().getInstance().translate(domain, message1, message2, n)
139 #else
140  #define TR_PLURAL(domain, message1, message2, n) (n > 1 ? message2 : message1)
141 #endif
142 
143 /*!
144  \def TE_COMMON_TEXT_DOMAIN
145 
146  \brief It contains the name of the text domain used in the translation of messages in the TerraLib Common module.
147 */
148 #define TE_COMMON_TEXT_DOMAIN "tecommon"
149 
150 /*!
151  \def TE_COMMON_TEXT_DOMAIN_DIR
152 
153  \brief It contains the translation catalog directory.
154 */
155 #define TE_COMMON_TEXT_DOMAIN_DIR "locale"
156 
157 /*!
158  \def TR_COMMON
159 
160  \brief It marks a string in order to get translated. This is the mark used in the Common module of TerraLib.
161 
162  In each module you have to define a new mark. It can be hard-working,
163  but it gives you the maximum flexibility to define your own text domain
164  in the apropriated directory.
165  <br>
166  Example of usage:
167  \code
168  std::cout << TR_COMMON("My message!");
169 
170  throw Exception(TR_COMMON("My other message!"));
171  \endcode
172 */
173 #define TR_COMMON(message) TR(message, TE_COMMON_TEXT_DOMAIN)
174 
175 /*!
176  \def TR_PLURAL_COMMON
177 
178  \brief It marks a string in order to get translated according to plural form. This is the mark used in the Common module of TerraLib.
179 
180  In each module you have to define a new mark. It can be hard-working,
181  but it gives you the maximum flexibility to define your own text domain
182  in the apropriated directory.
183  <br>
184  Example of usage:
185  \code
186  int n = f(...);
187 
188  std::cout << TR_PLURAL_COMMON("One Message!", "Two Messages", n);
189 
190  throw Exception(TR_PLURAL_COMMON("One Message!", "Two Messages", n));
191  \endcode
192 
193  In the above example, the parameter n can be
194  a threshold that helps to choose between the first or the second construction.
195  If your trabslation file is configured with a theashold of 1,
196  indicating that if n > 1 must choose the second construction,
197  the plural versin will be choosed, otherwise, it will choose the
198  singular form (the fisrt one).
199 */
200 #define TR_PLURAL_COMMON(message1, message2, n) TR_PLURAL(TE_COMMON_TEXT_DOMAIN, message1, message2, n)
201 
202 //@}
203 
204 /** @name Logger Defines
205  * Flags for building TerraLib with log support.
206  *
207  * The macros TE_LOG_XXX can be used to log messages.
208  * These macros are disabled if TE_LOGGER_ENABLED
209  * is set to 0.
210  *
211  * Remember to include the <common/Logger.h> file when using this set of macros.
212  */
213 //@{
214 
215 /*!
216  \def TE_LOGGER_DEFAULT_NAME
217 
218  \brief This is the fully qualified TerraLib root logger.
219 
220  \note If you are developing a new module and want to have your
221  own log configuration file, please give it a name starting with "terralib.your-module-name". So it will
222  belong to TerraLib loggers tree.
223 */
224 #define TE_LOGGER_DEFAULT_NAME "terralib"
225 
226 /*!
227  \def TE_LOGGER_DEFAULT_CONFIG_FILE
228 
229  \brief If logger configuration is file based (text or XML), the file name (with its full path or relative path to TerraLib current directory).
230 */
231 #define TE_LOGGER_DEFAULT_CONFIGURATION_FILE "conf/te-log.conf"
232 
233 /*!
234  \def TE_LOGGER_DEFAULT_CONFIG_FILE_TYPE
235 
236  \brief It sets the default type of file used to configure the logger.
237 
238  \note See LoggerConfigurationType enum for more information about possible values for this macro.
239 */
240 #define TE_LOGGER_DEFAULT_CONFIG_FILE_TYPE te::common::LOGGER_TXT_CONFIG
241 
242 /*!
243  \def TE_LOGGER_MAKE_DEFAULT_INITIALIZATION
244 
245  \brief This macro can be used to make logger default initialization.
246 */
247 #if TE_LOGGER_ENABLED
248  #define TE_LOGGER_MAKE_DEFAULT_INITIALIZATION() \
249  const std::string loggerConfFile = te::common::Logger::getDefaultConfigFile(); \
250  te::common::Logger::initialize(TE_LOGGER_DEFAULT_NAME, TE_LOGGER_DEFAULT_CONFIG_FILE_TYPE, loggerConfFile);
251 #else
252  #define TE_LOGGER_MAKE_DEFAULT_INITIALIZATION() ((void)0)
253 #endif
254 
255 /*!
256  \def TE_LOGGER_MAKE_DEFAULT_FINALIZATION
257 
258  \brief This macro can be used to make logger default finalization.
259 */
260 #if TE_LOGGER_ENABLED
261  #define TE_LOGGER_MAKE_DEFAULT_FINALIZATION() te::common::Logger::finalize(TE_LOGGER_DEFAULT_NAME)
262 #else
263  #define TE_LOGGER_MAKE_DEFAULT_FINALIZATION() ((void)0)
264 #endif
265 
266 /*!
267  \def TE_LOGGER_FATAL_ENABLED
268 
269  \brief If this flag is set to 0 the macro TE_LOG_FATAL will be disabled and no additional computational costs will be added to the code.
270 */
271 #define TE_LOGGER_FATAL_ENABLED 1
272 
273 /*!
274  \def TE_LOGGER_ASSERT_ENABLED
275 
276  \brief If this flag is set to 0 the assertion macro TE_LOG_ASSERT will be disabled and no additional computational costs will be added to the code.
277 */
278 #define TE_LOGGER_ASSERT_ENABLED 1
279 
280 /*!
281  \def TE_LOGGER_ERROR_ENABLED
282 
283  \brief If this flag is set to 0 the assertion macro TE_LOG_ERROR will be disabled and no additional computational costs will be added to the code.
284 */
285 #define TE_LOGGER_ERROR_ENABLED 1
286 
287 /*!
288  \def TE_LOGGER_WARN_ENABLED
289 
290  \brief If this flag is set to 0 the assertion macro TE_LOG_WARN will be disabled and no additional computational costs will be added to the code.
291 */
292 #define TE_LOGGER_WARN_ENABLED 1
293 
294 /*!
295  \def TE_LOGGER_INFO_ENABLED
296 
297  \brief If this flag is set to 0 the assertion macro TE_LOG_INFO will be disabled and no additional computational costs will be added to the code.
298 */
299 #define TE_LOGGER_INFO_ENABLED 1
300 
301 /*!
302  \def TE_LOGGER_DEBUG_ENABLED
303 
304  \brief If this flag is set to 0 the assertion macro TE_LOG_DEBUG will be disabled and no additional computational costs will be added to the code.
305 */
306 #define TE_LOGGER_DEBUG_ENABLED 1
307 
308 /*!
309  \def TE_LOGGER_TRACE_ENABLED
310 
311  \brief If this flag is set to 0 the assertion macro TE_LOG_TRACE will be disabled and no additional computational costs will be added to the code.
312 */
313 #define TE_LOGGER_TRACE_ENABLED 1
314 
315 /*!
316  \def TE_LOG_FATAL
317 
318  \brief Use this tag in order to log a message to a specified logger with the FATAL level.
319 
320  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
321 
322  \note The FATAL level designates very severe error events that will presumably lead the application to abort.
323 */
324 #if (TE_LOGGER_ENABLED && TE_LOGGER_FATAL_ENABLED)
325  #define TE_LOG_FATAL(msg) te::common::Logger::logFatal(TE_LOGGER_DEFAULT_NAME, msg)
326 #else
327  #define TE_LOG_FATAL(msg) ((void)0)
328 #endif
329 
330 /*!
331  \def TE_LOG_ASSERT
332 
333  \brief Use this tag in order to log a message to a specified logger with the ASSERT level.
334 
335  \param condition An expression (condition). If it is not true, the message will be logged.
336  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
337 
338  \note The ASSERT level can be used to check expressions that must be evaluated as true.
339 */
340 #if (TE_LOGGER_ENABLED && TE_LOGGER_ASSERT_ENABLED)
341  #define TE_LOG_ASSERT(condition, msg) te::common::Logger::logAssert(TE_LOGGER_DEFAULT_NAME, condition, msg)
342 #else
343  #define TE_LOG_ASSERT(condition, msg) ((void)0)
344 #endif
345 
346 /*!
347  \def TE_LOG_ERROR
348 
349  \brief Use this tag in order to log a message to a specified logger with the ERROR level.
350 
351  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
352 
353  \note The ERROR level designates error events that might still allow the application to continue running.
354 */
355 #if (TE_LOGGER_ENABLED && TE_LOGGER_ERROR_ENABLED)
356  #define TE_LOG_ERROR(msg) te::common::Logger::logError(TE_LOGGER_DEFAULT_NAME, msg)
357 #else
358  #define TE_LOG_ERROR(msg) ((void)0)
359 #endif
360 
361 /*!
362  \def TE_LOG_WARN
363 
364  \brief Use this tag in order to log a message to a specified logger with the WARN level.
365 
366  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
367 
368  \note The WARN level designates potentially harmful situations.
369 */
370 #if (TE_LOGGER_ENABLED && TE_LOGGER_WARN_ENABLED)
371  #define TE_LOG_WARN(msg) te::common::Logger::logWarning(TE_LOGGER_DEFAULT_NAME, msg)
372 #else
373  #define TE_LOG_WARN(msg) ((void)0)
374 #endif
375 
376 /*!
377  \def TE_LOG_INFO
378 
379  \brief Use this tag in order to log a message to a specified logger with the INFO level.
380 
381  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
382 
383  \note The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
384 */
385 #if (TE_LOGGER_ENABLED && TE_LOGGER_INFO_ENABLED)
386  #define TE_LOG_INFO(msg) te::common::Logger::logInfo(TE_LOGGER_DEFAULT_NAME, msg)
387 #else
388  #define TE_LOG_INFO(msg) ((void)0)
389 #endif
390 
391 /*!
392  \def TE_LOG_DEBUG
393 
394  \brief Use this tag in order to log a message to a specified logger with the DEBUG level.
395 
396  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
397 
398  \note The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
399 */
400 #if (TE_LOGGER_ENABLED && TE_LOGGER_DEBUG_ENABLED)
401  #define TE_LOG_DEBUG(msg) te::common::Logger::logDebug(TE_LOGGER_DEFAULT_NAME, msg)
402 #else
403  #define TE_LOG_DEBUG(msg) ((void)0)
404 #endif
405 
406 /*!
407  \def TE_LOG_TRACE
408 
409  \brief Use this tag in order to log a message to a specified logger with the TRACE level.
410 
411  \param msg The message to be logged. Example: "Exception raised because of a missing parameter!".
412 
413  \note The TRACE Level designates finer-grained informational events than the DEBUG.
414 */
415 #if (TE_LOGGER_ENABLED && TE_LOGGER_TRACE_ENABLED)
416  #define TE_LOG_TRACE(msg) te::common::Logger::logTrace(TE_LOGGER_DEFAULT_NAME, msg)
417 #else
418  #define TE_LOG_TRACE(msg) ((void)0)
419 #endif
420 
421 //@}
422 
423 #define TE_PROTOCOL_DEFAULT_PORTS_FILE "protocol/protocolPorts.txt"
424 
425 /** @name DLL/LIB Module
426  * Flags for building TerraLib as a DLL or as a Static Library
427  */
428 //@{
429 
430 /*!
431  \def TECOMMONEXPORT
432 
433  \brief You can use this macro in order to export/import classes and functions from this module.
434 
435  \note If you want to compile TerraLib as DLL in Windows, remember to insert TECOMMONDLL into the project's list of defines.
436 
437  \note If you want to compile TerraLib as an Static Library under Windows, remember to insert the TECOCOMMONSTATIC flag into the project list of defines.
438 */
439 #ifdef WIN32
440 
441  #ifdef _MSC_VER
442  #pragma warning( disable : 4251 )
443  #pragma warning( disable : 4275 )
444  #pragma warning( disable : 4290 )
445  #endif
446 
447  #ifdef TECOMMONSTATIC
448  #define TECOMMONEXPORT // Don't need to export/import... it is a static library
449  #elif TECOMMONDLL
450  #define TECOMMONEXPORT __declspec(dllexport) // export DLL information
451  #else
452  #define TECOMMONEXPORT __declspec(dllimport) // import DLL information
453  #endif
454 #else
455  #define TECOMMONEXPORT
456 #endif
457 
458 //@}
459 
460 #endif // __TERRALIB_COMMON_INTERNAL_CONFIG_H
461