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