checking in the recent efforts at optimizing clam
[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 //! Abbreviated name for signed long integers.
68 typedef long int signed_long;
69 //! Abbreviated name for signed long long integers.
70 typedef long long signed_long_long;
71
72 // some maximum and minimum values that are helpful.
73 #ifndef MAXINT32
74   //! Maximum 32-bit integer value.
75   #define MAXINT32 0x7fffffff
76 #endif
77 #ifndef MININT32
78   //! Minimum 32-bit integer value.
79   #define MININT32 0x80000000
80 #endif
81 #ifndef MAXINT16
82   //! Maximum 32-bit integer value.
83   #define MAXINT16 0x7fff
84 #endif
85 #ifndef MININT16
86   //! Minimum 32-bit integer value.
87   #define MININT16 0x8000
88 #endif
89 #ifndef MAXCHAR
90   //! Maximum byte-based character value.
91   #define MAXCHAR 0x7f
92 #endif
93 #ifndef MINCHAR
94   //! Minimum byte-based character value.
95   #define MINCHAR 0x80
96 #endif
97 #ifndef MAXBYTE
98   //! Maximum unsigned byte value.
99   #define MAXBYTE 0xff
100 #endif
101 #ifndef MINBYTE
102   //! Minimum unsigned byte value.
103   #define MINBYTE 0x00
104 #endif
105
106 // Provide definitions for integers with platform independent specific sizes.
107 // Note that these may have to be adjusted for 64 bit platforms.
108 typedef char int8;
109 typedef unsigned char uint8;
110 typedef signed short int16;
111 typedef unsigned short uint16;
112 typedef signed int int32;
113 typedef unsigned int uint32;
114
115 //////////////
116
117 // useful time constants.
118
119 // the _ms suffix indicates that these are measured in milliseconds.
120 const int SECOND_ms = 1000;  //!< Number of milliseconds in a second.
121 const int MINUTE_ms = 60 * SECOND_ms;  //!< Number of milliseconds in a minute.
122 const int HOUR_ms = 60 * MINUTE_ms;  //!< Number of milliseconds in an hour.
123 const int DAY_ms = 24 * HOUR_ms;  //!< Number of milliseconds in a day.
124
125 // the _s suffix indicates that these are measured in seconds.
126 const int MINUTE_s = 60;  //!< Number of seconds in a minute.
127 const int HOUR_s = 60 * MINUTE_s;  //!< Number of seconds in an hour.
128 const int DAY_s = 24 * HOUR_s;  //!< Number of seconds in a day.
129
130 //////////////
131
132 // useful general constants.
133
134 const int KILOBYTE = 1024;  //!< Number of bytes in a kilobyte.
135 const int MEGABYTE = KILOBYTE * KILOBYTE;  //!< Number of bytes in a megabyte.
136 const int GIGABYTE = MEGABYTE * KILOBYTE;  //!< Number of bytes in a gigabyte.
137 const double TERABYTE = double(GIGABYTE) * double(KILOBYTE);
138 //double TERABYTE() { return double(GIGABYTE) * double(KILOBYTE); }
139   //!< Number of bytes in a terabyte.
140 //  /*!< Implemented as a function to avoid annoying link errors for double
141 //  floating point constants in some compilers. */
142
143 //////////////
144
145 // Super basic objects...
146
147 //! lowest level object for all hoople objects.  supports run-time type id.
148
149 class root_object
150 {
151 public:
152   virtual ~root_object() {}
153 };
154
155 //////////////
156
157 // compiler specific dumping ground for global settings...
158
159 /*
160 #ifdef _MSC_VER
161   // turns off annoying complaints from visual c++.
162   #pragma warning(disable : 4251 4275 4003 4800 4355 4786 4290 4996 4407)
163   #pragma warning(error : 4172)
164     // 4251 and 4275 turn off warnings regarding statically linked code
165     //    not being marked with dll import/export flags.
166     // 4003 turns off warnings about insufficient number of parameters passed
167     //    to a macro.
168     // 4800 turns off the warning about conversion from int to bool not being
169     //    efficient.
170     // 4355 turns off the warning re 'this' used in base member init list.
171     // 4786 turns off the warning about 'identifier' truncated to 'number'
172     //    characters in the debug information which frequenly happens when
173     //    STL pair and set templates are expanded.
174     // 4172 is made an error because this warning is emitted for a dangerous
175     //    condition; the address of a local variable is being returned, making
176     //    the returned object junk in almost all cases.
177     // 4996 turns off warnings about deprecated functions, which are mostly
178     //    nonsense, since these are mainly the core posix functions.
179 #else
180 //hmmm: trying to fix complaints about size_t being '?'.
181 //  typedef long long __int64;
182   //#define __SIZE_TYPE__ long unsigned int
183 #endif  // ms visual c++.
184 */
185
186 //////////////
187
188 } //namespace.
189
190 #endif // outer guard.
191