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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 //
21 /****************************************************************************/
22 
23 #ifndef FXEXDEFS_H
24 #define FXEXDEFS_H
25 
26 #include <config.h>
27 
28 #include "fxheader.h"
29 
30 #ifdef WIN32
31 #define NOMINMAX
32 #include <windows.h>
33 #undef NOMINMAX
34 #endif
35 
36 // loads the FOX defs
37 #ifndef FXDEFS_H
38 #include <fxdefs.h>
43 using namespace FX;
44 #endif
45 
46 // Disable warnings on extern before template instantiation for the Microsoft compiler.
47 // see "HOWTO: Exporting STL Components Inside & Outside of a Class" on the microsoft website
48 #if defined(WIN32) && defined(_MSC_VER)
49 #pragma warning (disable : 4231)
50 #endif
51 
52 
53 // implement CALLBACK for unix
54 #ifndef CALLBACK
55 #define CALLBACK
56 #endif
57 
64 namespace FXEX {
65 
66 // provide an extern mechanism
67 #ifdef WIN32
68 #ifdef FOXDLL
69 #ifndef FOXDLL_EXPORTS
70 #define FXEXTERN extern
71 #endif
72 #endif
73 #endif
74 
75 #ifndef FXEXTERN
76 #define FXEXTERN
77 #endif
78 
79 // Valid compression factors for Bzip and Gzip compression libraries
80 #define COMPRESS_MAX 9
81 #define COMPRESS_NORMAL 6
82 #define COMPRESS_FAST 1
83 #define COMPRESS_NONE 0
84 
85 // Win32 defines INFINITE to be -1, we might as well do it too.
86 #ifndef WIN32
87 # define INFINITE (-1)
88 #endif
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 // 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 
143 #define FXSEND(tgt,sel,msg,ptr) \
144  (tgt->handle(this,FXSEL(sel,msg),ptr)
145 #define FXROUTE(src,tgt,sel,msg,ptr) \
146  (tgt->handle(src,FXSEL(sel,msg),ptr)
147 
148 // debugging macros
149 #ifndef NDEBUG
150 # define FXCTOR() fxtrace (100,"%s::%s %p\n",getClassName(),getClassName(),this)
151 # define FXMETHOD(methodname) fxtrace (100,"%s::%s %p\n",getClassName(),#methodname,this)
152 # define FXDTOR() fxtrace (100,"%s::~%s %p\n",getClassName(),getClassName(),this)
153 #else
154 # define FXCTOR()
155 # define FXMETHOD(methodname)
156 # define FXDTOR()
157 #endif
158 
159 // New selector types
160 enum {
161  SEL_DATA = FX::SEL_LAST, // form of data as an event
162  SEL_THREAD, // thread/runnable events
163  SEL_WAITABLE_WAIT, // waitable event such as a Condition variable, semaphore, etc
164  SEL_WAITABLE_ACTIVATE, // waitable event such as a Condition variable, semaphore, etc
165  SEL_INTERLOCK, // interlocked event; object went into lock
166  SEL_BARRIER_LOCK, // barrier event; thread waiting in barrier lock
167  SEL_BARRIER_UNLOCK, // barrier event; barrier object reset, threads released
168  SEL_INPUT, // some type of input event
169  SEL_OUTPUT, // some type of output event
170  SEL_ERROR, // some type of error event
171  SEL_IO, // Some form of IO
172  SEL_IO_CONNECT, // Connection event
173  SEL_EVENT, // a generic event
174  SEL_BEGIN, // en event defining some begining
175  SEL_END, // an event defining some ending
176  SEL_TAG, // tag event
177  SEL_CONTENT, // content event
178  SEL_REGISTRY, // a registry event (TODO I have a plan for this...)
179  SEL_LASTEX,// Last message
181 };
182 
184 typedef FXint FXIOStatus;
185 enum {
191 };
192 #ifndef INVALID_HANDLE
193 #ifdef WIN32
194 #define INVALID_HANDLE INVALID_HANDLE_VALUE
195 #else
196 #define INVALID_HANDLE -1
197 #endif
198 #endif
199 
200 #ifndef VALID_RESULT
201 #define VALID_RESULT 0
202 #endif
203 
205 typedef FXint FXIOState;
206 enum {
218 };
219 
225  FXSocketTypeNone = 0, // unknown socket type
226  FXSocketTypeStream, // TCP socket
228  FXSocketTypeDatagram, // UDP socket
229  FXSocketTypeUDP = FXSocketTypeDatagram // UDP socket
230 };
231 
234  FXSocketFamilyNone = 0, // unknown socket family
235  FXSocketFamilyLocal, // Local domain socket (on nearly every system, same as Unix domain)
236  FXSocketFamilyInet, // Internet domain socket, version 4 (ie the default internet family)
237  FXSocketFamilyInet6, // Internet domain socket, version 6
238  FXSocketFamilyAutomatic, // automatically choose UNIX domain (local) socket, when connecting
239  // to localhost, internet domain for internet sockets
241 };
242 
263  FILEPERM_NONE = 0, // file has no permissions
264  FILEPERM_USER_READ = 0x00000001, // user can read from file
265  FILEPERM_USER_WRITE = 0x00000002, // user can write to file
266  FILEPERM_USER_EXEC = 0X00000004, // user can execute file
267  FILEPERM_GROUP_READ = 0x00000010, // group can read from file
268  FILEPERM_GROUP_WRITE = 0x00000020, // group can write to file
269  FILEPERM_GROUP_EXEC = 0x00000040, // group can execute the file
270  FILEPERM_OTHER_READ = 0x00000100, // everybody can read from file
271  FILEPERM_OTHER_WRITE = 0x00000200, // everybody can write to file
272  FILEPERM_OTHER_EXEC = 0x00000400, // everybody can execute the file
273  FILEPERM_READ = 0x00000111, // file read mask; set all read permissions
274  FILEPERM_WRITE = 0x00000222, // file write mask; set all write permissions
275  FILEPERM_EXEC = 0x00000444, // file execute mask; set all execute permissions
276  FILEPERM_ALL = 0x00000777, // permissions mask; set all permissions
277  FILEPERM_SET_UID = 0x00001000, // set the UID permission
278  FILEPERM_SET_GID = 0x00002000, // set the GID permisssion
279  FILEPERM_STICKY = 0x00004000, // set the STICKY permission
280  FILEPERM_SECURE_IO = FILEPERM_USER_READ | FILEPERM_USER_WRITE, // permissions suitable for single user IO access
281  FILEPERM_DEFAULT_IO = FILEPERM_READ | FILEPERM_USER_WRITE | FILEPERM_GROUP_WRITE, // permissions suitable for group IO access
282  FILEPERM_DEFAULT_EXEC = FILEPERM_READ | FILEPERM_USER_WRITE | FILEPERM_GROUP_WRITE | FILEPERM_EXEC // permissions suitable for all users to execute a file
283 };
284 
285 // thread stuff
286 #ifndef WIN32
287 typedef void* FXThreadHandle; // handle to a thread
288 typedef void* FXThreadMutex; // handle to a mutex
289 typedef void* FXThreadCondition; // handle to a condition variable
290 typedef void* FXThreadSemaphore; // handle to a semaphore
291 typedef FXInputHandle* FXThreadEventHandle; // handle to a thread event object
292 #else
293 typedef HANDLE FXThreadHandle; // handle to a thread
294 typedef HANDLE FXThreadMutex; // handle to a mutex
295 typedef HANDLE FXThreadCondition; // handle to a condition variable
296 typedef HANDLE FXThreadSemaphore; // handle to a semaphore
297 typedef FXInputHandle FXThreadEventHandle; // handle to a thread event object
298 #endif
299 
300 // dynamic library loading
301 #ifndef WIN32
302 typedef void* FXDLLHandle; // handle to a dynamically loaded file
303 #else
304 typedef HMODULE FXDLLHandle; // handle to a dynamically loaded file
305 #endif
306 
307 namespace FXUtils {
309 extern FXAPI const FXuchar fxexversion[3];
310 }
311 } // namespace FXEX
312 
313 #endif // FXEXDEFS_H
314 
FXAPI const FXuchar fxexversion[3]
Version number that the library version is compiled with.
void * FXDLLHandle
Definition: fxexdefs.h:302
FXInputHandle * FXThreadEventHandle
Definition: fxexdefs.h:291
FXint FXIOStatus
IO status definitions.
Definition: fxexdefs.h:184
@ FXIOStateOK
Definition: fxexdefs.h:210
@ FXIOStateAccepted
Definition: fxexdefs.h:215
@ FXIOStateNone
Definition: fxexdefs.h:208
@ FXIOStateOk
Definition: fxexdefs.h:209
@ FXIOStateConnected
Definition: fxexdefs.h:212
@ FXIOStateDuplicated
Definition: fxexdefs.h:216
@ FXIOStateListener
Definition: fxexdefs.h:214
@ FXIOStateLast
Definition: fxexdefs.h:217
@ FXIOStateUnconnected
Definition: fxexdefs.h:211
@ FXIOStateUnknown
Definition: fxexdefs.h:207
@ FXIOStateOpen
Definition: fxexdefs.h:213
@ SEL_REGISTRY
Definition: fxexdefs.h:178
@ SEL_CONTENT
Definition: fxexdefs.h:177
@ SEL_BARRIER_LOCK
Definition: fxexdefs.h:166
@ SEL_OUTPUT
Definition: fxexdefs.h:169
@ SEL_END
Definition: fxexdefs.h:175
@ SEL_EVENT
Definition: fxexdefs.h:173
@ SEL_WAITABLE_ACTIVATE
Definition: fxexdefs.h:164
@ SEL_INTERLOCK
Definition: fxexdefs.h:165
@ SEL_INPUT
Definition: fxexdefs.h:168
@ SEL_BEGIN
Definition: fxexdefs.h:174
@ SEL_WAITABLE_WAIT
Definition: fxexdefs.h:163
@ SEL_LASTEX
Definition: fxexdefs.h:179
@ SEL_IO_CONNECT
Definition: fxexdefs.h:172
@ SEL_THREAD_EVENT
Definition: fxexdefs.h:180
@ SEL_DATA
Definition: fxexdefs.h:161
@ SEL_IO
Definition: fxexdefs.h:171
@ SEL_BARRIER_UNLOCK
Definition: fxexdefs.h:167
@ SEL_TAG
Definition: fxexdefs.h:176
@ SEL_ERROR
Definition: fxexdefs.h:170
@ SEL_THREAD
Definition: fxexdefs.h:162
void * FXThreadHandle
Definition: fxexdefs.h:287
void * FXThreadMutex
Definition: fxexdefs.h:288
FXint FXIOState
IO state definitions.
Definition: fxexdefs.h:205
void * FXThreadSemaphore
Definition: fxexdefs.h:290
FXSocketType
Socket types.
Definition: fxexdefs.h:224
@ FXSocketTypeTCP
Definition: fxexdefs.h:227
@ FXSocketTypeUDP
Definition: fxexdefs.h:229
@ FXSocketTypeDatagram
Definition: fxexdefs.h:228
@ FXSocketTypeStream
Definition: fxexdefs.h:226
@ FXSocketTypeNone
Definition: fxexdefs.h:225
void * FXThreadCondition
Definition: fxexdefs.h:289
FXSocketFamily
Socket families.
Definition: fxexdefs.h:233
@ FXSocketFamilyNone
Definition: fxexdefs.h:234
@ FXSocketFamilyUnix
Definition: fxexdefs.h:240
@ FXSocketFamilyAutomatic
Definition: fxexdefs.h:238
@ FXSocketFamilyInet6
Definition: fxexdefs.h:237
@ FXSocketFamilyLocal
Definition: fxexdefs.h:235
@ FXSocketFamilyInet
Definition: fxexdefs.h:236
@ FXIOStatusOk
Definition: fxexdefs.h:188
@ FXIOStatusUnknown
Definition: fxexdefs.h:186
@ FXIOStatusLast
Definition: fxexdefs.h:190
@ FXIOStatusError
Definition: fxexdefs.h:187
@ FXIOStatusOK
Definition: fxexdefs.h:189
FXFilePermission
Definition: fxexdefs.h:262
@ FILEPERM_GROUP_READ
Definition: fxexdefs.h:267
@ FILEPERM_NONE
Definition: fxexdefs.h:263
@ FILEPERM_OTHER_WRITE
Definition: fxexdefs.h:271
@ FILEPERM_READ
Definition: fxexdefs.h:273
@ FILEPERM_USER_READ
Definition: fxexdefs.h:264
@ FILEPERM_OTHER_EXEC
Definition: fxexdefs.h:272
@ FILEPERM_GROUP_EXEC
Definition: fxexdefs.h:269
@ FILEPERM_USER_WRITE
Definition: fxexdefs.h:265
@ FILEPERM_STICKY
Definition: fxexdefs.h:279
@ FILEPERM_ALL
Definition: fxexdefs.h:276
@ FILEPERM_EXEC
Definition: fxexdefs.h:275
@ FILEPERM_OTHER_READ
Definition: fxexdefs.h:270
@ FILEPERM_WRITE
Definition: fxexdefs.h:274
@ FILEPERM_DEFAULT_IO
Definition: fxexdefs.h:281
@ FILEPERM_SECURE_IO
Definition: fxexdefs.h:280
@ FILEPERM_SET_GID
Definition: fxexdefs.h:278
@ FILEPERM_SET_UID
Definition: fxexdefs.h:277
@ FILEPERM_DEFAULT_EXEC
Definition: fxexdefs.h:282
@ FILEPERM_GROUP_WRITE
Definition: fxexdefs.h:268
@ FILEPERM_USER_EXEC
Definition: fxexdefs.h:266