regmacros.h

00001 //==========================================================================
00002 //  REGMACROS.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //==========================================================================
00007 
00008 /*--------------------------------------------------------------*
00009   Copyright (C) 1992-2008 Andras Varga
00010   Copyright (C) 2006-2008 OpenSim Ltd.
00011 
00012   This file is distributed WITHOUT ANY WARRANTY. See the file
00013   `license' for details on this and other legal matters.
00014 *--------------------------------------------------------------*/
00015 
00016 #ifndef __REGMACROS_H
00017 #define __REGMACROS_H
00018 
00019 #include "simkerneldefs.h"
00020 
00021 NAMESPACE_BEGIN
00022 
00028 
00042 #define Define_NED_Math_Function(NAME,ARGCOUNT) \
00043   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,NAME,ARGCOUNT));)
00044 
00052 #define Define_NED_Math_Function2(NAME,FUNCTION,ARGCOUNT) \
00053   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,FUNCTION,ARGCOUNT));)
00054 
00060 #define Define_NED_Math_Function3(NAME,ARGCOUNT,CATEGORY,DESCRIPTION) \
00061   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,NAME,ARGCOUNT,CATEGORY,DESCRIPTION));)
00062 
00068 #define Define_NED_Math_Function4(NAME,FUNCTION,ARGCOUNT,CATEGORY,DESCRIPTION) \
00069   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,FUNCTION,ARGCOUNT,CATEGORY,DESCRIPTION));)
00070 
00075 #define Define_Function(NAME,ARGCOUNT) \
00076   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,NAME,ARGCOUNT)); Define_Function_macro(); /*issues deprecation warning*/)
00077 
00082 #define Define_Function2(NAME,FUNCTION,ARGCOUNT) \
00083   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,FUNCTION,ARGCOUNT)); Define_Function_macro(); /*issues deprecation warning*/)
00084 
00089 #define Define_Function3(NAME,ARGCOUNT,CATEGORY,DESCRIPTION) \
00090   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,NAME,ARGCOUNT,CATEGORY,DESCRIPTION)); Define_Function_macro(); /*issues deprecation warning*/)
00091 
00096 #define Define_Function4(NAME,FUNCTION,ARGCOUNT,CATEGORY,DESCRIPTION) \
00097   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDMathFunction(#NAME,FUNCTION,ARGCOUNT,CATEGORY,DESCRIPTION)); Define_Function_macro(); /*issues deprecation warning*/)
00098 
00099 // only exists so that Define_FunctionX() macros issue a deprecation warning when used:
00100 _OPPDEPRECATED inline void Define_Function_macro() {}
00101 
00126 #define Define_NED_Function(FUNCTION,SIGNATURE) \
00127   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDFunction(FUNCTION,SIGNATURE));)
00128 
00135 #define Define_NED_Function2(FUNCTION,SIGNATURE,CATEGORY,DESCRIPTION) \
00136   EXECUTE_ON_STARTUP(nedFunctions.getInstance()->add(new cNEDFunction(FUNCTION,SIGNATURE,CATEGORY,DESCRIPTION));)
00137 
00147 #define Register_Class(CLASSNAME)  __REGISTER_CLASS(CLASSNAME, cObject, "class")
00148 
00158 #define Register_Abstract_Class(CLASSNAME)  __REGISTER_ABSTRACT_CLASS(CLASSNAME, cObject, "class")
00159 
00166 #define Define_Module(CLASSNAME)  __REGISTER_CLASS(CLASSNAME, cModule, "module")
00167 
00174 #define Define_Channel(CLASSNAME)  __REGISTER_CLASS(CLASSNAME, cChannel, "channel")
00175 
00176 // internal
00177 #define __REGISTER_CLASS(CLASSNAME, BASECLASS, DESC) \
00178   static cObject *MAKE_UNIQUE_WITHIN_FILE(__factoryfunc_)() {BASECLASS *ret = new CLASSNAME; return ret; } \
00179   static void *MAKE_UNIQUE_WITHIN_FILE(__castfunc_)(cObject *obj) {return (void*)dynamic_cast<CLASSNAME*>(obj);} \
00180   EXECUTE_ON_STARTUP(classes.getInstance()->add(new cObjectFactory(opp_typename(typeid(CLASSNAME)), MAKE_UNIQUE_WITHIN_FILE(__factoryfunc_), MAKE_UNIQUE_WITHIN_FILE(__castfunc_), DESC));)
00181 
00182 // internal
00183 #define __REGISTER_ABSTRACT_CLASS(CLASSNAME, BASECLASS /*unused*/, DESC) \
00184   static void *MAKE_UNIQUE_WITHIN_FILE(__castfunc_)(cObject *obj) {return (void*)dynamic_cast<CLASSNAME*>(obj);} \
00185   EXECUTE_ON_STARTUP(classes.getInstance()->add(new cObjectFactory(opp_typename(typeid(CLASSNAME)), NULL, MAKE_UNIQUE_WITHIN_FILE(__castfunc_), DESC));)
00186 
00192 #define Register_ClassDescriptor(DESCRIPTORCLASS) \
00193   EXECUTE_ON_STARTUP(classDescriptors.getInstance()->add(new DESCRIPTORCLASS());)
00194 
00212 #define Module_Class_Members(CLASSNAME,BASECLASS,STACK)  NOTE_the_deprecated_Module_Class_Members_macro_has_been_removed_in_version_4_0
00213 
00214 // internal
00215 #define __REGISTER_CONFIGOPTION(ID, ARGLIST) \
00216   cConfigOption *ID; \
00217   EXECUTE_ON_STARTUP(configOptions.getInstance()->add(ID = new cConfigOption ARGLIST);)
00218 
00224 #define Register_GlobalConfigOption(ID, NAME, TYPE, DEFAULTVALUE, DESCRIPTION) \
00225   __REGISTER_CONFIGOPTION(ID, (NAME, true, cConfigOption::TYPE, NULL, DEFAULTVALUE, DESCRIPTION))
00226 
00232 #define Register_PerRunConfigOption(ID, NAME, TYPE, DEFAULTVALUE, DESCRIPTION) \
00233   __REGISTER_CONFIGOPTION(ID, (NAME, false, cConfigOption::TYPE, NULL, DEFAULTVALUE, DESCRIPTION))
00234 
00241 #define Register_GlobalConfigOptionU(ID, NAME, UNIT, DEFAULTVALUE, DESCRIPTION) \
00242   __REGISTER_CONFIGOPTION(ID, (NAME, true, cConfigOption::CFG_DOUBLE, UNIT, DEFAULTVALUE, DESCRIPTION))
00243 
00250 #define Register_PerRunConfigOptionU(ID, NAME, UNIT, DEFAULTVALUE, DESCRIPTION) \
00251   __REGISTER_CONFIGOPTION(ID, (NAME, false, cConfigOption::CFG_DOUBLE, UNIT, DEFAULTVALUE, DESCRIPTION))
00252 
00258 #define Register_PerObjectConfigOption(ID, NAME, KIND, TYPE, DEFAULTVALUE, DESCRIPTION) \
00259   __REGISTER_CONFIGOPTION(ID, (NAME, cConfigOption::KIND, cConfigOption::TYPE, NULL, DEFAULTVALUE, DESCRIPTION))
00260 
00267 #define Register_PerObjectConfigOptionU(ID, NAME, KIND, UNIT, DEFAULTVALUE, DESCRIPTION) \
00268   __REGISTER_CONFIGOPTION(ID, (NAME, cConfigOption::KIND, cConfigOption::CFG_DOUBLE, UNIT, DEFAULTVALUE, DESCRIPTION))
00269 
00275 #define Register_MessagePrinter(CLASSNAME) \
00276   EXECUTE_ON_STARTUP(messagePrinters.getInstance()->add(new CLASSNAME());)
00277 
00279 
00280 NAMESPACE_END
00281 
00282 
00283 #endif
00284 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3