Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / parsim / cispeventlogger.h @ 81ad8b66

History | View | Annotate | Download (2.57 KB)

1
//=========================================================================
2
//  CISPEVENTLOGGER.H - part of
3
//
4
//                  OMNeT++/OMNEST
5
//           Discrete System Simulation in C++
6
//
7
//  Author: Andras Varga, 2003
8
//          Dept. of Electrical and Computer Systems Engineering,
9
//          Monash University, Melbourne, Australia
10
//
11
//=========================================================================
12

    
13
/*--------------------------------------------------------------*
14
  Copyright (C) 2003-2008 Andras Varga
15
  Copyright (C) 2006-2008 OpenSim Ltd.
16

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

    
21
#ifndef __CISPEVENTLOGGER_H__
22
#define __CISPEVENTLOGGER_H__
23

    
24
#include "cnullmessageprot.h"
25

    
26
NAMESPACE_BEGIN
27

    
28

    
29
/**
30
 * Implements phase one for the Ideal Simulation Protocol (ISP),
31
 * namely, creating the log of "external" events. That log will be
32
 * used as by the ISP synchromization mechanism (cIdealSimulationProtocol).
33
 *
34
 * This class simply executes the simulation under the Null Message
35
 * Algorithm, and additionally records all "external" events to a file.
36
 *
37
 * @ingroup Parsim
38
 */
39
class SIM_API cISPEventLogger : public cNullMessageProtocol
40
{
41
  protected:
42
    FILE *fout;  // the event log file (stores ExternalEvent's)
43

    
44
  protected:
45
    // Overridden to set message priority to sourceProcId. We do the same in
46
    // cIdealSimulationProtocol. This ensures that messages with equal
47
    // timestamps will get processed in the same order in both protocols,
48
    // whatever the concrete timing conditions.
49
    void processReceivedMessage(cMessage *msg, int destModuleId, int destGateId, int sourceProcId);
50

    
51
  public:
52
    /**
53
     * Constructor.
54
     */
55
    cISPEventLogger();
56

    
57
    /**
58
     * Destructor.
59
     */
60
    virtual ~cISPEventLogger();
61

    
62
    /**
63
     * Called at the beginning of a simulation run.
64
     * The addition to the base class is opening the file.
65
     */
66
    virtual void startRun();
67

    
68
    /**
69
     * Called at the end of a simulation run.
70
     * The addition to the base class is closing the file.
71
     */
72
    virtual void endRun();
73

    
74
    /**
75
     * Overridden to check that the model doesn't set message priority which
76
     * we need for our own purposes.
77
     */
78
    void processOutgoingMessage(cMessage *msg, int procId, int moduleId, int gateId, void *data);
79

    
80
    /**
81
     * Scheduler function. The addition to the base class is
82
     * recording the event to the file.
83
     */
84
    virtual cMessage *getNextEvent();
85
};
86

    
87
NAMESPACE_END
88

    
89

    
90
#endif
91