Project

General

Profile

Statistics
| Branch: | Revision:

root / src / eventlog / filteredevent.h @ daf081df

History | View | Annotate | Download (5.23 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  FILTEREDEVENT.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 __FILTEREDEVENT_H_
18
#define __FILTEREDEVENT_H_
19
20
#include <vector>
21
#include "eventlogdefs.h"
22
#include "ievent.h"
23
#include "event.h"
24
25
NAMESPACE_BEGIN
26
27
class FilteredEventLog;
28
29
/**
30
 * Events stored in the FilteredEventLog. This class uses the Event class by delegation so that multiple
31
 * filtered events can share the same event object.
32
 *
33
 * Filtered events are in a lazy double-linked list based on event numbers.
34
 */
35
class EVENTLOG_API FilteredEvent : public IEvent
36
{
37
    protected:
38
        FilteredEventLog *filteredEventLog;
39
40
        eventnumber_t eventNumber; // the corresponding event number
41
        eventnumber_t causeEventNumber; // the event number from which the message was sent that is being processed in this event
42
        IMessageDependency *cause; // the message send which is processed in this event
43
        IMessageDependencyList *causes; // the arrival message sends of messages which we send in this even and are in the filtered set
44
        IMessageDependencyList *consequences; // the message sends and arrivals from this event to another in the filtered set
45
46
        struct BreadthSearchItem {
47
            IEvent *event;
48
            IMessageDependency *firstSeenMessageDependency;
49
            bool effectiveIsReuse;
50
            int level;
51
52
            BreadthSearchItem(IEvent *event, IMessageDependency *firstSeenMessageDependency, bool effectiveIsReuse, int level)
53
            {
54
                this->event = event;
55
                this->firstSeenMessageDependency = firstSeenMessageDependency;
56
                this->effectiveIsReuse = effectiveIsReuse;
57
                this->level = level;
58
            }
59
        };
60
61
    public:
62
        FilteredEvent(FilteredEventLog *filteredEventLog, eventnumber_t eventNumber);
63
        ~FilteredEvent();
64
65
        IEvent *getEvent();
66
67
        // IEvent interface
68
        virtual void synchronize();
69
        virtual IEventLog *getEventLog();
70
71
        virtual ModuleCreatedEntry *getModuleCreatedEntry() { return getEvent()->getModuleCreatedEntry(); }
72
73
        virtual file_offset_t getBeginOffset() { return getEvent()->getBeginOffset(); }
74
        virtual file_offset_t getEndOffset() { return getEvent()->getEndOffset(); }
75
76
        virtual EventEntry *getEventEntry() { return getEvent()->getEventEntry(); }
77 2f5cc443 Simon Tenbusch
        virtual EventEndEntry *getEventEndEntry() { return getEvent()->getEventEndEntry(); }
78 01873262 Georg Kunz
        virtual int getNumEventLogEntries() { return getEvent()->getNumEventLogEntries(); }
79
        virtual EventLogEntry *getEventLogEntry(int index) { return getEvent()->getEventLogEntry(index); }
80
81
        virtual int getNumEventLogMessages() { return getEvent()->getNumEventLogMessages(); }
82
        virtual int getNumBeginSendEntries() { return getEvent()->getNumBeginSendEntries(); }
83
        virtual EventLogMessageEntry *getEventLogMessage(int index) { return getEvent()->getEventLogMessage(index); }
84
85
        virtual eventnumber_t getEventNumber() { return eventNumber; }
86
        virtual simtime_t getSimulationTime() { return getEvent()->getSimulationTime(); }
87 daf081df Simon Tenbusch
        virtual long getComplexity() { return getEvent()->getComplexity(); }
88 01873262 Georg Kunz
        virtual int getModuleId() { return getEvent()->getModuleId(); }
89
        virtual long getMessageId() { return getEvent()->getMessageId(); }
90
        virtual eventnumber_t getCauseEventNumber() { return getEvent()->getCauseEventNumber(); }
91
92
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry) { return getEvent()->isSelfMessage(beginSendEntry); }
93
        virtual bool isSelfMessageProcessingEvent() { return getEvent()->isSelfMessageProcessingEvent(); }
94
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry) { return getEvent()->getEndSendEntry(beginSendEntry); };
95
        virtual FilteredEvent *getPreviousEvent();
96
        virtual FilteredEvent *getNextEvent();
97
98
        virtual FilteredEvent *getCauseEvent();
99
        virtual IMessageDependency *getCause();
100
        virtual BeginSendEntry *getCauseBeginSendEntry();
101
        virtual IMessageDependencyList *getCauses();
102
        virtual IMessageDependencyList *getConsequences();
103
104
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) { getEvent()->print(file, outputEventLogMessages); }
105
106
    protected:
107
        void getCauses(IEvent *event, IMessageDependency *endMessageDependency, bool isReuse, int level);
108
        void getConsequences(IEvent *event, IMessageDependency *beginMessageDependency, bool isReuse, int level);
109
        int countFilteredMessageDependencies(IMessageDependencyList *messageDependencies);
110
        void pushNewFilteredMessageDependency(IMessageDependencyList *messageDependencies, bool isReuse, IMessageDependency *beginMessageDependency, IMessageDependency *endMessageDependency);
111
};
112
113
NAMESPACE_END
114
115
116
#endif