Statistics
| Branch: | Revision:

root / src / eventlog / ievent.cc @ 842775ab

History | View | Annotate | Download (1.94 KB)

1
//=========================================================================
2
//  IEVENTLOG.CC - 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
#include <stdio.h>
18
#include "ievent.h"
19

    
20
USING_NAMESPACE
21

    
22
IEvent::IEvent()
23
{
24
    clearInternalState();
25
}
26

    
27
void IEvent::clearInternalState()
28
{
29
    nextEvent = NULL;
30
    previousEvent = NULL;
31
    cachedTimelineCoordinate = -1;
32
    cachedTimelineCoordinateSystemVersion = -1;
33
}
34

    
35
void IEvent::synchronize(FileReader::FileChangedState change)
36
{
37
    if (change == FileReader::OVERWRITTEN)
38
        clearInternalState();
39
}
40

    
41
int IEvent::findBeginSendEntryIndex(int messageId)
42
{
43
    // find the "BS" or "SA" line in the cause event
44
    for (int beginSendEntryNumber = 0; beginSendEntryNumber < getNumEventLogEntries(); beginSendEntryNumber++)
45
    {
46
        BeginSendEntry *beginSendEntry = dynamic_cast<BeginSendEntry *>(getEventLogEntry(beginSendEntryNumber));
47

    
48
        if (beginSendEntry && beginSendEntry->messageId == messageId)
49
            return beginSendEntryNumber;
50
    }
51

    
52
    return -1;
53
}
54

    
55
void IEvent::linkEvents(IEvent *previousEvent, IEvent *nextEvent)
56
{
57
    previousEvent->nextEvent = nextEvent;
58
    nextEvent->previousEvent = previousEvent;
59
}
60

    
61
void IEvent::unlinkEvents(IEvent *previousEvent, IEvent *nextEvent)
62
{
63
    previousEvent->nextEvent = NULL;
64
    nextEvent->previousEvent = NULL;
65
}
66

    
67
void IEvent::unlinkNeighbourEvents(IEvent *event)
68
{
69
    if (event->previousEvent)
70
        unlinkEvents(event->previousEvent, event);
71
    if (event->nextEvent)
72
        unlinkEvents(event, event->nextEvent);
73
}