8d022ab0f5a7a0c5d7e5a9404949b0712cf6164b
[feisty_meow.git] / nucleus / library / basis / definitions.h
1 #ifndef DEFINITIONS_GROUP
2 #define DEFINITIONS_GROUP
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : definitions                                                       *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 1991-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 //! @file "definitions.h" Constants and objects used throughout HOOPLE.
19 /*! @file
20   Defines a set of useful universal constants (for our chosen universe) and
21   a set of aliases for convenient abstract and concrete data types.
22   This is the lowest-level header in hoople and should not include any others.
23 */
24
25 namespace basis {
26
27 //////////////
28
29 // Constants...
30
31 //! The value representing a pointer to nothing.
32 #define NULL_POINTER 0
33
34 ////! A null pointer with a type of (void *).
35 //#define NULL_VOID_POINTER (void *)NULL_POINTER
36
37 //! A fundamental constant measuring the number of bits in a byte.
38 #define BITS_PER_BYTE 8
39
40 //! An approximation of the fundamental circular constant.
41 #define PI_APPROX 3.14159265358
42
43 //////////////
44
45 // Data Structures & Functions
46
47 //! This macro just eats what it's passed; it marks unused formal parameters.
48 #define formal(parameter)
49
50 //! A fairly important unit which is seldom defined...
51 typedef unsigned char abyte;
52
53 #if defined(UNICODE) && defined(__WIN32__)
54   //! the flexichar type is always appropriate to hold data for win32 calls.
55   typedef wchar_t flexichar;
56 #else
57   // this version simply defangs any conversions.
58   typedef char flexichar;
59 #endif
60
61 //! Abbreviated name for unsigned integers.
62 typedef unsigned int un_int;
63 //! Abbreviated name for unsigned short integers.
64 typedef unsigned short un_short;
65 //! Abbreviated name for unsigned long integers.
66 typedef unsigned long un_long;
67
68 // some maximum and minimum values that are helpful.
69 #ifndef MAXINT32
70   //! Maximum 32-bit integer value.
71   #define MAXINT32 0x7fffffff
72 #endif
73 #ifndef MININT32
74   //! Minimum 32-bit integer value.
75   #define MININT32 0x80000000
76 #endif
77 #ifndef MAXINT16
78   //! Maximum 32-bit integer value.
79   #define MAXINT16 0x7fff
80 #endif
81 #ifndef MININT16
82   //! Minimum 32-bit integer value.
83   #define MININT16 0x8000
84 #endif
85 #ifndef MAXCHAR
86   //! Maximum byte-based character value.
87   #define MAXCHAR 0x7f
88 #endif
89 #ifndef MINCHAR
90   //! Minimum byte-based character value.
91   #define MINCHAR 0x80
92 #endif
93 #ifndef MAXBYTE
94   //! Maximum unsigned byte value.
95   #define MAXBYTE 0xff
96 #endif
97 #ifndef MINBYTE
98   //! Minimum unsigned byte value.
99   #define MINBYTE 0x00
100 #endif
101
102 // Provide definitions for integers with platform independent specific sizes.
103 // Note that these may have to be adjusted for 64 bit platforms.
104 typedef char int8;
105 typedef unsigned char uint8;
106 typedef signed short int16;
107 typedef unsigned short uint16;
108 typedef signed int int32;
109 typedef unsigned int uint32;
110
111 //////////////
112
113 // useful time constants.
114
115 // the _ms suffix indicates that these are measured in milliseconds.
116 const int SECOND_ms = 1000;  //!< Number of milliseconds in a second.
117 const int MINUTE_ms = 60 * SECOND_ms;  //!< Number of milliseconds in a minute.
118 const int HOUR_ms = 60 * MINUTE_ms;  //!< Number of milliseconds in an hour.
119 const int DAY_ms = 24 * HOUR_ms;  //!< Number of milliseconds in a day.
120
121 // the _s suffix indicates that these are measured in seconds.
122 const int MINUTE_s = 60;  //!< Number of seconds in a minute.
123 const int HOUR_s = 60 * MINUTE_s;  //!< Number of seconds in an hour.
124 const int DAY_s = 24 * HOUR_s;  //!< Number of seconds in a day.
125
126 //////////////
127
128 // useful general constants.
129
130 const int KILOBYTE = 1024;  //!< Number of bytes in a kilobyte.
131 const int MEGABYTE = KILOBYTE * KILOBYTE;  //!< Number of bytes in a megabyte.
132 const int GIGABYTE = MEGABYTE * KILOBYTE;  //!< Number of bytes in a gigabyte.
133 const double TERABYTE = double(GIGABYTE) * double(KILOBYTE);
134 //double TERABYTE() { return double(GIGABYTE) * double(KILOBYTE); }
135   //!< Number of bytes in a terabyte.
136 //  /*!< Implemented as a function to avoid annoying link errors for double
137 //  floating point constants in some compilers. */
138
139 //////////////
140
141 // Super basic objects...
142
143 //! lowest level object for all hoople objects.  supports run-time type id.
144
145 class root_object
146 {
147 public:
148   virtual ~root_object() {}
149 };
150
151 //////////////
152
153 // compiler specific dumping ground for global settings...
154
155 #ifdef _MSC_VER
156   // turns off annoying complaints from visual c++.
157   #pragma warning(disable : 4251 4275 4003 4800 4355 4786 4290 4996 4407)
158   #pragma warning(error : 4172)
159     // 4251 and 4275 turn off warnings regarding statically linked code
160     //    not being marked with dll import/export flags.
161     // 4003 turns off warnings about insufficient number of parameters passed
162     //    to a macro.
163     // 4800 turns off the warning about conversion from int to bool not being
164     //    efficient.
165     // 4355 turns off the warning re 'this' used in base member init list.
166     // 4786 turns off the warning about 'identifier' truncated to 'number'
167     //    characters in the debug information which frequenly happens when
168     //    STL pair and set templates are expanded.
169     // 4172 is made an error because this warning is emitted for a dangerous
170     //    condition; the address of a local variable is being returned, making
171     //    the returned object junk in almost all cases.
172     // 4996 turns off warnings about deprecated functions, which are mostly
173     //    nonsense, since these are mainly the core posix functions.
174 #else
175 //hmmm: trying to fix complaints about size_t being '?'.
176 //  typedef long long __int64;
177   //#define __SIZE_TYPE__ long unsigned int
178 #endif  // ms visual c++.
179
180 //////////////
181
182 } //namespace.
183
184 #endif // outer guard.
185