Statistics
| Branch: | Revision:

root / src / eventlog / ievent.h @ 2f5cc443

History | View | Annotate | Download (4.58 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
    public:
39
        IEvent();
40
        virtual ~IEvent() {}
41

    
42
        /**
43
         * Synchorizes state when the underlying log file changes (new events are appended).
44
         */
45
        virtual void synchronize() = 0;
46

    
47
        /**
48
         * Returns the corresponding event log.
49
         */
50
        virtual IEventLog *getEventLog() = 0;
51

    
52
        /**
53
         * Returns the begin offset of the event in the log file.
54
         */
55
        virtual file_offset_t getBeginOffset() = 0;
56
        /**
57
         * Returns the end offset of the event in the log file.
58
         */
59
        virtual file_offset_t getEndOffset() = 0;
60

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

    
78
        // simple text lines
79
        virtual int getNumEventLogMessages() = 0;
80
        virtual int getNumBeginSendEntries() = 0;
81
        virtual EventLogMessageEntry *getEventLogMessage(int index) = 0;
82

    
83
        // some of the data found in the 'E' entry (line), to get additional data query the entries
84
        virtual eventnumber_t getEventNumber() = 0;
85
        virtual simtime_t getSimulationTime() = 0;
86
        virtual int getModuleId() = 0;
87
        virtual long getMessageId() = 0;
88
        virtual eventnumber_t getCauseEventNumber() = 0;
89

    
90
        /**
91
         * Returns the immediately preceding event or NULL if there is no such event.
92
         */
93
        virtual IEvent *getPreviousEvent() = 0;
94
        /**
95
         * Returns the immediately following event or NULL if there is no such event.
96
         */
97
        virtual IEvent *getNextEvent() = 0;
98

    
99
        /**
100
         * Returns the closest preceding event which caused this event by sending a message.
101
         */
102
        virtual IEvent *getCauseEvent() = 0;
103
        virtual BeginSendEntry *getCauseBeginSendEntry() = 0;
104
        virtual IMessageDependency *getCause() = 0;
105
        virtual IMessageDependencyList *getCauses() = 0;
106
        virtual IMessageDependencyList *getConsequences() = 0;
107

    
108
        /**
109
         * Print all entries of this event.
110
         */
111
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
112

    
113
        /**
114
         * Returns the log entry which describes the event's module.
115
         */
116
        virtual ModuleCreatedEntry *getModuleCreatedEntry() = 0;
117

    
118
        /**
119
         * Returns the index of the begin send entry where the given message was sent.
120
         */
121
        virtual int findBeginSendEntryIndex(int messageId);
122

    
123
        /**
124
         * Returns true if the sent message is a self message.
125
         */
126
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry) = 0;
127
        /**
128
         * Returns true if the received message was a self message.
129
         */
130
        virtual bool isSelfMessageProcessingEvent() = 0;
131
        /**
132
         * Retuns the corresponding end send or NULL if the message got deleted.
133
         */
134
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry) = 0;
135

    
136
        /**
137
         * Used to maintain the double linked list.
138
         */
139
        static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
140
        static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
141
};
142

    
143
NAMESPACE_END
144

    
145

    
146
#endif