Statistics
| Branch: | Revision:

root / src / eventlog / ievent.h @ bcffd494

History | View | Annotate | Download (5.01 KB)

1
//=========================================================================
2
//  IEVENT.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Levente Meszaros
7
//
8
//=========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

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

    
17
#ifndef __IEVENT_H_
18
#define __IEVENT_H_
19

    
20
#include <sstream>
21
#include "eventlogentry.h"
22
#include "eventlogentries.h"
23
#include "messagedependency.h"
24

    
25
NAMESPACE_BEGIN
26

    
27
class EVENTLOG_API IEvent
28
{
29
    protected:
30
        IEvent *previousEvent;
31
        IEvent *nextEvent;
32

    
33
    public:
34
        // gui state for SequenceChart
35
        double cachedTimelineCoordinate;
36
        long cachedTimelineCoordinateSystemVersion;
37

    
38
        long _earliestProcessingTime; //The earliest time the event can be finished, as defined in "A Critical Path Tool for Parallel Simulation Performance Optimization"
39

    
40

    
41

    
42
    public:
43
        IEvent();
44
        virtual ~IEvent() {}
45

    
46
        /**
47
         * Synchorizes state when the underlying log file changes (new events are appended).
48
         */
49
        virtual void synchronize() = 0;
50

    
51
        /**
52
         * Returns the corresponding event log.
53
         */
54
        virtual IEventLog *getEventLog() = 0;
55

    
56
        /**
57
         * Returns the begin offset of the event in the log file.
58
         */
59
        virtual file_offset_t getBeginOffset() = 0;
60
        /**
61
         * Returns the end offset of the event in the log file.
62
         */
63
        virtual file_offset_t getEndOffset() = 0;
64

    
65
        /**
66
         * Returns the 'E' entry (line) corresponding to this event.
67
         */
68
        virtual EventEntry *getEventEntry() = 0;
69
        /**
70
         * Returns the 'EE' entry (line) corresponding to this event.
71
         */
72
        virtual EventEndEntry *getEventEndEntry() = 0;
73
        /**
74
         * Returns the number of log file entries (lines) for this event.
75
         */
76
        virtual int getNumEventLogEntries() = 0;
77
        /**
78
         * Returns the nth entry (line) for this event.
79
         */
80
        virtual EventLogEntry *getEventLogEntry(int index) = 0;
81

    
82
        // simple text lines
83
        virtual int getNumEventLogMessages() = 0;
84
        virtual int getNumBeginSendEntries() = 0;
85
        virtual EventLogMessageEntry *getEventLogMessage(int index) = 0;
86

    
87
        // some of the data found in the 'E' entry (line), to get additional data query the entries
88
        virtual eventnumber_t getEventNumber() = 0;
89
        virtual simtime_t getSimulationTime() = 0;
90
        virtual long getComplexity() = 0;
91
        virtual int getModuleId() = 0;
92
        virtual long getMessageId() = 0;
93
        virtual eventnumber_t getCauseEventNumber() = 0;
94

    
95
        /**
96
         * Returns the immediately preceding event or NULL if there is no such event.
97
         */
98
        virtual IEvent *getPreviousEvent() = 0;
99
        /**
100
         * Returns the immediately following event or NULL if there is no such event.
101
         */
102
        virtual IEvent *getNextEvent() = 0;
103

    
104
        /**
105
         * Returns the closest preceding event which caused this event by sending a message.
106
         */
107
        virtual IEvent *getCauseEvent() = 0;
108
        virtual BeginSendEntry *getCauseBeginSendEntry() = 0;
109
        virtual IMessageDependency *getCause() = 0;
110
        virtual IMessageDependencyList *getCauses() = 0;
111
        virtual IMessageDependencyList *getConsequences() = 0;
112

    
113
        /**  public int getEarliestProcessingTime() {
114
    return EventLogEngineJNI.IEvent_earliestProcessingTime_get(swigCPtr, this);
115
  }
116
         * Print all entries of this event.
117
         */
118
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
119

    
120
        /**
121
         * Returns the log entry which describes the event's module.
122
         */
123
        virtual ModuleCreatedEntry *getModuleCreatedEntry() = 0;
124

    
125
        /**
126
         * Returns the index of the begin send entry where the given message was sent.
127
         */
128
        virtual int findBeginSendEntryIndex(int messageId);
129

    
130
        /**
131
         * Returns true if the sent message is a self message.
132
         */
133
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry) = 0;
134
        /**
135
         * Returns true if the received message was a self message.
136
         */
137
        virtual bool isSelfMessageProcessingEvent() = 0;
138
        /**
139
         * Retuns the corresponding end send or NULL if the message got deleted.
140
         */
141
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry) = 0;
142

    
143
        /**
144
         * Used to maintain the double linked list.
145
         */
146
        static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
147
        static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
148

    
149
        virtual long getEarliestProcessingTime() = 0;
150
        virtual long getEarliestStartTime() = 0;
151
};
152

    
153
NAMESPACE_END
154

    
155

    
156
#endif