Project

General

Profile

Statistics
| Branch: | Revision:

root / src / eventlog / eventlogfacade.cc @ 8aeaaccc

History | View | Annotate | Download (8.49 KB)

1
//=========================================================================
2
//  EVENTLOGFACADE.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
#include "ieventlog.h"
20
#include "event.h"
21
#include "eventlog.h"
22
#include "filteredevent.h"
23
#include "filteredeventlog.h"
24
#include "eventlogfacade.h"
25

    
26
USING_NAMESPACE
27

    
28
EventLogFacade::EventLogFacade(IEventLog *eventLog)
29
{
30
    Assert(eventLog);
31
    this->eventLog = eventLog;
32
}
33

    
34
void EventLogFacade::synchronize(FileReader::FileChangedState change)
35
{
36
    if (change != FileReader::UNCHANGED)
37
        return eventLog->synchronize(change);
38
}
39

    
40
IEvent* EventLogFacade::IEvent_getEvent(ptr_t ptr)
41
{
42
    IEVENT_PTR(ptr);
43
    return (IEvent*)ptr;
44
}
45

    
46
ptr_t EventLogFacade::IEvent_getNonFilteredEvent(ptr_t ptr)
47
{
48
    IEVENT_PTR(ptr);
49
    IEvent *ievent = (IEvent*)ptr;
50

    
51
    Event *event = dynamic_cast<Event *>(ievent);
52
    if (event)
53
        return ptr;
54
    else
55
        return IEvent_getNonFilteredEvent((ptr_t)((FilteredEvent *)ievent)->getEvent());
56
}
57

    
58
ptr_t EventLogFacade::IEvent_getEventForEventNumber(eventnumber_t eventNumber)
59
{
60
    return (ptr_t)eventLog->getEventForEventNumber(eventNumber);
61
}
62

    
63
ptr_t EventLogFacade::IEvent_getNonFilteredEventForEventNumber(eventnumber_t eventNumber)
64
{
65
    EventLog *nonFilteredEventLog = dynamic_cast<EventLog *>(eventLog);
66

    
67
    if (nonFilteredEventLog)
68
        return (ptr_t)nonFilteredEventLog->getEventForEventNumber(eventNumber);
69
    else
70
        return (ptr_t)((FilteredEventLog *)eventLog)->getEventLog()->getEventForEventNumber(eventNumber);
71
}
72

    
73
ptr_t EventLogFacade::IEvent_getPreviousEvent(ptr_t ptr)
74
{
75
    IEVENT_PTR(ptr);
76
    return (ptr_t)((IEvent*)ptr)->getPreviousEvent();
77
}
78

    
79
ptr_t EventLogFacade::IEvent_getNextEvent(ptr_t ptr)
80
{
81
    IEVENT_PTR(ptr);
82
    return (ptr_t)((IEvent*)ptr)->getNextEvent();
83
}
84

    
85
eventnumber_t EventLogFacade::IEvent_getEventNumber(ptr_t ptr)
86
{
87
    IEVENT_PTR(ptr);
88
    return ((IEvent*)ptr)->getEventNumber();
89
}
90

    
91
simtime_t EventLogFacade::IEvent_getSimulationTime(ptr_t ptr)
92
{
93
    IEVENT_PTR(ptr);
94
    return ((IEvent*)ptr)->getSimulationTime();
95
}
96

    
97
double EventLogFacade::IEvent_getSimulationTimeAsDouble(ptr_t ptr)
98
{
99
    IEVENT_PTR(ptr);
100
    return ((IEvent*)ptr)->getSimulationTime().dbl();
101
}
102

    
103
int EventLogFacade::IEvent_getModuleId(ptr_t ptr)
104
{
105
    IEVENT_PTR(ptr);
106
    return ((IEvent*)ptr)->getModuleId();
107
}
108

    
109
int EventLogFacade::IEvent_getNumCauses(ptr_t ptr)
110
{
111
    IEVENT_PTR(ptr);
112
    return ((IEvent*)ptr)->getCauses()->size();
113
}
114

    
115
int EventLogFacade::IEvent_getNumConsequences(ptr_t ptr)
116
{
117
    IEVENT_PTR(ptr);
118
    return ((IEvent*)ptr)->getConsequences()->size();
119
}
120

    
121
ptr_t EventLogFacade::IEvent_getCause(ptr_t ptr, int index)
122
{
123
    IEVENT_PTR(ptr);
124
    return (ptr_t)((IEvent*)ptr)->getCauses()->at(index);
125
}
126

    
127
ptr_t EventLogFacade::IEvent_getConsequence(ptr_t ptr, int index)
128
{
129
    IEVENT_PTR(ptr);
130
    return (ptr_t)((IEvent*)ptr)->getConsequences()->at(index);
131
}
132

    
133
bool EventLogFacade::IEvent_isSelfMessageProcessingEvent(ptr_t ptr)
134
{
135
    IEVENT_PTR(ptr);
136
    return ((IEvent*)ptr)->isSelfMessageProcessingEvent();
137
}
138

    
139
EventLogEntry *EventLogFacade::EventLogEntry_getEventLogEntry(ptr_t ptr)
140
{
141
    EVENT_LOG_ENTRY_PTR(ptr);
142
    return (EventLogEntry*)ptr;
143
}
144

    
145
ptr_t EventLogFacade::EventLogEntry_getEvent(ptr_t ptr)
146
{
147
    EVENT_LOG_ENTRY_PTR(ptr);
148
    return (ptr_t)((EventLogEntry*)ptr)->getEvent();
149
}
150

    
151
int EventLogFacade::EventLogEntry_getContextModuleId(ptr_t ptr)
152
{
153
    EVENT_LOG_ENTRY_PTR(ptr);
154
    return ((EventLogEntry*)ptr)->contextModuleId;
155
}
156

    
157
int EventLogFacade::EventLogEntry_getEntryIndex(ptr_t ptr)
158
{
159
    EVENT_LOG_ENTRY_PTR(ptr);
160
    return ((EventLogEntry*)ptr)->getEntryIndex();
161
}
162

    
163
bool EventLogFacade::BeginSendEntry_isSelfMessage(ptr_t ptr)
164
{
165
    BEGIN_SEND_ENTRY_PTR(ptr);
166
    BeginSendEntry *beginSendEntry = (BeginSendEntry *)ptr;
167
    return beginSendEntry->getEvent()->isSelfMessage(beginSendEntry);
168
}
169

    
170
int EventLogFacade::BeginSendEntry_getMessageId(ptr_t ptr)
171
{
172
    BEGIN_SEND_ENTRY_PTR(ptr);
173
    BeginSendEntry *beginSendEntry = (BeginSendEntry *)ptr;
174
    return beginSendEntry->messageId;
175
}
176

    
177
ptr_t EventLogFacade::BeginSendEntry_getEndSendEntry(ptr_t ptr)
178
{
179
    BEGIN_SEND_ENTRY_PTR(ptr);
180
    BeginSendEntry *beginSendEntry = (BeginSendEntry *)ptr;
181
    return (ptr_t)beginSendEntry->getEvent()->getEndSendEntry(beginSendEntry);
182
}
183

    
184
simtime_t EventLogFacade::BeginSendEntry_getTransmissionDelay(ptr_t ptr)
185
{
186
    IMESSAGE_DEPENDENCY_PTR(ptr);
187
    BeginSendEntry *beginSendEntry = (BeginSendEntry *)ptr;
188
    return beginSendEntry->getEvent()->getTransmissionDelay(beginSendEntry);
189
}
190

    
191
bool EventLogFacade::EndSendEntry_isReceptionStart(ptr_t ptr)
192
{
193
    END_SEND_ENTRY_PTR(ptr);
194
    EndSendEntry *endSendEntry = (EndSendEntry *)ptr;
195
    return endSendEntry->isReceptionStart;
196
}
197

    
198
const char *EventLogFacade::ModuleCreatedEntry_getModuleFullPath(ptr_t ptr)
199
{
200
    std::string fullPath;
201
    MODULE_CREATED_ENTRY_PTR(ptr);
202
    ModuleCreatedEntry *moduleCreatedEntry = (ModuleCreatedEntry *)ptr;
203

    
204
    while (moduleCreatedEntry) {
205
        fullPath = moduleCreatedEntry->fullName + fullPath;
206
        moduleCreatedEntry = eventLog->getModuleCreatedEntry(moduleCreatedEntry->parentModuleId);
207
        if (moduleCreatedEntry)
208
            fullPath = "." + fullPath;
209
    }
210

    
211
    return eventLogStringPool.get(fullPath.c_str());
212
}
213

    
214
int EventLogFacade::ModuleMethodBeginEntry_getFromModuleId(ptr_t ptr)
215
{
216
    MODULE_METHOD_BEGIN_ENTRY_PTR(ptr);
217
    return ((ModuleMethodBeginEntry *)ptr)->fromModuleId;
218
}
219

    
220
int EventLogFacade::ModuleMethodBeginEntry_getToModuleId(ptr_t ptr)
221
{
222
    MODULE_METHOD_BEGIN_ENTRY_PTR(ptr);
223
    return ((ModuleMethodBeginEntry *)ptr)->toModuleId;
224
}
225

    
226
const char *EventLogFacade::ModuleMethodBeginEntry_getMethod(ptr_t ptr)
227
{
228
    MODULE_METHOD_BEGIN_ENTRY_PTR(ptr);
229
    return ((ModuleMethodBeginEntry *)ptr)->method;
230
}
231

    
232
IMessageDependency *EventLogFacade::IMessageDependency_getMessageDependency(ptr_t ptr)
233
{
234
    IMESSAGE_DEPENDENCY_PTR(ptr);
235
    return (IMessageDependency*)ptr;
236
}
237

    
238
const char *EventLogFacade::IMessageDependency_getMessageName(ptr_t ptr)
239
{
240
    IMESSAGE_DEPENDENCY_PTR(ptr);
241
    return ((IMessageDependency*)ptr)->getBeginSendEntry()->messageFullName;
242
}
243

    
244
bool EventLogFacade::IMessageDependency_isReuse(ptr_t ptr)
245
{
246
    IMESSAGE_DEPENDENCY_PTR(ptr);
247
    return ((IMessageDependency*)ptr)->getIsReuse();
248
}
249

    
250
bool EventLogFacade::IMessageDependency_isSelfMessageReuse(ptr_t ptr)
251
{
252
    MESSAGE_DEPENDENCY_PTR(ptr);
253
    return ((MessageDependency*)ptr)->isSelfMessageReuse();
254
}
255

    
256
bool EventLogFacade::IMessageDependency_isStoredMessageReuse(ptr_t ptr)
257
{
258
    MESSAGE_DEPENDENCY_PTR(ptr);
259
    return ((MessageDependency*)ptr)->isStoredMessageReuse();
260
}
261

    
262
bool EventLogFacade::IMessageDependency_isFilteredMessageDependency(ptr_t ptr)
263
{
264
    IMESSAGE_DEPENDENCY_PTR(ptr);
265
    return dynamic_cast<FilteredMessageDependency*>((IMessageDependency*)ptr);
266
}
267

    
268
ptr_t EventLogFacade::IMessageDependency_getCauseEvent(ptr_t ptr)
269
{
270
    IMESSAGE_DEPENDENCY_PTR(ptr);
271
    return (ptr_t)((IMessageDependency*)ptr)->getCauseEvent();
272
}
273

    
274
ptr_t EventLogFacade::IMessageDependency_getConsequenceEvent(ptr_t ptr)
275
{
276
    IMESSAGE_DEPENDENCY_PTR(ptr);
277
    return (ptr_t)((IMessageDependency*)ptr)->getConsequenceEvent();
278
}
279

    
280
ptr_t EventLogFacade::IMessageDependency_getBeginSendEntry(ptr_t ptr)
281
{
282
    IMESSAGE_DEPENDENCY_PTR(ptr);
283
    return (ptr_t)((IMessageDependency*)ptr)->getBeginSendEntry();
284
}
285

    
286
simtime_t EventLogFacade::IMessageDependency_getCauseSimulationTime(ptr_t ptr)
287
{
288
    IMESSAGE_DEPENDENCY_PTR(ptr);
289
    return ((IMessageDependency*)ptr)->getCauseSimulationTime();
290
}
291

    
292
simtime_t EventLogFacade::IMessageDependency_getConsequenceSimulationTime(ptr_t ptr)
293
{
294
    IMESSAGE_DEPENDENCY_PTR(ptr);
295
    return ((IMessageDependency*)ptr)->getConsequenceSimulationTime();
296
}
297

    
298
const char *EventLogFacade::FilteredMessageDependency_getBeginMessageName(ptr_t ptr)
299
{
300
    FILTERED_MESSAGE_DEPENDENCY_PTR(ptr);
301
    return ((FilteredMessageDependency*)ptr)->getBeginMessageDependency()->getBeginSendEntry()->messageFullName;
302
}
303

    
304
const char *EventLogFacade::FilteredMessageDependency_getEndMessageName(ptr_t ptr)
305
{
306
    FILTERED_MESSAGE_DEPENDENCY_PTR(ptr);
307
    return ((FilteredMessageDependency*)ptr)->getEndMessageDependency()->getBeginSendEntry()->messageFullName;
308
}