Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (4.62 KB)

1
//=========================================================================
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
        EventEndEntry* eventEndEntry; //the event end entry that stores the measured complexity
47
        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
        Event(EventLog *eventLog);
63
        ~Event();
64

    
65
        /**
66
         * Parse an event starting at the given offset.
67
         */
68
        file_offset_t parse(FileReader *reader, file_offset_t offset);
69

    
70
        // IEvent interface
71
        virtual void synchronize();
72
        virtual IEventLog *getEventLog();
73

    
74
        virtual ModuleCreatedEntry *getModuleCreatedEntry();
75

    
76
        virtual file_offset_t getBeginOffset() { return beginOffset; }
77
        virtual file_offset_t getEndOffset() { return endOffset; }
78

    
79
        virtual EventEntry *getEventEntry() { return eventEntry; }
80
        virtual EventEndEntry *getEventEndEntry() { return eventEndEntry; }
81
        virtual int getNumEventLogEntries() { return eventLogEntries.size(); }
82
        virtual EventLogEntry *getEventLogEntry(int index) { return eventLogEntries[index]; }
83

    
84
        virtual int getNumEventLogMessages() { return numEventLogMessages; }
85
        virtual int getNumBeginSendEntries() { return numBeginSendEntries; }
86
        virtual EventLogMessageEntry *getEventLogMessage(int index);
87

    
88
        virtual eventnumber_t getEventNumber() { return eventEntry->eventNumber; }
89
        virtual simtime_t getSimulationTime() { return eventEntry->simulationTime; }
90
        virtual long getComplexity() { return !eventEndEntry ? 1 : eventEndEntry->complexity; }
91
        virtual int getModuleId() { return eventEntry->moduleId; }
92
        virtual long getMessageId() { return eventEntry->messageId; }
93
        virtual eventnumber_t getCauseEventNumber() { return eventEntry->causeEventNumber; }
94

    
95
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry);
96
        virtual bool isSelfMessageProcessingEvent();
97
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry);
98
        simtime_t getTransmissionDelay(BeginSendEntry *beginSendEntry);
99
        virtual Event *getPreviousEvent();
100
        virtual Event *getNextEvent();
101

    
102
        virtual Event *getCauseEvent();
103
        virtual BeginSendEntry *getCauseBeginSendEntry();
104
        virtual MessageDependency *getCause();
105
        virtual IMessageDependencyList *getCauses();
106
        virtual IMessageDependencyList *getConsequences();
107

    
108
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true);
109

    
110
    protected:
111
        void deleteAllocatedObjects();
112
        void clearInternalState();
113
        Event *getReuserEvent(int &beginSendEntryNumber);
114
};
115

    
116
NAMESPACE_END
117

    
118

    
119
#endif