Statistics
| Branch: | Revision:

root / src / eventlog / ievent.h @ 0596ce67

History | View | Annotate | Download (5.23 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* criticalPredecessor;
34

    
35
    public:
36
        // gui state for SequenceChart
37
        double cachedTimelineCoordinate;
38
        long cachedTimelineCoordinateSystemVersion;
39

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

    
42

    
43

    
44
    public:
45
        IEvent();
46
        virtual ~IEvent() {}
47

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

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

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

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

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

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

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

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

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

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

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

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

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

    
151
        virtual long getEarliestProcessingTime() = 0;
152
        virtual long getEarliestStartTime() = 0;
153

    
154
        IEvent* getCriticalPredecessor() {
155
            return criticalPredecessor;
156
        }
157

    
158
        void setCriticalPredecessor(IEvent* e) {
159
            criticalPredecessor = e;
160
        }
161
};
162

    
163
NAMESPACE_END
164

    
165

    
166
#endif