-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlphabet.h
61 lines (48 loc) · 1.22 KB
/
Alphabet.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
#ifndef ALPHABET_H
#define ALPHABET_H
#include <iostream>
#include <stdexcept>
#include <cstddef>
#include <string>
// typedef char Symbol;
class Alphabet {
public:
class BadAlphabetCreation: public std::logic_error {
public:
BadAlphabetCreation(std::string type):
logic_error("Cannot create type " + type) {}
};
/* class BadSymbol: public std::logic_error { */
/* public: */
/* BadSymbol(char symbol): */
/* logic_error("Cannot encode symbol " + symbol) {} */
/* }; */
virtual int size() = 0;
virtual int encode(char) = 0;
virtual char decode(int) = 0;
virtual ~Alphabet() {}
// factory method
static Alphabet* factory(const std::string&)
throw(BadAlphabetCreation);
};
class AminoAcidSymbols: public Alphabet {
AminoAcidSymbols() {}
friend class Alphabet;
static std::string alphabet;
public:
int size() { return alphabet.size(); }
int encode(char);
char decode(int);
~AminoAcidSymbols() {}
};
class SecondaryStructureSymbols: public Alphabet {
SecondaryStructureSymbols() {}
friend class Alphabet;
static std::string alphabet;
public:
int size() { return alphabet.size(); }
int encode(char);
char decode(int);
~SecondaryStructureSymbols() {}
};
#endif // ALPHABET_H