Debian Codegraph @

Source/Reasoner/Kernel/Process/CDatatypeValueSpaceRealValuesCounter.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CDatatypeValueSpaceRealValuesCounter.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32
33 CDatatypeValueSpaceRealValuesCounter::CDatatypeValueSpaceRealValuesCounter() {
34 initRealValueCounter();
35 }
36
37 CDatatypeValueSpaceRealValuesCounter* CDatatypeValueSpaceRealValuesCounter::initRealValueCounter(cint64 valueCount) {
38 initValueCounter(valueCount);
39 mIntegerTypeCounter.initValueCounter(valueCount);
40 mDecimalTypeCounter.initValueCounter(valueCount);
41 mRationalTypeCounter.initValueCounter(valueCount);
42 mNonIntegerTypeCounter.initValueCounter(valueCount);
43 mNonDecimalTypeCounter.initValueCounter(valueCount);
44 mNonRationalTypeCounter.initValueCounter(valueCount);
45 return this;
46 }
47
48
49 bool CDatatypeValueSpaceRealValuesCounter::incValueCount(cint64 type, cint64 incCount) {
50 bool counted = false;
51 if ((type & RVT_INTEGER_ONLY_COUNT) != 0) {
52 counted |= mIntegerTypeCounter.incValueCount(incCount);
53 }
54 if ((type & RVT_DECIMAL_ONLY_COUNT) != 0) {
55 counted |= mDecimalTypeCounter.incValueCount(incCount);
56 }
57 if ((type & RVT_RATIONAL_ONLY_COUNT) != 0) {
58 counted |= mRationalTypeCounter.incValueCount(incCount);
59 }
60 if ((type & RVT_NON_INTEGER_ONLY_COUNT) != 0) {
61 counted |= mNonIntegerTypeCounter.incValueCount(incCount);
62 }
63 if ((type & RVT_NON_DECIMAL_ONLY_COUNT) != 0) {
64 counted |= mNonDecimalTypeCounter.incValueCount(incCount);
65 }
66 if ((type & RVT_NON_RATIONAL_ONLY_COUNT) != 0) {
67 counted |= mNonRationalTypeCounter.incValueCount(incCount);
68 }
69 return counted;
70 }
71
72 bool CDatatypeValueSpaceRealValuesCounter::incInfinite(cint64 type) {
73 bool counted = false;
74 if ((type & RVT_INTEGER_ONLY_COUNT) != 0) {
75 counted |= mIntegerTypeCounter.incInfinite();
76 }
77 if ((type & RVT_DECIMAL_ONLY_COUNT) != 0) {
78 counted |= mDecimalTypeCounter.incInfinite();
79 }
80 if ((type & RVT_RATIONAL_ONLY_COUNT) != 0) {
81 counted |= mRationalTypeCounter.incInfinite();
82 }
83 if ((type & RVT_NON_INTEGER_ONLY_COUNT) != 0) {
84 counted |= mNonIntegerTypeCounter.incInfinite();
85 }
86 if ((type & RVT_NON_DECIMAL_ONLY_COUNT) != 0) {
87 counted |= mNonDecimalTypeCounter.incInfinite();
88 }
89 if ((type & RVT_NON_RATIONAL_ONLY_COUNT) != 0) {
90 counted |= mNonRationalTypeCounter.incInfinite();
91 }
92 return counted;
93 }
94
95 bool CDatatypeValueSpaceRealValuesCounter::isInfinite(cint64 type) {
96 bool infinite = true;
97 if ((type & RVT_INTEGER_ONLY_COUNT) != 0) {
98 infinite &= mIntegerTypeCounter.isInfinite();
99 }
100 if ((type & RVT_DECIMAL_ONLY_COUNT) != 0) {
101 infinite &= mDecimalTypeCounter.isInfinite();
102 }
103 if ((type & RVT_RATIONAL_ONLY_COUNT) != 0) {
104 infinite &= mRationalTypeCounter.isInfinite();
105 }
106 if ((type & RVT_NON_INTEGER_ONLY_COUNT) != 0) {
107 infinite &= mNonIntegerTypeCounter.isInfinite();
108 }
109 if ((type & RVT_NON_DECIMAL_ONLY_COUNT) != 0) {
110 infinite &= mNonDecimalTypeCounter.isInfinite();
111 }
112 if ((type & RVT_NON_RATIONAL_ONLY_COUNT) != 0) {
113 infinite &= mNonRationalTypeCounter.isInfinite();
114 }
115 return infinite;
116 }
117
118 cint64 CDatatypeValueSpaceRealValuesCounter::getValueCount(cint64 type) {
119 cint64 valueCount = true;
120 if ((type & RVT_INTEGER_ONLY_COUNT) != 0) {
121 valueCount += mIntegerTypeCounter.getValueCount();
122 }
123 if ((type & RVT_DECIMAL_ONLY_COUNT) != 0) {
124 valueCount += mDecimalTypeCounter.getValueCount();
125 }
126 if ((type & RVT_RATIONAL_ONLY_COUNT) != 0) {
127 valueCount += mRationalTypeCounter.getValueCount();
128 }
129 if ((type & RVT_NON_INTEGER_ONLY_COUNT) != 0) {
130 valueCount += mNonIntegerTypeCounter.getValueCount();
131 }
132 if ((type & RVT_NON_DECIMAL_ONLY_COUNT) != 0) {
133 valueCount += mNonDecimalTypeCounter.getValueCount();
134 }
135 if ((type & RVT_NON_RATIONAL_ONLY_COUNT) != 0) {
136 valueCount += mNonRationalTypeCounter.getValueCount();
137 }
138 return valueCount;
139 }
140
141
142 bool CDatatypeValueSpaceRealValuesCounter::hasValueAchieved(cint64 value) {
143 return CDatatypeValueSpaceValuesCounter::hasValueAchieved(value);
144 }
145
146 cint64 CDatatypeValueSpaceRealValuesCounter::getValueCount() {
147 return CDatatypeValueSpaceValuesCounter::getValueCount();
148 }
149
150 bool CDatatypeValueSpaceRealValuesCounter::isInfinite() {
151 return CDatatypeValueSpaceValuesCounter::isInfinite();
152 }
153
154 bool CDatatypeValueSpaceRealValuesCounter::hasValueAchieved(cint64 type, cint64 value) {
155 bool achieved = true;
156 if ((type & RVT_INTEGER_ONLY_COUNT) != 0) {
157 achieved &= mIntegerTypeCounter.hasValueAchieved(value);
158 }
159 if ((type & RVT_DECIMAL_ONLY_COUNT) != 0) {
160 achieved &= mDecimalTypeCounter.hasValueAchieved(value);
161 }
162 if ((type & RVT_RATIONAL_ONLY_COUNT) != 0) {
163 achieved &= mRationalTypeCounter.hasValueAchieved(value);
164 }
165 if ((type & RVT_NON_INTEGER_ONLY_COUNT) != 0) {
166 achieved &= mNonIntegerTypeCounter.hasValueAchieved(value);
167 }
168 if ((type & RVT_NON_DECIMAL_ONLY_COUNT) != 0) {
169 achieved &= mNonDecimalTypeCounter.hasValueAchieved(value);
170 }
171 if ((type & RVT_NON_RATIONAL_ONLY_COUNT) != 0) {
172 achieved &= mNonRationalTypeCounter.hasValueAchieved(value);
173 }
174 return achieved;
175 }
176
177
178 CDatatypeValueSpaceValuesCounter::VALUES_COUNTER_TYPE CDatatypeValueSpaceRealValuesCounter::getCounterType() {
179 return VCT_REAL_VALUE_COUNTER;
180 }
181
182
183 bool CDatatypeValueSpaceRealValuesCounter::combineWithValueCounter(CDatatypeValueSpaceValuesCounter* counter, cint64 additionalDiff) {
184 bool modified = false;
185 modified |= CDatatypeValueSpaceValuesCounter::combineWithValueCounter(counter,additionalDiff);
186 CDatatypeValueSpaceRealValuesCounter* realCounter = dynamic_cast<CDatatypeValueSpaceRealValuesCounter*>(counter);
187 if (realCounter) {
188 modified |= mIntegerTypeCounter.combineWithValueCounter(&realCounter->mIntegerTypeCounter,additionalDiff);
189 modified |= mDecimalTypeCounter.combineWithValueCounter(&realCounter->mDecimalTypeCounter,additionalDiff);
190 modified |= mRationalTypeCounter.combineWithValueCounter(&realCounter->mRationalTypeCounter,additionalDiff);
191 modified |= mNonIntegerTypeCounter.combineWithValueCounter(&realCounter->mNonIntegerTypeCounter,additionalDiff);
192 modified |= mNonDecimalTypeCounter.combineWithValueCounter(&realCounter->mNonDecimalTypeCounter,additionalDiff);
193 modified |= mNonRationalTypeCounter.combineWithValueCounter(&realCounter->mNonRationalTypeCounter,additionalDiff);
194 }
195 return modified;
196 }
197
198
199 }; // end namespace Process
200
201 }; // end namespace Kernel
202
203 }; // end namespace Reasoner
204
205 }; // end namespace Konclude