00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __MACROS_H
00026 #define __MACROS_H
00027
00028 #include "ctypes.h"
00029
00030
00031
00037
00047 #define Define_Network(NAME,SETUPFUNC) \
00048 void SETUPFUNC(); \
00049 static cNetworkType NAME##__network(#NAME,SETUPFUNC);
00050
00058 #define Define_Link(NAME,DELAY,ERROR,DATARATE) \
00059 static cLinkType NAME##__link(#NAME, DELAY, ERROR, DATARATE);
00060
00071 #define Define_Function(FUNCTION,ARGCOUNT) \
00072 cFunctionType FUNCTION##__functype(#FUNCTION,(MathFunc)FUNCTION,ARGCOUNT);
00073
00080 #define Register_Class(CLASSNAME) \
00081 void *CLASSNAME##__create() {return new CLASSNAME;} \
00082 cClassRegister CLASSNAME##__reg(#CLASSNAME,CLASSNAME##__create);
00083
00090 #define Register_InspectorFactory(FACTORYNAME,FUNCTION) \
00091 TInspector *FUNCTION(cObject *, int, void *); \
00092 cInspectorFactory FACTORYNAME##__inspfct(#FACTORYNAME,FUNCTION);
00093
00094
00095
00096
00102
00114 #define Define_Module(CLASSNAME) \
00115 static cModule *CLASSNAME##__create(const char *name, cModule *parentmod ) \
00116 { \
00117 return (cModule *) new CLASSNAME(name, parentmod); \
00118 } \
00119 cModuleType CLASSNAME##__type(#CLASSNAME,#CLASSNAME,(ModuleCreateFunc)CLASSNAME##__create);
00120
00128 #define Define_Module_Like(CLASSNAME,INTERFACE) \
00129 static cModule *CLASSNAME##__create(const char *name, cModule *parentmod ) \
00130 { \
00131 return (cModule *) new CLASSNAME(name, parentmod); \
00132 } \
00133 cModuleType CLASSNAME##__type(#CLASSNAME,#INTERFACE,(ModuleCreateFunc)CLASSNAME##__create);
00134
00155 #define Module_Class_Members(CLASSNAME,BASECLASS,STACK) \
00156 public: \
00157 CLASSNAME(const char *name, cModule *parentmod, unsigned stk=STACK) : \
00158 BASECLASS(name, parentmod, stk) {} \
00159 virtual const char *className() const {return #CLASSNAME;}
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 #define Interface(CLASSNAME) static sDescrItem CLASSNAME##__descr[] = {
00173 #define Gate(NAME,TYPE) {'G', #NAME, NULL, TYPE},
00174 #define Parameter(NAME,TYPES) {'P', #NAME, TYPES, 0 },
00175 #define Machine(NAME) {'M', #NAME, NULL, 0 },
00176 #define EndInterface {'E', NULL, NULL, 0 }};
00177
00178
00179 #define Register_Interface(CLASSNAME) \
00180 static cModuleInterface CLASSNAME##__interface( #CLASSNAME, CLASSNAME##__descr);
00181
00182
00183 #define GateDir_Input 'I'
00184 #define GateDir_Output 'O'
00185
00186
00187 #define ParType_Const "#"
00188 #define ParType_Any "*"
00189 #define ParType_Numeric "LDXFT"
00190 #define ParType_Bool "B"
00191 #define ParType_String "S"
00192
00193 #endif
00194