Statistics
| Branch: | Revision:

root / src / eventlog / event.h @ master

History | View | Annotate | Download (4.82 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  EVENT.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 __EVENT_H_
18
#define __EVENT_H_
19
20
#include <sstream>
21
#include <algorithm>
22
#include <vector>
23
#include "ievent.h"
24
#include "filereader.h"
25
#include "eventlogentry.h"
26
#include "eventlogentries.h"
27
#include "messagedependency.h"
28
29
NAMESPACE_BEGIN
30
31
class EventLog;
32
33
/**
34
 * Manages all event log entries for a single event. (All lines belonging to an "E" line.)
35
 * Returned Event*, EventLogEntry*, EventEntry*, MessageSend*, IMessageDependencyList* pointers should not be
36
 * remembered by callers, because they may get deleted when the event is
37
 * thrown out of the eventlog cache.
38
 */
39
class EVENTLOG_API Event : public IEvent
40
{
41
    protected:
42
        EventLog *eventLog; // the corresponding event log
43
        file_offset_t beginOffset; // file offset where the event starts
44
        file_offset_t endOffset; // file offset where the event ends (ie. begin of next event)
45
        EventEntry *eventEntry; // the event log entry that corresponds to the actual event ("E" line)
46 2f5cc443 Simon Tenbusch
        EventEndEntry* eventEndEntry; //the event end entry that stores the measured complexity
47 01873262 Georg Kunz
        ModuleCreatedEntry *moduleCreatedEntry;
48
        int numEventLogMessages;
49
        int numBeginSendEntries;
50
51
        typedef std::vector<EventLogEntry *> EventLogEntryList;
52
        EventLogEntryList eventLogEntries; // all entries parsed from the file (lines below "E" line)
53
54
        /**
55
         * A is a cause of B if and only if B is a consequence of A.
56
         */
57
        MessageDependency *cause; // the message send which is processed in this event
58
        IMessageDependencyList *causes; // the arrival message sends of messages which we send in this event
59
        IMessageDependencyList *consequences; // message sends in this event
60
61
    public:
62 a3b7e786 Simon Tenbusch
63 01873262 Georg Kunz
        Event(EventLog *eventLog);
64
        ~Event();
65
66
        /**
67
         * Parse an event starting at the given offset.
68
         */
69
        file_offset_t parse(FileReader *reader, file_offset_t offset);
70
71
        // IEvent interface
72
        virtual void synchronize();
73
        virtual IEventLog *getEventLog();
74
75
        virtual ModuleCreatedEntry *getModuleCreatedEntry();
76
77
        virtual file_offset_t getBeginOffset() { return beginOffset; }
78
        virtual file_offset_t getEndOffset() { return endOffset; }
79
80
        virtual EventEntry *getEventEntry() { return eventEntry; }
81 2f5cc443 Simon Tenbusch
        virtual EventEndEntry *getEventEndEntry() { return eventEndEntry; }
82 01873262 Georg Kunz
        virtual int getNumEventLogEntries() { return eventLogEntries.size(); }
83
        virtual EventLogEntry *getEventLogEntry(int index) { return eventLogEntries[index]; }
84
85
        virtual int getNumEventLogMessages() { return numEventLogMessages; }
86
        virtual int getNumBeginSendEntries() { return numBeginSendEntries; }
87
        virtual EventLogMessageEntry *getEventLogMessage(int index);
88
89
        virtual eventnumber_t getEventNumber() { return eventEntry->eventNumber; }
90
        virtual simtime_t getSimulationTime() { return eventEntry->simulationTime; }
91 7c7d95e5 Simon Tenbusch
        virtual long getComplexity() { return !eventEndEntry ? 0 : eventEndEntry->complexity; }
92 01873262 Georg Kunz
        virtual int getModuleId() { return eventEntry->moduleId; }
93
        virtual long getMessageId() { return eventEntry->messageId; }
94
        virtual eventnumber_t getCauseEventNumber() { return eventEntry->causeEventNumber; }
95
96
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry);
97
        virtual bool isSelfMessageProcessingEvent();
98
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry);
99
        simtime_t getTransmissionDelay(BeginSendEntry *beginSendEntry);
100
        virtual Event *getPreviousEvent();
101
        virtual Event *getNextEvent();
102
103 12288d0e Simon Tenbusch
        virtual Event *getPreviousEventRealTime();
104
        virtual Event *getNextEventRealTime();
105
106 01873262 Georg Kunz
        virtual Event *getCauseEvent();
107
        virtual BeginSendEntry *getCauseBeginSendEntry();
108
        virtual MessageDependency *getCause();
109
        virtual IMessageDependencyList *getCauses();
110
        virtual IMessageDependencyList *getConsequences();
111
112
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true);
113
114 bcffd494 Simon Tenbusch
        virtual long getEarliestProcessingTime();
115
        virtual long getEarliestStartTime();
116
117
118 01873262 Georg Kunz
    protected:
119
        void deleteAllocatedObjects();
120
        void clearInternalState();
121
        Event *getReuserEvent(int &beginSendEntryNumber);
122
};
123
124
NAMESPACE_END
125
126
127
#endif