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