Statistics
| Branch: | Revision:

root / src / eventlog / ievent.h @ 77a045fa

History | View | Annotate | Download (4.62 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 long getComplexity() = 0;
87
        virtual int getModuleId() = 0;
88
        virtual long getMessageId() = 0;
89
        virtual eventnumber_t getCauseEventNumber() = 0;
90

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

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

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

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

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

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

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

    
144
NAMESPACE_END
145

    
146

    
147
#endif