OMNeT++ Simulation Library
5.6.1
regmacros.h
1
//==========================================================================
2
// REGMACROS.H - part of
3
// OMNeT++/OMNEST
4
// Discrete System Simulation in C++
5
//
6
//==========================================================================
7
8
/*--------------------------------------------------------------*
9
Copyright (C) 1992-2017 Andras Varga
10
Copyright (C) 2006-2017 OpenSim Ltd.
11
12
This file is distributed WITHOUT ANY WARRANTY. See the file
13
`license' for details on this and other legal matters.
14
*--------------------------------------------------------------*/
15
16
#ifndef __OMNETPP_REGMACROS_H
17
#define __OMNETPP_REGMACROS_H
18
19
#include "simkerneldefs.h"
20
21
namespace
omnetpp
{
22
25
39
#define Define_NED_Math_Function(NAME,ARGCOUNT) \
40
EXECUTE_ON_STARTUP(omnetpp::nedFunctions.getInstance()->add(new omnetpp::cNedMathFunction(#NAME,NAME,ARGCOUNT));)
41
49
#define Define_NED_Math_Function2(NAME,FUNCTION,ARGCOUNT) \
50
EXECUTE_ON_STARTUP(omnetpp::nedFunctions.getInstance()->add(new omnetpp::cNedMathFunction(#NAME,FUNCTION,ARGCOUNT));)
51
57
#define Define_NED_Math_Function3(NAME,ARGCOUNT,CATEGORY,DESCRIPTION) \
58
EXECUTE_ON_STARTUP(omnetpp::nedFunctions.getInstance()->add(new omnetpp::cNedMathFunction(#NAME,NAME,ARGCOUNT,CATEGORY,DESCRIPTION));)
59
65
#define Define_NED_Math_Function4(NAME,FUNCTION,ARGCOUNT,CATEGORY,DESCRIPTION) \
66
EXECUTE_ON_STARTUP(omnetpp::nedFunctions.getInstance()->add(new omnetpp::cNedMathFunction(#NAME,FUNCTION,ARGCOUNT,CATEGORY,DESCRIPTION));)
67
92
#define Define_NED_Function(FUNCTION,SIGNATURE) \
93
EXECUTE_ON_STARTUP(omnetpp::nedFunctions.getInstance()->add(new omnetpp::cNedFunction(FUNCTION,SIGNATURE));)
94
101
#define Define_NED_Function2(FUNCTION,SIGNATURE,CATEGORY,DESCRIPTION) \
102
EXECUTE_ON_STARTUP(omnetpp::nedFunctions.getInstance()->add(new omnetpp::cNedFunction(FUNCTION,SIGNATURE,CATEGORY,DESCRIPTION));)
103
113
#define Register_Class(CLASSNAME) __REGISTER_CLASS(CLASSNAME, omnetpp::cObject, "class")
114
124
#define Register_Abstract_Class(CLASSNAME) __REGISTER_ABSTRACT_CLASS(CLASSNAME, omnetpp::cObject, "class")
125
132
#define Define_Module(CLASSNAME) __REGISTER_CLASS(CLASSNAME, omnetpp::cModule, "module")
133
140
#define Define_Channel(CLASSNAME) __REGISTER_CLASS(CLASSNAME, omnetpp::cChannel, "channel")
141
142
// internal
143
#define __REGISTER_CLASS(CLASSNAME, BASECLASS, DESC) \
144
__REGISTER_CLASS_X(CLASSNAME, BASECLASS, DESC,
/*nothing*/
)
145
146
// internal
147
#define __REGISTER_CLASS_X(CLASSNAME, BASECLASS, DESC, EXTRACODE) \
148
static omnetpp::cObject *MAKE_UNIQUE_WITHIN_FILE(__factoryfunc_)() {BASECLASS *ret = new CLASSNAME; return ret; } \
149
static void *MAKE_UNIQUE_WITHIN_FILE(__castfunc_)(omnetpp::cObject *obj) {return (void*)dynamic_cast<CLASSNAME*>(obj);} \
150
EXECUTE_ON_STARTUP(omnetpp::classes.getInstance()->add(new omnetpp::cObjectFactory(omnetpp::opp_typename(typeid(CLASSNAME)), MAKE_UNIQUE_WITHIN_FILE(__factoryfunc_), MAKE_UNIQUE_WITHIN_FILE(__castfunc_), DESC)); EXTRACODE; )
151
152
// internal
153
#define __REGISTER_ABSTRACT_CLASS(CLASSNAME, BASECLASS
/*unused*/
, DESC) \
154
static void *MAKE_UNIQUE_WITHIN_FILE(__castfunc_)(omnetpp::cObject *obj) {return (void*)dynamic_cast<CLASSNAME*>(obj);} \
155
EXECUTE_ON_STARTUP(omnetpp::classes.getInstance()->add(new omnetpp::cObjectFactory(omnetpp::opp_typename(typeid(CLASSNAME)), nullptr, MAKE_UNIQUE_WITHIN_FILE(__castfunc_), DESC));)
156
162
#define Register_ClassDescriptor(DESCRIPTORCLASS) \
163
EXECUTE_ON_STARTUP(omnetpp::classDescriptors.getInstance()->add(new DESCRIPTORCLASS());)
164
165
// internal
166
#define __REGISTER_CONFIGOPTION(ID, ARGLIST) \
167
omnetpp::cConfigOption *ID; \
168
EXECUTE_ON_STARTUP(omnetpp::configOptions.getInstance()->add(ID = new omnetpp::cConfigOption ARGLIST);)
169
175
#define Register_GlobalConfigOption(ID, NAME, TYPE, DEFAULTVALUE, DESCRIPTION) \
176
__REGISTER_CONFIGOPTION(ID, (NAME, true, omnetpp::cConfigOption::TYPE, nullptr, DEFAULTVALUE, DESCRIPTION))
177
183
#define Register_PerRunConfigOption(ID, NAME, TYPE, DEFAULTVALUE, DESCRIPTION) \
184
__REGISTER_CONFIGOPTION(ID, (NAME, false, omnetpp::cConfigOption::TYPE, nullptr, DEFAULTVALUE, DESCRIPTION))
185
192
#define Register_GlobalConfigOptionU(ID, NAME, UNIT, DEFAULTVALUE, DESCRIPTION) \
193
__REGISTER_CONFIGOPTION(ID, (NAME, true, omnetpp::cConfigOption::CFG_DOUBLE, UNIT, DEFAULTVALUE, DESCRIPTION))
194
201
#define Register_PerRunConfigOptionU(ID, NAME, UNIT, DEFAULTVALUE, DESCRIPTION) \
202
__REGISTER_CONFIGOPTION(ID, (NAME, false, omnetpp::cConfigOption::CFG_DOUBLE, UNIT, DEFAULTVALUE, DESCRIPTION))
203
209
#define Register_PerObjectConfigOption(ID, NAME, KIND, TYPE, DEFAULTVALUE, DESCRIPTION) \
210
__REGISTER_CONFIGOPTION(ID, (NAME, omnetpp::cConfigOption::KIND, omnetpp::cConfigOption::TYPE, nullptr, DEFAULTVALUE, DESCRIPTION))
211
218
#define Register_PerObjectConfigOptionU(ID, NAME, KIND, UNIT, DEFAULTVALUE, DESCRIPTION) \
219
__REGISTER_CONFIGOPTION(ID, (NAME, omnetpp::cConfigOption::KIND, omnetpp::cConfigOption::CFG_DOUBLE, UNIT, DEFAULTVALUE, DESCRIPTION))
220
226
#define Register_MessagePrinter(CLASSNAME) \
227
EXECUTE_ON_STARTUP(omnetpp::messagePrinters.getInstance()->add(new CLASSNAME());)
228
244
#define Register_Enum(NAME, VALUES) \
245
EXECUTE_ON_STARTUP(omnetpp::enums.getInstance()->add((new omnetpp::cEnum(omnetpp::opp_typename(typeid(NAME))))->registerNames(#VALUES)->registerValues VALUES))
246
269
#define Register_Enum2(VAR, NAME, VALUES) \
270
static omnetpp::cEnum *VAR; \
271
EXECUTE_ON_STARTUP(VAR = new omnetpp::cEnum(NAME); VAR->bulkInsert VALUES; omnetpp::enums.getInstance()->add(VAR))
272
287
#define Register_Figure(NAME, CLASSNAME) \
288
__REGISTER_CLASS_X(CLASSNAME, omnetpp::cFigure, "figure", figureTypes[NAME] = omnetpp::opp_typename(typeid(CLASSNAME)))
289
291
292
}
// namespace omnetpp
293
294
295
#endif
296
omnetpp
Definition:
cabstracthistogram.h:21
include
omnetpp
regmacros.h
Generated on Fri Feb 7 2020 11:37:56 for OMNeT++ Simulation Library by
1.8.13