SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fxexdefs.h
Go to the documentation of this file.
1
/********************************************************************************
2
* *
3
* FOX extension library: Definitions, Types, and Macros *
4
* *
5
*********************************************************************************
6
* Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. *
7
*********************************************************************************
8
* This library is free software; you can redistribute it and/or *
9
* modify it under the terms of the GNU Lesser General Public *
10
* License as published by the Free Software Foundation; either *
11
* version 2.1 of the License, or (at your option) any later version. *
12
* *
13
* This library is distributed in the hope that it will be useful, *
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16
* Lesser General Public License for more details. *
17
* *
18
* You should have received a copy of the GNU Lesser General Public *
19
* License along with this library; if not, write to the Free Software *
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21
********************************************************************************/
22
#ifndef FXEXDEFS_H
23
#define FXEXDEFS_H
24
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <fx.h>
32
33
#ifdef WIN32
34
#define NOMINMAX
35
#include <windows.h>
36
#undef NOMINMAX
37
#endif
38
39
// loads the FOX defs
40
#ifndef FXDEFS_H
41
#include <fxdefs.h>
46
using namespace
FX;
47
#endif
48
49
// Disable warnings on extern before template instantiation for the Microsoft compiler.
50
// see "HOWTO: Exporting STL Components Inside & Outside of a Class" on the microsoft website
51
#if defined(WIN32) && defined(_MSC_VER)
52
#pragma warning (disable : 4231)
53
#endif
54
55
56
// implement CALLBACK for unix
57
#ifndef CALLBACK
58
#define CALLBACK
59
#endif
60
67
namespace
FXEX {
68
69
// provide an extern mechanism
70
#ifdef WIN32
71
#ifdef FOXDLL
72
#ifndef FOXDLL_EXPORTS
73
#define FXEXTERN extern
74
#endif
75
#endif
76
#endif
77
78
#ifndef FXEXTERN
79
#define FXEXTERN
80
#endif
81
82
83
// Valid compression factors for Bzip and Gzip compression libraries
84
#define COMPRESS_MAX 9
85
#define COMPRESS_NORMAL 6
86
#define COMPRESS_FAST 1
87
#define COMPRESS_NONE 0
88
89
90
// Win32 defines INFINITE to be -1, we might as well do it too.
91
#ifndef WIN32
92
# define INFINITE (-1)
93
#endif
94
95
96
// determine the newline charater(s)
97
#ifdef WIN32
98
#define FXNEWLINE "\r\n"
99
#endif
100
#ifdef MAC
101
#define FXNEWLINE "\r"
102
#endif
103
#ifndef FXNEWLINE
104
#define FXNEWLINE "\n"
105
#endif
106
107
108
// make a short from two chars
109
#define MKUSHORT(l,h) ((((FX::FXuchar)(l))&0xff) | (((FX::FXuchar)(h))<<8))
110
111
/* !!!!
112
// Make a long from two ints - provided longs are twice the size of an int
113
#ifdef FX_LONG
114
# define MKULONG(l,h) ((((FX::FXuint)(l))&0xffffffff) | (((FX::FXuint)(h))<<32))
115
#else
116
# if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
117
# error "You wanted 64bit file sizes (actually 63), but I couldn't make it so..."
118
# endif
119
#endif
120
!!!! */
121
126
#define FXDeclare(Class) \
127
FXDECLARE(Class)
128
#define FXDeclareAbstract(Class) \
129
FXDECLARE_ABSTRACT(Class)
130
#define FXDefMap(Class) \
131
FXDEFMAP(Class) Class##Map[]
132
#define FXImplementAbstract(Class,Parent) \
133
FXIMPLEMENT_ABSTRACT(Class,Parent,Class##Map,ARRAYNUMBER(Class##Map))
134
#define FXImplement(Class,Parent) \
135
FXIMPLEMENT(Class,Parent,Class##Map,ARRAYNUMBER(Class##Map))
136
#define FXFuncDecl(Func) \
137
long on##Func (FXObject*,FXSelector,void*)
138
#define FXFuncImpl(Class,Func,tgt,sel,ptr) \
139
long Class::on##Func (FXOject *tgt,FXSelector sel, void *ptr)
140
#define FXMapTypes(Class,FromType,ToType,Func) \
141
FXMAPTYPES(SEL_##FromType,SEL_##ToType,Class::on##Func)
142
#define FXMapType(Class,SelType,Func) \
143
FXMAPTYPE(SEL_##SelType,Class::on##Func)
144
#define FXMapFuncs(Class,SelType,FromId,ToId,Func) \
145
FXMAPFUNCS(SEL_##SelType,Class::ID_##FromId,Class::ID_##ToId,Class::on#Func)
146
#define FXMapFunc(Class,SelType,Id,Func) \
147
FXMAPFUNC(SEL_##SelType,Class::ID_##Id,Class::on##Func)
148
149
151
#define FXSEND(tgt,sel,msg,ptr) \
152
(tgt->handle(this,FXSEL(sel,msg),ptr)
153
#define FXROUTE(src,tgt,sel,msg,ptr) \
154
(tgt->handle(src,FXSEL(sel,msg),ptr)
155
156
157
// debugging macros
158
#ifndef NDEBUG
159
# define FXCTOR() fxtrace (100,"%s::%s %p\n",getClassName(),getClassName(),this)
160
# define FXMETHOD(methodname) fxtrace (100,"%s::%s %p\n",getClassName(),#methodname,this)
161
# define FXDTOR() fxtrace (100,"%s::~%s %p\n",getClassName(),getClassName(),this)
162
#else
163
# define FXCTOR()
164
# define FXMETHOD(methodname)
165
# define FXDTOR()
166
#endif
167
168
169
// New selector types
170
enum
{
171
SEL_DATA
= FX::SEL_LAST,
// form of data as an event
172
SEL_THREAD
,
// thread/runnable events
173
SEL_WAITABLE_WAIT
,
// waitable event such as a Condition variable, semaphore, etc
174
SEL_WAITABLE_ACTIVATE
,
// waitable event such as a Condition variable, semaphore, etc
175
SEL_INTERLOCK
,
// interlocked event; object went into lock
176
SEL_BARRIER_LOCK
,
// barrier event; thread waiting in barrier lock
177
SEL_BARRIER_UNLOCK
,
// barrier event; barrier object reset, threads released
178
SEL_INPUT
,
// some type of input event
179
SEL_OUTPUT
,
// some type of output event
180
SEL_ERROR
,
// some type of error event
181
SEL_IO
,
// Some form of IO
182
SEL_IO_CONNECT
,
// Connection event
183
SEL_EVENT
,
// a generic event
184
SEL_BEGIN
,
// en event defining some begining
185
SEL_END
,
// an event defining some ending
186
SEL_TAG
,
// tag event
187
SEL_CONTENT
,
// content event
188
SEL_REGISTRY
,
// a registry event (TODO I have a plan for this...)
189
SEL_LASTEX
,
// Last message
190
SEL_THREAD_EVENT
191
};
192
193
195
typedef
FXint
FXIOStatus
;
196
enum
{
197
FXIOStatusUnknown
= -2,
198
FXIOStatusError
= -1,
199
FXIOStatusOk
= 0,
200
FXIOStatusOK
= 0,
201
FXIOStatusLast
202
};
203
#ifndef INVALID_HANDLE
204
# ifdef WIN32
205
# define INVALID_HANDLE INVALID_HANDLE_VALUE
206
# else
207
# define INVALID_HANDLE -1
208
# endif
209
#endif
210
211
#ifndef VALID_RESULT
212
# define VALID_RESULT 0
213
#endif
214
215
217
typedef
FXint
FXIOState
;
218
enum
{
219
FXIOStateUnknown
= -1,
220
FXIOStateNone
= -1,
221
FXIOStateOk
= 0,
222
FXIOStateOK
= 0,
223
FXIOStateUnconnected
,
224
FXIOStateConnected
,
225
FXIOStateOpen
=
FXIOStateConnected
,
226
FXIOStateListener
,
227
FXIOStateAccepted
,
228
FXIOStateDuplicated
,
229
FXIOStateLast
230
};
231
232
236
237
enum
FXSocketType
{
238
FXSocketTypeNone
= 0,
// unknown socket type
239
FXSocketTypeStream
,
// TCP socket
240
FXSocketTypeTCP
=
FXSocketTypeStream
,
// TCP socket
241
FXSocketTypeDatagram
,
// UDP socket
242
FXSocketTypeUDP
=
FXSocketTypeDatagram
// UDP socket
243
};
244
246
enum
FXSocketFamily
{
247
FXSocketFamilyNone
= 0,
// unknown socket family
248
FXSocketFamilyLocal
,
// Local domain socket (on nearly every system, same as Unix domain)
249
FXSocketFamilyInet
,
// Internet domain socket, version 4 (ie the default internet family)
250
FXSocketFamilyInet6
,
// Internet domain socket, version 6
251
FXSocketFamilyAutomatic
,
// automatically choose UNIX domain (local) socket, when connecting
252
// to localhost, internet domain for internet sockets
253
FXSocketFamilyUnix
=
FXSocketFamilyLocal
254
};
255
256
276
enum
FXFilePermission
{
277
FILEPERM_NONE
= 0,
// file has no permissions
278
FILEPERM_USER_READ
= 0x00000001,
// user can read from file
279
FILEPERM_USER_WRITE
= 0x00000002,
// user can write to file
280
FILEPERM_USER_EXEC
= 0X00000004,
// user can execute file
281
FILEPERM_GROUP_READ
= 0x00000010,
// group can read from file
282
FILEPERM_GROUP_WRITE
= 0x00000020,
// group can write to file
283
FILEPERM_GROUP_EXEC
= 0x00000040,
// group can execute the file
284
FILEPERM_OTHER_READ
= 0x00000100,
// everybody can read from file
285
FILEPERM_OTHER_WRITE
= 0x00000200,
// everybody can write to file
286
FILEPERM_OTHER_EXEC
= 0x00000400,
// everybody can execute the file
287
FILEPERM_READ
= 0x00000111,
// file read mask; set all read permissions
288
FILEPERM_WRITE
= 0x00000222,
// file write mask; set all write permissions
289
FILEPERM_EXEC
= 0x00000444,
// file execute mask; set all execute permissions
290
FILEPERM_ALL
= 0x00000777,
// permissions mask; set all permissions
291
FILEPERM_SET_UID
= 0x00001000,
// set the UID permission
292
FILEPERM_SET_GID
= 0x00002000,
// set the GID permisssion
293
FILEPERM_STICKY
= 0x00004000,
// set the STICKY permission
294
FILEPERM_SECURE_IO
=
FILEPERM_USER_READ
|
FILEPERM_USER_WRITE
,
// permissions suitable for single user IO access
295
FILEPERM_DEFAULT_IO
=
FILEPERM_READ
|
FILEPERM_USER_WRITE
|
FILEPERM_GROUP_WRITE
,
// permissions suitable for group IO access
296
FILEPERM_DEFAULT_EXEC
=
FILEPERM_READ
|
FILEPERM_USER_WRITE
|
FILEPERM_GROUP_WRITE
|
FILEPERM_EXEC
// permissions suitable for all users to execute a file
297
};
298
299
300
// thread stuff
301
#ifndef WIN32
302
typedef
void
*
FXThreadHandle
;
// handle to a thread
303
typedef
void
*
FXThreadMutex
;
// handle to a mutex
304
typedef
void
*
FXThreadCondition
;
// handle to a condition variable
305
typedef
void
*
FXThreadSemaphore
;
// handle to a semaphore
306
typedef
FXInputHandle*
FXThreadEventHandle
;
// handle to a thread event object
307
#else
308
typedef
HANDLE
FXThreadHandle
;
// handle to a thread
309
typedef
HANDLE
FXThreadMutex
;
// handle to a mutex
310
typedef
HANDLE
FXThreadCondition
;
// handle to a condition variable
311
typedef
HANDLE
FXThreadSemaphore
;
// handle to a semaphore
312
typedef
FXInputHandle
FXThreadEventHandle
;
// handle to a thread event object
313
#endif
314
315
316
// dynamic library loading
317
#ifndef WIN32
318
typedef
void
*
FXDLLHandle
;
// handle to a dynamically loaded file
319
#else
320
typedef
HMODULE
FXDLLHandle
;
// handle to a dynamically loaded file
321
#endif
322
323
324
// database interface handle
325
//typedef void* FXDatabaseHandle; // handle to a database connection
326
327
328
namespace
FXUtils {
329
331
333
extern
FXAPI
const
FXuchar
fxexversion
[3];
334
335
337
339
#ifdef WIN32
340
static
void
get_time_now(
unsigned
long
* abs_sec,
unsigned
long
* abs_nsec);
341
static
DWORD get_timeout(
unsigned
long
secs,
unsigned
long
nsecs, DWORD default_to);
342
#else
343
void
convert_timeval
(
struct
timeval* tv, FXuint ms);
344
void
convert_timespec
(
struct
timespec* ts, FXuint ms);
345
#endif
346
347
}
// namespace FXUtils
348
}
// namespace FXEX
349
350
#endif // FXEXDEFS_H
351
build
buildd
sumo-0.17.1~dfsg
src
utils
foxtools
fxexdefs.h
Generated on Sun Jun 16 2013 17:30:14 for SUMO - Simulation of Urban MObility by
1.8.3.1