-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompressioncontroller.cpp
More file actions
53 lines (45 loc) · 1.19 KB
/
compressioncontroller.cpp
File metadata and controls
53 lines (45 loc) · 1.19 KB
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
#include "compressioncontroller.h"
CompressionController::CompressionController()
{
}
void CompressionController::compress(const QString& filePath, AlgorithmEnum algo)
{
switch (algo)
{
case AlgorithmEnum::Huffman:
qDebug() << "Huffman enum";
compressHuffman(filePath);
break;
case AlgorithmEnum::Arithmetic:
qDebug() << "Arithmetic enum";
compressArithmetic(filePath);
break;
case AlgorithmEnum::LZ77:
qDebug() << "LZ77 enum";
compressLZ77(filePath);
break;
default:
qCritical() << "Default. This Algorithmenum is not allowed";
}
}
void CompressionController::decompress(const QString &filePath)
{
HuffmanDecode huffmanDecode;
huffmanDecode.decompress(filePath);
}
//consider using polymorphism here
void CompressionController::compressHuffman(const QString& filePath)
{
Huffman huffman;
huffman.compress(filePath);
}
void CompressionController::compressArithmetic(const QString& filePath)
{
Arithmetic arithmetic;
arithmetic.compress(filePath);
}
void CompressionController::compressLZ77(const QString& filePath)
{
LZ77 lz77;
lz77.compress(filePath);
}