-
Notifications
You must be signed in to change notification settings - Fork 272
/
Copy pathFingerprintModule.h
112 lines (105 loc) · 1.76 KB
/
FingerprintModule.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
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
#ifndef __FINGERPRINTMODULE_H__
#define __FINGERPRINTMODULE_H__
#include <stdio.h>
// 基类
class FingerprintModule
{
public:
FingerprintModule() {}
virtual ~FingerprintModule() {}
void getImage()
{
printf("采指纹图像\n");
}
void output()
{
printf("指纹图像处理完成!\n");
}
virtual bool isSafeMode() = 0;
virtual void processImage() = 0;
// 加解密
virtual void encrypt() = 0;
virtual void decrypt() = 0;
// 模板方法
void algorithm()
{
// 1.采图
getImage();
// 2.安全模式下加密和解密
if (isSafeMode())
{
// 2.1. 加密
encrypt();
// 2.2. 解密
decrypt();
}
// 3.处理Image
processImage();
// 4.处理结果
output();
}
};
// 派生类
class FingerprintModuleA : public FingerprintModule
{
public:
FingerprintModuleA() {}
void processImage()
{
printf("使用 第一代版本算法 处理指纹图像\n");
}
bool isSafeMode()
{
printf("安全模式\n");
return true;
}
void encrypt()
{
printf("使用RSA密钥加密\n");
}
void decrypt()
{
printf("使用RSA密钥解密\n");
}
};
// 派生类
class FingerprintModuleB : public FingerprintModule
{
public:
FingerprintModuleB() {}
void processImage()
{
printf("使用 第二代版本算法 处理指纹图像\n");
}
bool isSafeMode()
{
printf("非安全模式\n");
return false;
}
void encrypt() {}
void decrypt() {}
};
// 派生类
class FingerprintModuleC : public FingerprintModule
{
public:
FingerprintModuleC() {}
void processImage()
{
printf("使用 第一代版本算法 处理指纹图像\n");
}
bool isSafeMode()
{
printf("安全模式\n");
return true;
}
void encrypt()
{
printf("使用DH密钥加密\n");
}
void decrypt()
{
printf("使用DH密钥解密\n");
}
};
#endif //__FINGERPRINTMODULE_H__