Statistics
| Branch: | Revision:

root / src / eventlog / eventlogtablefacade.h @ e1750c09

History | View | Annotate | Download (3.6 KB)

1
//=========================================================================
2
//  EVENTLOGTABLEFACADE.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 __EVENTLOGTABLEFACADE_H_
18
#define __EVENTLOGTABLEFACADE_H_
19

    
20
#include "matchexpression.h"
21
#include "ievent.h"
22
#include "ieventlog.h"
23
#include "eventlogfacade.h"
24

    
25
NAMESPACE_BEGIN
26

    
27
enum EventLogTableFilterMode {
28
    ALL_ENTRIES,
29
    EVENT_AND_SEND_AND_MESSAGE_ENTRIES,
30
    EVENT_AND_MESSAGE_ENTRIES,
31
    EVENT_ENTRIES,
32
    CUSTOM_ENTRIES
33
};
34

    
35
/**
36
 * A class that makes it possible to extract info about events, without
37
 * returning objects. (Wherever a C++ method returns an object pointer,
38
 * SWIG-generated wrapper creates a corresponding Java object with the
39
 * pointer value inside. This has disastrous effect on performance
40
 * when dealing with huge amounts of data).
41
 */
42
class EVENTLOG_API EventLogTableFacade : public EventLogFacade
43
{
44
    protected:
45
        eventnumber_t approximateNumberOfEntries;
46
        eventnumber_t lastMatchedEventNumber;
47
        int lastNumMatchingEventLogEntries;
48
        EventLogTableFilterMode filterMode;
49
        std::string customFilter;
50
        MatchExpression matchExpression;
51

    
52
    public:
53
        EventLogTableFacade(IEventLog *eventLog);
54
        virtual ~EventLogTableFacade() {}
55

    
56
        virtual void synchronize(FileReader::FileChangedState change);
57

    
58
        EventLogTableFilterMode getFilterMode() { return filterMode; }
59
        void setFilterMode(EventLogTableFilterMode filterMode);
60
        bool matchesFilter(EventLogEntry *eventLogEntry);
61
        int getNumMatchingEventLogEntries(IEvent *event);
62
        void setCustomFilter(const char *pattern) { customFilter = pattern; matchExpression.setPattern((std::string("E or (") + customFilter + ")").c_str(), false, true, false); }
63
        const char *getCustomFilter() { return customFilter.c_str(); }
64

    
65
        EventLogEntry *getEventLogEntry(eventnumber_t eventNumber, int eventLogEntryIndex);
66
        EventLogEntry *getFirstEntry();
67
        EventLogEntry *getLastEntry();
68
        int getEntryIndexInEvent(EventLogEntry *eventLogEntry);
69
        EventLogEntry *getEntryInEvent(IEvent *event, int index);
70
        eventnumber_t getDistanceToEntry(EventLogEntry *sourceEventLogEntry, EventLogEntry *targetEventLogEntry, eventnumber_t limit);
71
        EventLogEntry *getClosestEntryInEvent(EventLogEntry *eventLogEntry);
72
        eventnumber_t getDistanceToFirstEntry(EventLogEntry *eventLogEntry, eventnumber_t limit);
73
        eventnumber_t getDistanceToLastEntry(EventLogEntry *eventLogEntry, eventnumber_t limit);
74
        EventLogEntry *getNeighbourEntry(EventLogEntry *eventLogEntry, eventnumber_t distance);
75
        double getApproximatePercentageForEntry(EventLogEntry *eventLogEntry);
76
        EventLogEntry *getApproximateEventLogEntryAt(double percentage);
77
        eventnumber_t getApproximateNumberOfEntries();
78

    
79
    protected:
80
        EventLogEntry *getPreviousEntry(EventLogEntry *eventLogEntry, int& index);
81
        EventLogEntry *getNextEntry(EventLogEntry *eventLogEntry, int& index);
82
        EventLogEntry *getEntryAndDistance(EventLogEntry *sourceEventLogEntry, EventLogEntry *targetEventLogEntry, eventnumber_t distance, eventnumber_t& reachedDistance);
83
};
84

    
85
NAMESPACE_END
86

    
87

    
88
#endif