Statistics
| Branch: | Revision:

root / src / eventlog / filteredevent.h @ 2f5cc443

History | View | Annotate | Download (5.16 KB)

1
//=========================================================================
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
        virtual EventEndEntry *getEventEndEntry() { return getEvent()->getEventEndEntry(); }
78
        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
        virtual int getModuleId() { return getEvent()->getModuleId(); }
88
        virtual long getMessageId() { return getEvent()->getMessageId(); }
89
        virtual eventnumber_t getCauseEventNumber() { return getEvent()->getCauseEventNumber(); }
90

    
91
        virtual bool isSelfMessage(BeginSendEntry *beginSendEntry) { return getEvent()->isSelfMessage(beginSendEntry); }
92
        virtual bool isSelfMessageProcessingEvent() { return getEvent()->isSelfMessageProcessingEvent(); }
93
        virtual EndSendEntry *getEndSendEntry(BeginSendEntry *beginSendEntry) { return getEvent()->getEndSendEntry(beginSendEntry); };
94
        virtual FilteredEvent *getPreviousEvent();
95
        virtual FilteredEvent *getNextEvent();
96

    
97
        virtual FilteredEvent *getCauseEvent();
98
        virtual IMessageDependency *getCause();
99
        virtual BeginSendEntry *getCauseBeginSendEntry();
100
        virtual IMessageDependencyList *getCauses();
101
        virtual IMessageDependencyList *getConsequences();
102

    
103
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) { getEvent()->print(file, outputEventLogMessages); }
104

    
105
    protected:
106
        void getCauses(IEvent *event, IMessageDependency *endMessageDependency, bool isReuse, int level);
107
        void getConsequences(IEvent *event, IMessageDependency *beginMessageDependency, bool isReuse, int level);
108
        int countFilteredMessageDependencies(IMessageDependencyList *messageDependencies);
109
        void pushNewFilteredMessageDependency(IMessageDependencyList *messageDependencies, bool isReuse, IMessageDependency *beginMessageDependency, IMessageDependency *endMessageDependency);
110
};
111

    
112
NAMESPACE_END
113

    
114

    
115
#endif