summaryrefslogtreecommitdiff
path: root/dnn/Criterion.cc
blob: d5ac1f6761f62c6df7a38d9bd685afaec8e45c61 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 *	DNN - Data News Network
 *
 *	by Stephane Chatty
 *
 *	Copyright 1993-1995
 *	Centre d'Etudes de la Navigation Aerienne (CENA)
 *
 *	Criteria.
 *
 *	$Id$
 *	$CurLog$
 */

#include "Criterion.h"

IvlBaseCriterion :: IvlBaseCriterion ()
{
}

IvlBaseCriterion :: ~IvlBaseCriterion ()
{
}

IvlAndCriterion :: IvlAndCriterion ()
: IvlBaseCriterion (),
  Conditions ()
{
}

IvlAndCriterion :: ~IvlAndCriterion ()
{
}

IvlAndCriterion&
IvlAndCriterion :: operator &= (IvlBaseCriterion& b)
{
	Conditions.Append (&b);
	return *this;
}

IvlAndCriterion&
IvlAndCriterion :: operator &= (IvlOrCriterion& b)
{
	Conditions.Append (&b);
	return *this;
}

IvlAndCriterion&
IvlAndCriterion :: operator &= (IvlAndCriterion& b)
{
	IvlListIterOf <IvlBaseCriterion> li = b.Conditions;
	while (++li)
		Conditions.Append (*li);
	return *this;
}

bool
IvlAndCriterion :: Test (IvlEvent& ev)
{
	bool res = true;
	IvlListIterOf <IvlBaseCriterion> li = Conditions;
	while (res && ++li)
#ifdef CPLUS_BUG22
		res = bool (res && (*li)->Test (ev));
#else
		res = res && (*li)->Test (ev);
#endif
	return res;
}

IvlOrCriterion :: IvlOrCriterion ()
: IvlBaseCriterion (),
  Alternatives ()
{
}

IvlOrCriterion :: ~IvlOrCriterion ()
{
}

IvlOrCriterion&
IvlOrCriterion :: operator |= (IvlOrCriterion& b)
{
	IvlListIterOf <IvlBaseCriterion> li = b.Alternatives;
	while (++li)
		Alternatives.Append (*li);
	return *this;
}

IvlOrCriterion&
IvlOrCriterion :: operator |= (IvlBaseCriterion& b)
{
	Alternatives.Append (&b);
	return *this;
}

IvlOrCriterion&
IvlOrCriterion :: operator |= (IvlAndCriterion& b)
{
	Alternatives.Append (&b);
	return *this;
}

bool
IvlOrCriterion :: Test (IvlEvent& ev)
{
	bool res = false;
	IvlListIterOf <IvlBaseCriterion> li = Alternatives;
	while (!res && ++li)
#ifdef CPLUS_BUG22
		res = bool (res || (*li)->Test (ev));
#else
		res = res || (*li)->Test (ev);
#endif
	return res;
}

IvlBasicCriterion :: IvlBasicCriterion ()
: IvlBaseCriterion (),
  Check (0)
{
}

IvlBasicCriterion :: IvlBasicCriterion (bool (*c) (IvlEvent&))
: IvlBaseCriterion (),
  Check (c)
{
}

IvlBasicCriterion :: ~IvlBasicCriterion ()
{
}

bool
IvlBasicCriterion :: Test (IvlEvent& e)
{
	return Check ? (*Check) (e) : false;
}