blob: e878ddfb403a31e9782b673e795d2b56823f1256 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* DNN - Data News Network
*
* by Stephane Chatty
*
* Copyright 1993-1995
* Centre d'Etudes de la Navigation Aerienne (CENA)
*
* Criteria.
*
* $Id$
* $CurLog$
*/
#ifndef IvlCriterion_H_
#define IvlCriterion_H_
#include "cplus_bugs.h"
#include "ivl/bool.h"
#include "ivl/List.h"
class IvlEvent;
class IvlBaseCriterion {
friend class IvlAndCriterion;
friend class IvlOrCriterion;
protected:
IvlBaseCriterion ();
~IvlBaseCriterion ();
public:
virtual bool Test (IvlEvent&) = 0;
};
class IvlOrCriterion;
class IvlAndCriterion : public IvlBaseCriterion {
friend class IvlOrCriterion;
protected:
IvlListOf <IvlBaseCriterion> Conditions;
bool Test (IvlEvent&);
public:
IvlAndCriterion ();
~IvlAndCriterion ();
IvlAndCriterion& operator &= (IvlBaseCriterion&);
IvlAndCriterion& operator &= (IvlOrCriterion&);
IvlAndCriterion& operator &= (IvlAndCriterion&);
};
class IvlOrCriterion : public IvlBaseCriterion {
friend class IvlAndCriterion;
protected:
IvlListOf <IvlBaseCriterion> Alternatives;
bool Test (IvlEvent&);
public:
IvlOrCriterion ();
~IvlOrCriterion ();
IvlOrCriterion& operator |= (IvlBaseCriterion&);
IvlOrCriterion& operator |= (IvlOrCriterion&);
IvlOrCriterion& operator |= (IvlAndCriterion&);
};
class IvlBasicCriterion : public IvlBaseCriterion {
protected:
bool (*Check) (IvlEvent&);
bool Test (IvlEvent& e);
public:
IvlBasicCriterion ();
IvlBasicCriterion (bool (*c) (IvlEvent&));
~IvlBasicCriterion ();
inline void ChangeCriterion (bool (*c) (IvlEvent&)) {Check = c; }
};
template <class T> class IvlCriterionOf : public IvlBaseCriterion {
protected:
T& Object;
void (T::*Check) (IvlEvent&);
public:
IvlCriterionOf (T& o, void (T::*c) (IvlEvent&)) : IvlBaseCriterion (), Object (o), Check (c) {}
~IvlCriterionOf () {}
bool Test (IvlEvent& ev) { return (Object.*Check) (ev); }
};
#define SpecializedCriterion(R,S) \
\
class R : public IvlBaseCriterion { \
\
protected: \
\
S& Body; \
bool (S::*SpecializedCheck) (IvlEvent&); \
\
public: \
\
R (S& s, bool (S::*sc) (IvlEvent&)) : IvlBaseCriterion (), Body (s), SpecializedCheck (sc) {} \
~R () {} \
\
bool Test (IvlEvent& e) { return (Body.*SpecializedCheck) (e); } \
\
};
#endif /* IvlCriterion_H_ */
|