Statistics
| Branch: | Revision:

root / src / eventlog / ievent.h @ e1750c09

History | View | Annotate | Download (5.86 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
        IEvent *previousEventRealTime;
34
        IEvent *nextEventRealTime;
35

    
36
        IEvent* criticalPredecessor;
37

    
38
    public:
39
        // gui state for SequenceChart
40
        double cachedTimelineCoordinate;
41
        long cachedTimelineCoordinateSystemVersion;
42

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

    
45

    
46

    
47
    public:
48
        IEvent();
49
        virtual ~IEvent() {}
50

    
51
        /**
52
         * Synchorizes state when the underlying log file changes (new events are appended).
53
         */
54
        virtual void synchronize() = 0;
55

    
56
        /**
57
         * Returns the corresponding event log.
58
         */
59
        virtual IEventLog *getEventLog() = 0;
60

    
61
        /**
62
         * Returns the begin offset of the event in the log file.
63
         */
64
        virtual file_offset_t getBeginOffset() = 0;
65
        /**
66
         * Returns the end offset of the event in the log file.
67
         */
68
        virtual file_offset_t getEndOffset() = 0;
69

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

    
87
        // simple text lines
88
        virtual int getNumEventLogMessages() = 0;
89
        virtual int getNumBeginSendEntries() = 0;
90
        virtual EventLogMessageEntry *getEventLogMessage(int index) = 0;
91

    
92
        // some of the data found in the 'E' entry (line), to get additional data query the entries
93
        virtual eventnumber_t getEventNumber() = 0;
94
        virtual simtime_t getSimulationTime() = 0;
95
        virtual long getComplexity() = 0;
96
        virtual int getModuleId() = 0;
97
        virtual long getMessageId() = 0;
98
        virtual eventnumber_t getCauseEventNumber() = 0;
99

    
100
        /**
101
         * Returns the immediately preceding event or NULL if there is no such event.
102
         */
103
        virtual IEvent *getPreviousEvent() = 0;
104
        /**
105
         * Returns the immediately following event or NULL if there is no such event.
106
         */
107
        virtual IEvent *getNextEvent() = 0;
108

    
109
        /**
110
         * Returns the immediately preceding event in RealTime or NULL if there is no such event.
111
         */
112
        virtual IEvent *getPreviousEventRealTime() = 0;
113
        /**
114
         * Returns the immediately following event in RealTime or NULL if there is no such event.
115
         */
116
        virtual IEvent *getNextEventRealTime() = 0;
117

    
118
        virtual void setNextEventRealTime(IEvent* e) {
119
            nextEventRealTime = e;
120
        }
121

    
122
        virtual void setPreviousEventRealTime(IEvent* e) {
123
            previousEventRealTime = e;
124
        }
125

    
126
        /**
127
         * Returns the closest preceding event which caused this event by sending a message.
128
         */
129
        virtual IEvent *getCauseEvent() = 0;
130
        virtual BeginSendEntry *getCauseBeginSendEntry() = 0;
131
        virtual IMessageDependency *getCause() = 0;
132
        virtual IMessageDependencyList *getCauses() = 0;
133
        virtual IMessageDependencyList *getConsequences() = 0;
134

    
135
        /**  public int getEarliestProcessingTime() {
136
    return EventLogEngineJNI.IEvent_earliestProcessingTime_get(swigCPtr, this);
137
  }
138
         * Print all entries of this event.
139
         */
140
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
141

    
142
        /**
143
         * Returns the log entry which describes the event's module.
144
         */
145
        virtual ModuleCreatedEntry *getModuleCreatedEntry() = 0;
146

    
147
        /**
148
         * Returns the index of the begin send entry where the given message was sent.
149
         */
150
        virtual int findBeginSendEntryIndex(int messageId);
151

    
152
        /**
153
         * Returns true if the sent message is a self message.
154
         */
155
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry) = 0;
156
        /**
157
         * Returns true if the received message was a self message.
158
         */
159
        virtual bool isSelfMessageProcessingEvent() = 0;
160
        /**
161
         * Retuns the corresponding end send or NULL if the message got deleted.
162
         */
163
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry) = 0;
164

    
165
        /**
166
         * Used to maintain the double linked list.
167
         */
168
        static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
169
        static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
170

    
171
        virtual long getEarliestProcessingTime() = 0;
172
        virtual long getEarliestStartTime() = 0;
173

    
174
        IEvent* getCriticalPredecessor() {
175
            return criticalPredecessor;
176
        }
177

    
178
        void setCriticalPredecessor(IEvent* e) {
179
            criticalPredecessor = e;
180
        }
181
};
182

    
183
NAMESPACE_END
184

    
185

    
186
#endif