Statistics
| Branch: | Revision:

root / src / sim / onstartup.cc @ fbe00e73

History | View | Annotate | Download (1.26 KB)

1
//==========================================================================
2
//  ONSTARTUP.CC - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//
7
//  supporting class for EXECUTE_ON_STARTUP macro
8
//
9
//==========================================================================
10

    
11
/*--------------------------------------------------------------*
12
  Copyright (C) 1992-2008 Andras Varga
13
  Copyright (C) 2006-2008 OpenSim Ltd.
14

15
  This file is distributed WITHOUT ANY WARRANTY. See the file
16
  `license' for details on this and other legal matters.
17
*--------------------------------------------------------------*/
18

    
19

    
20
#include "onstartup.h"
21

    
22
USING_NAMESPACE
23

    
24

    
25
ExecuteOnStartup *ExecuteOnStartup::head;
26

    
27

    
28
ExecuteOnStartup::ExecuteOnStartup(void (*_code_to_exec)())
29
{
30
    code_to_exec = _code_to_exec;
31

    
32
    // add to list
33
    next = head;
34
    head = this;
35
}
36

    
37
ExecuteOnStartup::~ExecuteOnStartup()
38
{
39
}
40

    
41
void ExecuteOnStartup::execute()
42
{
43
    code_to_exec();
44
}
45

    
46
void ExecuteOnStartup::executeAll()
47
{
48
    ExecuteOnStartup *p = ExecuteOnStartup::head;
49
    while (p)
50
    {
51
        p->execute();
52
        p = p->next;
53
    }
54

    
55
    // null out list to prevent double execution on subsequent calls (e.g. after dll loading)
56
    ExecuteOnStartup::head = NULL;
57
}
58

    
59