source: tspsg-svn/trunk/src/globals.h @ 95

Last change on this file since 95 was 93, checked in by laleppa, 15 years ago

+ Preliminary Symbian support.

  • Property svn:keywords set to Id URL
File size: 3.3 KB
Line 
1/*!
2 * \file globals.h
3 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
4 *
5 *  $Id: globals.h 93 2010-02-23 22:17:48Z laleppa $
6 *  $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/globals.h $
7 *
8 * \brief Contains TSPSG global defines.
9 *
10 *  <b>TSPSG: TSP Solver and Generator</b>
11 *
12 *  This file is part of TSPSG.
13 *
14 *  TSPSG is free software: you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License as published by
16 *  the Free Software Foundation, either version 3 of the License, or
17 *  (at your option) any later version.
18 *
19 *  TSPSG is distributed in the hope that it will be useful,
20 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 *  GNU General Public License for more details.
23 *
24 *  You should have received a copy of the GNU General Public License
25 *  along with TSPSG.  If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#ifndef GLOBALS_H
29#define GLOBALS_H
30
31// INCLUDES
32#include <QtCore>
33#include <QtGui>
34
35// Version info
36#include "version.h"
37// OS and ARCH detection
38#include "os.h"
39// TSPSG Defaults
40#include "defaults.h"
41// Vista/7 Eyecandy
42#include "qtwin.h"
43
44// DEFINES
45//! Maximum available number of cities
46#define MAX_NUM_CITIES 50
47//! Maximum allowed value for random generation limits
48#define MAX_RAND_VALUE 1000
49
50// Paths
51/*!
52 * \def PATH_I18N
53 * \brief Bath to internationalization files.
54 */
55/*!
56 * \def PATH_DOCS
57 * \brief Bath to documentation files.
58 */
59#if defined(Q_OS_LINUX) || (defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN))
60        #define PATH_I18N "/usr/share/tspsg/i18n"
61        #define PATH_DOCS "/usr/share/doc/tspsg"
62#else
63        #define PATH_I18N "i18n"
64        #define PATH_DOCS "help"
65#endif // Q_OS_LINUX
66
67//! TSPSG Task file signature - letters \c TSPT
68#define TSPT quint32(0x54535054)
69//! TSPSG Task file version
70#define TSPT_VERSION quint8(1)
71//! TSPSG Task file metadata version
72#define TSPT_META_VERSION quint8(1)
73//! TSPSG Task file metadata size in bytes (incl. version)
74#define TSPT_META_SIZE 2
75//! ZKomModRd Task file signature - letters \c ZK
76#define ZKT quint16(0x5A4B)
77//! ZKomModRd Task file version
78#define ZKT_VERSION quint8(1)
79
80/*!
81 * \def INFINITY
82 * \brief This value means infinity :-)
83 *
84 *  Some libraries already have \c INFINITY defined.
85 *  We need to redefine it for the \c INFINITY to always have the same value.
86 */
87#ifdef INFINITY
88        #undef INFINITY
89#endif
90#define INFINITY 1.7E+308
91//! This string represents infinite value in the table
92#define INFSTR "---"
93
94// FUNCTIONS
95/*!
96 * \brief Checks whether \a x contains an integer value.
97 * \param x A value to check.
98 * \return \c true if \a x countains an integer, oherwise \c false.
99 */
100inline bool isInteger(double x)
101{
102double i;
103        return (modf(x, &i) == 0.0);
104}
105
106// Sanity checks
107// Check that default number of cities is sane (<= MAX_NUM_CITIES)
108#if DEF_NUM_CITIES > MAX_NUM_CITIES
109        #undef DEF_NUM_CITIES
110        #define DEF_NUM_CITIES MAX_NUM_CITIES
111#endif
112// Check that maximum for random generation is sane (<= MAX_RAND_VALUE)
113#if DEF_RAND_MAX > MAX_RAND_VALUE
114        #undef DEF_RAND_MAX
115        #define DEF_RAND_MAX MAX_RAND_VALUE
116#endif
117// Check that DEF_RAND_MIN <= DEF_RAND_MAX
118#if DEF_RAND_MIN > DEF_RAND_MAX
119        #undef DEF_RAND_MIN
120        #define DEF_RAND_MIN DEF_RAND_MAX
121#endif
122
123#endif // GLOBALS_H
Note: See TracBrowser for help on using the repository browser.