00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef GLOBALSEARCHMACROS_H
00016 #define GLOBALSEARCHMACROS_H
00017
00018 #include <globalsearch/random.h>
00019
00020 #include <QtCore/QSettings>
00021
00022 #include <cstdlib>
00023
00024 #ifdef WIN32
00025
00026 #define _WINSOCKAPI_
00027
00028 #include <windows.h>
00029
00030 #include <float.h>
00031 #else // WIN32
00032
00033 #include <unistd.h>
00034 #endif // WIN32
00035
00036
00037
00038
00039 #define SETTINGS(f) \
00040 QSettings *settings, pQS, rQS (f, QSettings::IniFormat); \
00041 settings = (QString(f).isEmpty()) ? &pQS : &rQS;
00042
00043
00044
00045 #define DESTROY_SETTINGS(f) settings->sync();
00046
00047
00048 #define INIT_RANDOM_GENERATOR() // Does nothing right now
00049 #define RANDDOUBLE() ( GlobalSearch::GSRandom::instance()->getRandomDouble() )
00050 #define RANDUINT() ( GlobalSearch::GSRandom::instance()->getRandomUInt() )
00051
00052
00053 #ifdef WIN32
00054
00055
00056 #define GS_ISNAN(a) _isnan((a))
00057 #define GS_ISINF(a) ((!static_cast<bool>(_finite((a)))) && \
00058 !static_cast<bool>(_isnan((a))))
00059 #define GS_SLEEP(a) Sleep(static_cast<unsigned long int>((a)*1000)) // arg in seconds
00060 #define GS_MSLEEP(a) Sleep(static_cast<unsigned long int>(a)) // arg in milliseconds
00061
00062 #else // def WIN32
00063
00064
00065 #define GS_ISNAN(a) std::isnan(a)
00066 #define GS_ISINF(a) std::isinf(a)
00067 #define GS_SLEEP(a) sleep(a) // arg in seconds
00068 #define GS_MSLEEP(a) usleep((a)*1000) // arg in milliseconds
00069
00070 #endif // WIN32
00071
00072
00073
00074 #define GS_IS_NAN_OR_INF(a) (GS_ISNAN(a) || GS_ISINF(a))
00075
00076 #endif // GLOBALSEARCHMACROS_H