Eclipse SUMO - Simulation of Urban MObility
fxexdefs.h
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3
// Copyright (C) 2004-2019 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials
5
// are made available under the terms of the Eclipse Public License v2.0
6
// which accompanies this distribution, and is available at
7
// http://www.eclipse.org/legal/epl-v20.html
8
// SPDX-License-Identifier: EPL-2.0
9
/****************************************************************************/
16
//
17
/****************************************************************************/
18
19
#ifndef FXEXDEFS_H
20
#define FXEXDEFS_H
21
22
#include <
config.h
>
23
24
#include <fx.h>
25
26
#ifdef WIN32
27
#define NOMINMAX
28
#include <windows.h>
29
#undef NOMINMAX
30
#endif
31
32
// loads the FOX defs
33
#ifndef FXDEFS_H
34
#include <fxdefs.h>
39
using namespace
FX;
40
#endif
41
42
// Disable warnings on extern before template instantiation for the Microsoft compiler.
43
// see "HOWTO: Exporting STL Components Inside & Outside of a Class" on the microsoft website
44
#if defined(WIN32) && defined(_MSC_VER)
45
#pragma warning (disable : 4231)
46
#endif
47
48
49
// implement CALLBACK for unix
50
#ifndef CALLBACK
51
#define CALLBACK
52
#endif
53
60
namespace
FXEX
{
61
62
// provide an extern mechanism
63
#ifdef WIN32
64
#ifdef FOXDLL
65
#ifndef FOXDLL_EXPORTS
66
#define FXEXTERN extern
67
#endif
68
#endif
69
#endif
70
71
#ifndef FXEXTERN
72
#define FXEXTERN
73
#endif
74
75
76
// Valid compression factors for Bzip and Gzip compression libraries
77
#define COMPRESS_MAX 9
78
#define COMPRESS_NORMAL 6
79
#define COMPRESS_FAST 1
80
#define COMPRESS_NONE 0
81
82
83
// Win32 defines INFINITE to be -1, we might as well do it too.
84
#ifndef WIN32
85
# define INFINITE (-1)
86
#endif
87
88
89
// determine the newline charater(s)
90
#ifdef WIN32
91
#define FXNEWLINE "\r\n"
92
#endif
93
#ifdef MAC
94
#define FXNEWLINE "\r"
95
#endif
96
#ifndef FXNEWLINE
97
#define FXNEWLINE "\n"
98
#endif
99
100
101
// make a short from two chars
102
#define MKUSHORT(l,h) ((((FX::FXuchar)(l))&0xff) | (((FX::FXuchar)(h))<<8))
103
104
/* !!!!
105
// Make a long from two ints - provided longs are twice the size of an int
106
#ifdef FX_LONG
107
# define MKULONG(l,h) ((((FX::FXuint)(l))&0xffffffff) | (((FX::FXuint)(h))<<32))
108
#else
109
# if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
110
# error "You wanted 64bit file sizes (actually 63), but I couldn't make it so..."
111
# endif
112
#endif
113
!!!! */
114
119
#define FXDeclare(Class) \
120
FXDECLARE(Class)
121
#define FXDeclareAbstract(Class) \
122
FXDECLARE_ABSTRACT(Class)
123
#define FXDefMap(Class) \
124
FXDEFMAP(Class) Class##Map[]
125
#define FXImplementAbstract(Class,Parent) \
126
FXIMPLEMENT_ABSTRACT(Class,Parent,Class##Map,ARRAYNUMBER(Class##Map))
127
#define FXImplement(Class,Parent) \
128
FXIMPLEMENT(Class,Parent,Class##Map,ARRAYNUMBER(Class##Map))
129
#define FXFuncDecl(Func) \
130
long on##Func (FXObject*,FXSelector,void*)
131
#define FXFuncImpl(Class,Func,tgt,sel,ptr) \
132
long Class::on##Func (FXOject *tgt,FXSelector sel, void *ptr)
133
#define FXMapTypes(Class,FromType,ToType,Func) \
134
FXMAPTYPES(SEL_##FromType,SEL_##ToType,Class::on##Func)
135
#define FXMapType(Class,SelType,Func) \
136
FXMAPTYPE(SEL_##SelType,Class::on##Func)
137
#define FXMapFuncs(Class,SelType,FromId,ToId,Func) \
138
FXMAPFUNCS(SEL_##SelType,Class::ID_##FromId,Class::ID_##ToId,Class::on#Func)
139
#define FXMapFunc(Class,SelType,Id,Func) \
140
FXMAPFUNC(SEL_##SelType,Class::ID_##Id,Class::on##Func)
141
142
144
#define FXSEND(tgt,sel,msg,ptr) \
145
(tgt->handle(this,FXSEL(sel,msg),ptr)
146
#define FXROUTE(src,tgt,sel,msg,ptr) \
147
(tgt->handle(src,FXSEL(sel,msg),ptr)
148
149
150
// debugging macros
151
#ifndef NDEBUG
152
# define FXCTOR() fxtrace (100,"%s::%s %p\n",getClassName(),getClassName(),this)
153
# define FXMETHOD(methodname) fxtrace (100,"%s::%s %p\n",getClassName(),#methodname,this)
154
# define FXDTOR() fxtrace (100,"%s::~%s %p\n",getClassName(),getClassName(),this)
155
#else
156
# define FXCTOR()
157
# define FXMETHOD(methodname)
158
# define FXDTOR()
159
#endif
160
161
162
// New selector types
163
enum
{
164
SEL_DATA
= FX::SEL_LAST,
// form of data as an event
165
SEL_THREAD
,
// thread/runnable events
166
SEL_WAITABLE_WAIT
,
// waitable event such as a Condition variable, semaphore, etc
167
SEL_WAITABLE_ACTIVATE
,
// waitable event such as a Condition variable, semaphore, etc
168
SEL_INTERLOCK
,
// interlocked event; object went into lock
169
SEL_BARRIER_LOCK
,
// barrier event; thread waiting in barrier lock
170
SEL_BARRIER_UNLOCK
,
// barrier event; barrier object reset, threads released
171
SEL_INPUT
,
// some type of input event
172
SEL_OUTPUT
,
// some type of output event
173
SEL_ERROR
,
// some type of error event
174
SEL_IO
,
// Some form of IO
175
SEL_IO_CONNECT
,
// Connection event
176
SEL_EVENT
,
// a generic event
177
SEL_BEGIN
,
// en event defining some begining
178
SEL_END
,
// an event defining some ending
179
SEL_TAG
,
// tag event
180
SEL_CONTENT
,
// content event
181
SEL_REGISTRY
,
// a registry event (TODO I have a plan for this...)
182
SEL_LASTEX
,
// Last message
183
SEL_THREAD_EVENT
184
};
185
186
188
typedef
FXint
FXIOStatus
;
189
enum
{
190
FXIOStatusUnknown
= -2,
191
FXIOStatusError
= -1,
192
FXIOStatusOk
= 0,
193
FXIOStatusOK
= 0,
194
FXIOStatusLast
195
};
196
#ifndef INVALID_HANDLE
197
# ifdef WIN32
198
# define INVALID_HANDLE INVALID_HANDLE_VALUE
199
# else
200
# define INVALID_HANDLE -1
201
# endif
202
#endif
203
204
#ifndef VALID_RESULT
205
# define VALID_RESULT 0
206
#endif
207
208
210
typedef
FXint
FXIOState
;
211
enum
{
212
FXIOStateUnknown
= -1,
213
FXIOStateNone
= -1,
214
FXIOStateOk
= 0,
215
FXIOStateOK
= 0,
216
FXIOStateUnconnected
,
217
FXIOStateConnected
,
218
FXIOStateOpen
=
FXIOStateConnected
,
219
FXIOStateListener
,
220
FXIOStateAccepted
,
221
FXIOStateDuplicated
,
222
FXIOStateLast
223
};
224
225
229
enum
FXSocketType
{
231
FXSocketTypeNone
= 0,
// unknown socket type
232
FXSocketTypeStream
,
// TCP socket
233
FXSocketTypeTCP
=
FXSocketTypeStream
,
// TCP socket
234
FXSocketTypeDatagram
,
// UDP socket
235
FXSocketTypeUDP
=
FXSocketTypeDatagram
// UDP socket
236
};
237
239
enum
FXSocketFamily
{
240
FXSocketFamilyNone
= 0,
// unknown socket family
241
FXSocketFamilyLocal
,
// Local domain socket (on nearly every system, same as Unix domain)
242
FXSocketFamilyInet
,
// Internet domain socket, version 4 (ie the default internet family)
243
FXSocketFamilyInet6
,
// Internet domain socket, version 6
244
FXSocketFamilyAutomatic
,
// automatically choose UNIX domain (local) socket, when connecting
245
// to localhost, internet domain for internet sockets
246
FXSocketFamilyUnix
=
FXSocketFamilyLocal
247
};
248
249
269
enum
FXFilePermission
{
270
FILEPERM_NONE
= 0,
// file has no permissions
271
FILEPERM_USER_READ
= 0x00000001,
// user can read from file
272
FILEPERM_USER_WRITE
= 0x00000002,
// user can write to file
273
FILEPERM_USER_EXEC
= 0X00000004,
// user can execute file
274
FILEPERM_GROUP_READ
= 0x00000010,
// group can read from file
275
FILEPERM_GROUP_WRITE
= 0x00000020,
// group can write to file
276
FILEPERM_GROUP_EXEC
= 0x00000040,
// group can execute the file
277
FILEPERM_OTHER_READ
= 0x00000100,
// everybody can read from file
278
FILEPERM_OTHER_WRITE
= 0x00000200,
// everybody can write to file
279
FILEPERM_OTHER_EXEC
= 0x00000400,
// everybody can execute the file
280
FILEPERM_READ
= 0x00000111,
// file read mask; set all read permissions
281
FILEPERM_WRITE
= 0x00000222,
// file write mask; set all write permissions
282
FILEPERM_EXEC
= 0x00000444,
// file execute mask; set all execute permissions
283
FILEPERM_ALL
= 0x00000777,
// permissions mask; set all permissions
284
FILEPERM_SET_UID
= 0x00001000,
// set the UID permission
285
FILEPERM_SET_GID
= 0x00002000,
// set the GID permisssion
286
FILEPERM_STICKY
= 0x00004000,
// set the STICKY permission
287
FILEPERM_SECURE_IO
=
FILEPERM_USER_READ
|
FILEPERM_USER_WRITE
,
// permissions suitable for single user IO access
288
FILEPERM_DEFAULT_IO
=
FILEPERM_READ
|
FILEPERM_USER_WRITE
|
FILEPERM_GROUP_WRITE
,
// permissions suitable for group IO access
289
FILEPERM_DEFAULT_EXEC
=
FILEPERM_READ
|
FILEPERM_USER_WRITE
|
FILEPERM_GROUP_WRITE
|
FILEPERM_EXEC
// permissions suitable for all users to execute a file
290
};
291
292
293
// thread stuff
294
#ifndef WIN32
295
typedef
void
*
FXThreadHandle
;
// handle to a thread
296
typedef
void
*
FXThreadMutex
;
// handle to a mutex
297
typedef
void
*
FXThreadCondition
;
// handle to a condition variable
298
typedef
void
*
FXThreadSemaphore
;
// handle to a semaphore
299
typedef
FXInputHandle*
FXThreadEventHandle
;
// handle to a thread event object
300
#else
301
typedef
HANDLE
FXThreadHandle
;
// handle to a thread
302
typedef
HANDLE
FXThreadMutex
;
// handle to a mutex
303
typedef
HANDLE
FXThreadCondition
;
// handle to a condition variable
304
typedef
HANDLE
FXThreadSemaphore
;
// handle to a semaphore
305
typedef
FXInputHandle
FXThreadEventHandle
;
// handle to a thread event object
306
#endif
307
308
309
// dynamic library loading
310
#ifndef WIN32
311
typedef
void
*
FXDLLHandle
;
// handle to a dynamically loaded file
312
#else
313
typedef
HMODULE
FXDLLHandle
;
// handle to a dynamically loaded file
314
#endif
315
316
317
// database interface handle
318
//typedef void* FXDatabaseHandle; // handle to a database connection
319
320
321
namespace
FXUtils {
322
324
326
extern
FXAPI
const
FXuchar
fxexversion
[3];
327
328
330
332
#ifdef WIN32
333
static
void
get_time_now(
unsigned
long
* abs_sec,
unsigned
long
* abs_nsec);
334
static
DWORD get_timeout(
unsigned
long
secs,
unsigned
long
nsecs, DWORD default_to);
335
#else
336
void
convert_timeval
(
struct
timeval* tv, FXuint ms);
337
void
convert_timespec
(
struct
timespec* ts, FXuint ms);
338
#endif
339
340
}
// namespace FXUtils
341
}
// namespace FXEX
342
343
#endif // FXEXDEFS_H
344
FXEX::FXSocketFamilyAutomatic
@ FXSocketFamilyAutomatic
Definition:
fxexdefs.h:244
FXEX::FILEPERM_SET_GID
@ FILEPERM_SET_GID
Definition:
fxexdefs.h:285
FXEX::SEL_THREAD
@ SEL_THREAD
Definition:
fxexdefs.h:165
FXEX::FILEPERM_USER_READ
@ FILEPERM_USER_READ
Definition:
fxexdefs.h:271
FXEX::FXSocketTypeStream
@ FXSocketTypeStream
Definition:
fxexdefs.h:232
FXEX::FILEPERM_READ
@ FILEPERM_READ
Definition:
fxexdefs.h:280
FXEX::SEL_BEGIN
@ SEL_BEGIN
Definition:
fxexdefs.h:177
FXEX::FILEPERM_GROUP_EXEC
@ FILEPERM_GROUP_EXEC
Definition:
fxexdefs.h:276
FXEX::FILEPERM_USER_EXEC
@ FILEPERM_USER_EXEC
Definition:
fxexdefs.h:273
FXEX::FXIOStatusUnknown
@ FXIOStatusUnknown
Definition:
fxexdefs.h:190
FXEX::FXSocketFamilyLocal
@ FXSocketFamilyLocal
Definition:
fxexdefs.h:241
FXEX::SEL_IO_CONNECT
@ SEL_IO_CONNECT
Definition:
fxexdefs.h:175
FXEX::FXIOStatusOK
@ FXIOStatusOK
Definition:
fxexdefs.h:193
FXEX::FXSocketTypeDatagram
@ FXSocketTypeDatagram
Definition:
fxexdefs.h:234
FXEX::SEL_IO
@ SEL_IO
Definition:
fxexdefs.h:174
FXEX::FXThreadSemaphore
void * FXThreadSemaphore
Definition:
fxexdefs.h:298
FXEX::FXIOStateOpen
@ FXIOStateOpen
Definition:
fxexdefs.h:218
FXEX::FXIOStatusLast
@ FXIOStatusLast
Definition:
fxexdefs.h:194
FXEX::FXIOStateUnconnected
@ FXIOStateUnconnected
Definition:
fxexdefs.h:216
FXEX::FILEPERM_ALL
@ FILEPERM_ALL
Definition:
fxexdefs.h:283
FXEX::SEL_TAG
@ SEL_TAG
Definition:
fxexdefs.h:179
FXEX::FILEPERM_NONE
@ FILEPERM_NONE
Definition:
fxexdefs.h:270
FXEX::SEL_WAITABLE_WAIT
@ SEL_WAITABLE_WAIT
Definition:
fxexdefs.h:166
FXEX::FILEPERM_OTHER_WRITE
@ FILEPERM_OTHER_WRITE
Definition:
fxexdefs.h:278
FXEX::FXIOStateConnected
@ FXIOStateConnected
Definition:
fxexdefs.h:217
FXEX::FXFilePermission
FXFilePermission
Definition:
fxexdefs.h:269
FXEX::FXSocketFamilyInet6
@ FXSocketFamilyInet6
Definition:
fxexdefs.h:243
FXEX::FILEPERM_DEFAULT_EXEC
@ FILEPERM_DEFAULT_EXEC
Definition:
fxexdefs.h:289
FXEX::SEL_WAITABLE_ACTIVATE
@ SEL_WAITABLE_ACTIVATE
Definition:
fxexdefs.h:167
FXEX::FXDLLHandle
void * FXDLLHandle
Definition:
fxexdefs.h:311
FXEX::SEL_CONTENT
@ SEL_CONTENT
Definition:
fxexdefs.h:180
FXEX::FXSocketTypeUDP
@ FXSocketTypeUDP
Definition:
fxexdefs.h:235
FXEX::SEL_BARRIER_LOCK
@ SEL_BARRIER_LOCK
Definition:
fxexdefs.h:169
FXEX
Definition:
FXBaseObject.cpp:47
FXEX::SEL_INPUT
@ SEL_INPUT
Definition:
fxexdefs.h:171
FXEX::FXUtils::fxexversion
FXAPI const FXuchar fxexversion[3]
Version number that the library version is compiled with.
FXEX::SEL_REGISTRY
@ SEL_REGISTRY
Definition:
fxexdefs.h:181
FXEX::FXIOStateLast
@ FXIOStateLast
Definition:
fxexdefs.h:222
FXEX::FXThreadEventHandle
FXInputHandle * FXThreadEventHandle
Definition:
fxexdefs.h:299
FXEX::FXSocketType
FXSocketType
Socket types.
Definition:
fxexdefs.h:230
FXEX::FXThreadHandle
void * FXThreadHandle
Definition:
fxexdefs.h:295
FXEX::SEL_BARRIER_UNLOCK
@ SEL_BARRIER_UNLOCK
Definition:
fxexdefs.h:170
FXEX::SEL_EVENT
@ SEL_EVENT
Definition:
fxexdefs.h:176
FXEX::FXUtils::convert_timeval
void convert_timeval(struct timeval *tv, FXuint ms)
time conversion routines
FXEX::FXSocketTypeNone
@ FXSocketTypeNone
Definition:
fxexdefs.h:231
FXEX::FXIOStateOK
@ FXIOStateOK
Definition:
fxexdefs.h:215
FXEX::FXThreadMutex
void * FXThreadMutex
Definition:
fxexdefs.h:296
FXEX::FXUtils::convert_timespec
void convert_timespec(struct timespec *ts, FXuint ms)
FXEX::FXSocketFamilyNone
@ FXSocketFamilyNone
Definition:
fxexdefs.h:240
FXEX::FILEPERM_OTHER_EXEC
@ FILEPERM_OTHER_EXEC
Definition:
fxexdefs.h:279
FXEX::FXIOStatusOk
@ FXIOStatusOk
Definition:
fxexdefs.h:192
FXEX::SEL_ERROR
@ SEL_ERROR
Definition:
fxexdefs.h:173
FXEX::SEL_END
@ SEL_END
Definition:
fxexdefs.h:178
FXEX::SEL_THREAD_EVENT
@ SEL_THREAD_EVENT
Definition:
fxexdefs.h:183
FXEX::FILEPERM_EXEC
@ FILEPERM_EXEC
Definition:
fxexdefs.h:282
FXEX::FILEPERM_WRITE
@ FILEPERM_WRITE
Definition:
fxexdefs.h:281
FXEX::FILEPERM_SET_UID
@ FILEPERM_SET_UID
Definition:
fxexdefs.h:284
FXEX::FXIOStatus
FXint FXIOStatus
IO status definitions.
Definition:
fxexdefs.h:188
FXEX::FXIOStateOk
@ FXIOStateOk
Definition:
fxexdefs.h:214
FXEX::FXIOStateListener
@ FXIOStateListener
Definition:
fxexdefs.h:219
FXEX::FXIOStateDuplicated
@ FXIOStateDuplicated
Definition:
fxexdefs.h:221
FXEX::FXSocketFamilyUnix
@ FXSocketFamilyUnix
Definition:
fxexdefs.h:246
config.h
FXEX::FILEPERM_USER_WRITE
@ FILEPERM_USER_WRITE
Definition:
fxexdefs.h:272
FXEX::FXSocketFamilyInet
@ FXSocketFamilyInet
Definition:
fxexdefs.h:242
FXEX::FILEPERM_DEFAULT_IO
@ FILEPERM_DEFAULT_IO
Definition:
fxexdefs.h:288
FXEX::SEL_LASTEX
@ SEL_LASTEX
Definition:
fxexdefs.h:182
FXEX::FILEPERM_STICKY
@ FILEPERM_STICKY
Definition:
fxexdefs.h:286
FXEX::FILEPERM_GROUP_READ
@ FILEPERM_GROUP_READ
Definition:
fxexdefs.h:274
FXEX::FXIOState
FXint FXIOState
IO state definitions.
Definition:
fxexdefs.h:210
FXEX::FXIOStateUnknown
@ FXIOStateUnknown
Definition:
fxexdefs.h:212
FXEX::FXSocketTypeTCP
@ FXSocketTypeTCP
Definition:
fxexdefs.h:233
FXEX::FILEPERM_SECURE_IO
@ FILEPERM_SECURE_IO
Definition:
fxexdefs.h:287
FXEX::FXIOStateAccepted
@ FXIOStateAccepted
Definition:
fxexdefs.h:220
FXEX::FILEPERM_GROUP_WRITE
@ FILEPERM_GROUP_WRITE
Definition:
fxexdefs.h:275
FXEX::FXIOStatusError
@ FXIOStatusError
Definition:
fxexdefs.h:191
FXEX::SEL_DATA
@ SEL_DATA
Definition:
fxexdefs.h:164
FXEX::FXSocketFamily
FXSocketFamily
Socket families.
Definition:
fxexdefs.h:239
FXEX::FXThreadCondition
void * FXThreadCondition
Definition:
fxexdefs.h:297
FXEX::SEL_INTERLOCK
@ SEL_INTERLOCK
Definition:
fxexdefs.h:168
FXEX::FXIOStateNone
@ FXIOStateNone
Definition:
fxexdefs.h:213
FXEX::FILEPERM_OTHER_READ
@ FILEPERM_OTHER_READ
Definition:
fxexdefs.h:277
FXEX::SEL_OUTPUT
@ SEL_OUTPUT
Definition:
fxexdefs.h:172
src
utils
foxtools
fxexdefs.h
Generated on Sun Dec 13 2020 08:44:58 for Eclipse SUMO - Simulation of Urban MObility by
1.8.20