-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintbase2.h
69 lines (63 loc) · 1.92 KB
/
intbase2.h
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
#ifndef INTBASE2_H
#define INTBASE2_H
/*
* For debugging to simplify the deBruijn graph, a minimal set of bases
*/
#include "intbase.h"
const unsigned int n2bases = 3;
std::string bases2[n2bases] = {"A", "C", endmarker};
class intbase2 : public intbase {
void set_consts() {
bases.clear(); // WARNING: not a good idea to to use multiple intbase subclasses!
for (unsigned int i=0; i<n2bases; ++i) {
bases.push_back(bases2[i]);
}
intbase::set_consts();
};
public:
intbase2() : intbase() {
set_consts();
};
intbase2(base_t b) : intbase() {
set_consts();
intbase::init_logging();
base_value = base_to_int(b);
};
intbase2(const unsigned int b) : intbase() {
set_consts();
if (b <= get_alphabetsize())
base_value = b;
else {
LOG4CXX_FATAL(logger, "intbase2 constructor: Invalid int base value b " << b << " should be in [0.." << get_alphabetsize() << "]. " << get_alphabetsize() << " is invalid, but is the end indicator.");
abort();
}
};
intbase2(const intbase2 &ib) : intbase() {
set_consts();
base_value = ib.base_value;
};
friend void test_intbase2(intbase2& ib) {
// >, <, ==, and != operators work
ib.set_base((unsigned int)1);
intbase2 ib2;
ib2.set_base((unsigned int)0);
if (!(ib2 < ib)) {
LOG4CXX_FATAL(ib.logger, "ib2 " << ib2 << " >= ib " << ib);
abort();
}
if (!(ib > ib2)) {
LOG4CXX_FATAL(ib.logger, "ib <= ib2");
abort();
}
if (!(ib == ib)) {
LOG4CXX_FATAL(ib.logger, "ib != ib");
abort();
}
if (!(ib2 != ib)) {
LOG4CXX_FATAL(ib.logger, "ib2 == ib");
abort();
}
LOG4CXX_INFO(ib.logger, "Relational operators work.");
}
};
#endif // INTBASE2_H