Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (3.57 KB)

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

    
20
#include "platdefs.h"
21
#include "exception.h"
22
#include "intxtypes.h" // for int64, our equivalent of Java's "long" type
23
#include "commonutil.h"
24
#include "bigdecimal.h"
25

    
26
NAMESPACE_BEGIN
27

    
28

    
29
#if defined(EVENTLOG_EXPORT)
30
#  define EVENTLOG_API OPP_DLLEXPORT
31
#elif defined(EVENTLOG_IMPORT) || defined(OMNETPPLIBS_IMPORT)
32
#  define EVENTLOG_API OPP_DLLIMPORT
33
#else
34
#  define EVENTLOG_API
35
#endif
36

    
37
#define PRINT_DEBUG_MESSAGES false
38

    
39
// the ptr_t type is used throughout the eventlog library to return C++ object pointers
40
// those pointers are used by the gui to efficiently access the C++ library without
41
// generating lots of garbage in the Java world (where the pointer is stored as a 64 long value)
42
// the unsigned long here will be 32 bits on 32 bit platforms and 64 bits on 64 bit platforms
43
//
44
// SWIG provides (by cPtr) positive Java long values even for objects hanging in the upper two gigabytes
45
// of memory on 32 bit platforms; so to have pointers to C++ objects == in Java we must ensure
46
// that the eventlog API functions return values which will be converted to positive Java long
47
// values by SWIG.
48
//
49
// note that C99 defines intptr_t and uintptr_t and uintptr_t would be sufficient here
50
// but not all supported compilers are C99 compatible
51
typedef unsigned long ptr_t;
52

    
53
typedef int64 eventnumber_t;
54
#define EVENTNUMBER_PRINTF_FORMAT INT64_PRINTF_FORMAT
55
inline int64 abs64(int64 a)
56
{
57
   return a < 0 ? -a : a;
58
}
59

    
60
typedef BigDecimal simtime_t;
61
#define simtime_nil BigDecimal::MinusOne
62

    
63
#ifndef PI
64
#define PI        3.141592653589793
65
#endif
66

    
67
/**
68
 * Variables which store event numbers throughout the API may have these
69
 * additional values (positive values are real event numbers).
70
 */
71
enum EventNumberKind
72
{
73
    /**
74
     * The event number is not yet calculated before.
75
     */
76
    EVENT_NOT_YET_CALCULATED = -1,
77
    /**
78
     * There is no such event and will never be because it is impossible. (e.g. the previous event of the first event)
79
     */
80
    NO_SUCH_EVENT = -2,
81
    /**
82
     * The event is not and will never be in the log, although it could be. (e.g. filtered by the user from the file)
83
     */
84
    FILTERED_EVENT = -3,
85
    /**
86
     * The event is not yet in the log, but it might appear in the future (e.g. simulation not there yet).
87
     * The last event number is added to the constant and returned.
88
     * (e.g. reading the event 1000 when the file ends at 100 will give -104)
89
     */
90
    EVENT_NOT_YET_REACHED = -4
91
};
92

    
93
enum MatchKind
94
{
95
    EXACT, // returns not NULL if exactly one event was found
96
    FIRST_OR_PREVIOUS, // if multiple matches were found it returns the first one or the previous if there are no matches at all
97
    FIRST_OR_NEXT, // if multiple matches were found it returns the first one or the next if there are no matches at all
98
    LAST_OR_NEXT, // as per FIRST_OR_PREVIOUS but the opposite
99
    LAST_OR_PREVIOUS // as per FIRST_OR_NEXT but the opposite
100
};
101

    
102
enum TimelineMode {
103
    SIMULATION_TIME,
104
    EVENT_NUMBER,
105
    STEP,
106
    NONLINEAR
107
};
108

    
109
NAMESPACE_END
110

    
111

    
112
#endif