Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (4.39 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
        ModuleCreatedEntry *moduleCreatedEntry;
47
        int numEventLogMessages;
48
        int numBeginSendEntries;
49

    
50
        typedef std::vector<EventLogEntry *> EventLogEntryList;
51
        EventLogEntryList eventLogEntries; // all entries parsed from the file (lines below "E" line)
52

    
53
        /**
54
         * A is a cause of B if and only if B is a consequence of A.
55
         */
56
        MessageSendDependency *cause; // the message send which is processed in this event
57
        IMessageDependencyList *causes; // the arrival message sends of messages which we send in this event
58
        IMessageDependencyList *consequences; // message sends in this event
59

    
60
    public:
61
        Event(EventLog *eventLog);
62
        virtual ~Event();
63

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

    
69
        // IEvent interface
70
        virtual void synchronize(FileReader::FileChangedState change);
71
        virtual IEventLog *getEventLog();
72

    
73
        virtual ModuleCreatedEntry *getModuleCreatedEntry();
74

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

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

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

    
86
        virtual eventnumber_t getEventNumber() { return eventEntry->eventNumber; }
87
        virtual simtime_t getSimulationTime() { return eventEntry->simulationTime; }
88
        virtual int getModuleId() { return eventEntry->moduleId; }
89
        virtual long getMessageId() { return eventEntry->messageId; }
90
        virtual eventnumber_t getCauseEventNumber() { return eventEntry->causeEventNumber; }
91

    
92
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry);
93
        virtual bool isSelfMessageProcessingEvent();
94
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry);
95
        simtime_t getTransmissionDelay(BeginSendEntry *beginSendEntry);
96
        virtual Event *getPreviousEvent();
97
        virtual Event *getNextEvent();
98

    
99
        virtual Event *getCauseEvent();
100
        virtual BeginSendEntry *getCauseBeginSendEntry();
101
        virtual MessageSendDependency *getCause();
102
        virtual IMessageDependencyList *getCauses();
103
        virtual IMessageDependencyList *getConsequences();
104

    
105
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true);
106

    
107
    protected:
108
        void clearInternalState();
109
        void deleteConsequences();
110
        void deleteAllocatedObjects();
111
};
112

    
113
NAMESPACE_END
114

    
115

    
116
#endif