forked from FengJungle/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdapterPattern.h
More file actions
56 lines (50 loc) · 806 Bytes
/
AdapterPattern.h
File metadata and controls
56 lines (50 loc) · 806 Bytes
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
#ifndef __SINGLETON_H__
#define __SINGLETON_H__
#include <iostream>
#include <string.h>
#include <mutex>
using namespace std;
//目标抽象类
class Controller
{
public:
Controller(){}
virtual void pathPlanning() = 0;
private:
};
//适配者类DxfParser
class DxfParser
{
public:
DxfParser(){}
void parseFile(){
printf("解析文件提取数据\n");
}
};
//适配者类PathPlanner
class PathPlanner
{
public:
PathPlanner(){}
void calculate(){
printf("计算加工路径\n");
}
};
//适配器类Adapter
class Adapter:public Controller
{
public:
Adapter(){
dxfParser = new DxfParser();
pathPlanner = new PathPlanner();
}
void pathPlanning(){
printf("路径规划:\n");
dxfParser->parseFile();
pathPlanner->calculate();
}
private:
DxfParser *dxfParser;
PathPlanner *pathPlanner;
};
#endif //__SINGLETON_H__