Statistics
| Branch: | Revision:

root / src / eventlog / ievent.h @ 842775ab

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(FileReader::FileChangedState change);
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 number of log file entries (lines) for this event.
67
         */
68
        virtual int getNumEventLogEntries() = 0;
69
        /**
70
         * Returns the nth entry (line) for this event.
71
         */
72
        virtual EventLogEntry *getEventLogEntry(int index) = 0;
73

    
74
        // simple text lines
75
        virtual int getNumEventLogMessages() = 0;
76
        virtual int getNumBeginSendEntries() = 0;
77
        virtual EventLogMessageEntry *getEventLogMessage(int index) = 0;
78

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

    
86
        /**
87
         * Returns the immediately preceding event or NULL if there is no such event.
88
         */
89
        virtual IEvent *getPreviousEvent() = 0;
90
        /**
91
         * Returns the immediately following event or NULL if there is no such event.
92
         */
93
        virtual IEvent *getNextEvent() = 0;
94

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

    
104
        /**
105
         * Print all entries of this event.
106
         */
107
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
108

    
109
        /**
110
         * Returns the log entry which describes the event's module.
111
         */
112
        virtual ModuleCreatedEntry *getModuleCreatedEntry() = 0;
113

    
114
        /**
115
         * Returns the index of the begin send entry where the given message was sent.
116
         */
117
        virtual int findBeginSendEntryIndex(int messageId);
118

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

    
132
        /**
133
         * Used to maintain the double linked list.
134
         */
135
        static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
136
        static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
137
        static void unlinkNeighbourEvents(IEvent *nextEvent);
138

    
139
    protected:
140
        void clearInternalState();
141
};
142

    
143
NAMESPACE_END
144

    
145

    
146
#endif