Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (5.31 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
#include "messagedependency.h"
25

    
26
NAMESPACE_BEGIN
27

    
28
class FilteredEventLog;
29

    
30
/**
31
 * Events stored in the FilteredEventLog. This class uses the Event class by delegation so that multiple
32
 * filtered events can share the same event object.
33
 *
34
 * Filtered events are in a lazy double-linked list based on event numbers.
35
 */
36
class EVENTLOG_API FilteredEvent : public IEvent
37
{
38
    protected:
39
        FilteredEventLog *filteredEventLog;
40

    
41
        eventnumber_t eventNumber; // the corresponding event number
42
        eventnumber_t causeEventNumber; // the event number from which the message was sent that is being processed in this event
43
        IMessageDependency *cause; // the message send which is processed in this event
44
        IMessageDependencyList *causes; // the arrival message sends of messages which we send in this even and are in the filtered set
45
        IMessageDependencyList *consequences; // the message sends and arrivals from this event to another in the filtered set
46

    
47
        struct BreadthSearchItem {
48
            IEvent *event;
49
            IMessageDependency *firstSeenMessageDependency;
50
            FilteredMessageDependency::Kind effectiveKind;
51
            int level;
52

    
53
            BreadthSearchItem(IEvent *event, IMessageDependency *firstSeenMessageDependency, FilteredMessageDependency::Kind effectiveKind, int level)
54
            {
55
                this->event = event;
56
                this->firstSeenMessageDependency = firstSeenMessageDependency;
57
                this->effectiveKind = effectiveKind;
58
                this->level = level;
59
            }
60
        };
61

    
62
    public:
63
        FilteredEvent(FilteredEventLog *filteredEventLog, eventnumber_t eventNumber);
64
        virtual ~FilteredEvent();
65

    
66
        IEvent *getEvent();
67

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

    
72
        virtual ModuleCreatedEntry *getModuleCreatedEntry() { return getEvent()->getModuleCreatedEntry(); }
73

    
74
        virtual file_offset_t getBeginOffset() { return getEvent()->getBeginOffset(); }
75
        virtual file_offset_t getEndOffset() { return getEvent()->getEndOffset(); }
76

    
77
        virtual EventEntry *getEventEntry() { return getEvent()->getEventEntry(); }
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 clearInternalState();
107
        void deleteConsequences();
108
        void deleteAllocatedObjects();
109

    
110
        void getCauses(IEvent *event, IMessageDependency *endMessageDependency, bool IsMixed, int level);
111
        void getConsequences(IEvent *event, IMessageDependency *beginMessageDependency, bool IsMixed, int level);
112
        int countFilteredMessageDependencies(IMessageDependencyList *messageDependencies);
113
        void pushNewFilteredMessageDependency(IMessageDependencyList *messageDependencies, FilteredMessageDependency::Kind kind, IMessageDependency *beginMessageDependency, IMessageDependency *endMessageDependency);
114
};
115

    
116
NAMESPACE_END
117

    
118

    
119
#endif