OMNeT++ Simulation Library
6.0.3
onstartup.h
1
//==========================================================================
2
// ONSTARTUP.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_ONSTARTUP_H
17
#define __OMNETPP_ONSTARTUP_H
18
19
#include <vector>
20
#include <map>
21
#include "simkerneldefs.h"
22
#include "cownedobject.h"
23
24
namespace
omnetpp {
25
26
27
// Generating identifiers unique for this file. See MSVC Help for __COUNTER__ for more info.
28
#define __OPPCONCAT1(x,y) x##y
29
#define __OPPCONCAT2(prefix,line) __OPPCONCAT1(prefix,line)
30
#define MAKE_UNIQUE_WITHIN_FILE(prefix) __OPPCONCAT2(prefix,__LINE__)
31
32
// helpers for EXECUTE_ON_STARTUP
33
// IMPORTANT: if you change "__onstartup_func_" below, linkall.pl must also be updated!
34
#define __ONSTARTUP_FUNC MAKE_UNIQUE_WITHIN_FILE(__onstartup_func_)
35
#define __ONSTARTUP_OBJ MAKE_UNIQUE_WITHIN_FILE(__onstartup_obj_)
36
37
// helper
38
#define __FILEUNIQUENAME__ MAKE_UNIQUE_WITHIN_FILE(__uniquename_)
39
40
// magic number for identifying a release build.
41
#define RELEASE_OPPSIM_MAGIC_NUMBER 0x12345678
42
52
#define EXECUTE_ON_STARTUP(CODE) \
53
namespace { \
54
void __ONSTARTUP_FUNC() {CODE;} \
55
static omnetpp::CodeFragments __ONSTARTUP_OBJ(__ONSTARTUP_FUNC, omnetpp::CodeFragments::STARTUP); \
56
}
57
66
//NOTE: implementation reuses some of the *startup* macros
67
#define EXECUTE_ON_SHUTDOWN(CODE) \
68
namespace { \
69
void __ONSTARTUP_FUNC() {CODE;} \
70
static omnetpp::CodeFragments __ONSTARTUP_OBJ(__ONSTARTUP_FUNC, omnetpp::CodeFragments::SHUTDOWN); \
71
}
72
78
class
SIM_API
CodeFragments
79
{
80
public
:
81
enum
Type {STARTUP, SHUTDOWN};
82
private
:
83
Type type;
84
void (*code)();
85
CodeFragments
*next;
86
static
CodeFragments
*head;
87
public
:
88
CodeFragments
(
void
(*code)(), Type type);
89
~
CodeFragments
() {}
90
static
void
executeAll(Type type);
91
};
92
93
}
// namespace omnetpp
94
95
96
#endif
97
omnetpp::CodeFragments
Supporting class for the EXECUTE_ON_STARTUP and EXECUTE_ON_SHUTDOWN macros.
Definition:
onstartup.h:78
include
omnetpp
onstartup.h
Generated on Tue Jan 30 2024 20:11:35 for OMNeT++ Simulation Library by
1.8.17