2019-10-22 00:24:54 +00:00
|
|
|
#ifndef __SINGLETON_H__
|
|
|
|
#define __SINGLETON_H__
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string.h>
|
|
|
|
#include <mutex>
|
|
|
|
using namespace std;
|
|
|
|
|
2021-10-28 13:26:15 +00:00
|
|
|
// 目标抽象类
|
2019-10-22 00:24:54 +00:00
|
|
|
class Controller
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Controller(){}
|
2021-04-04 13:09:08 +00:00
|
|
|
virtual ~Controller(){}
|
2019-10-22 00:24:54 +00:00
|
|
|
virtual void pathPlanning() = 0;
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2021-10-28 13:26:15 +00:00
|
|
|
// 适配者类DxfParser
|
2019-10-22 00:24:54 +00:00
|
|
|
class DxfParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DxfParser(){}
|
|
|
|
void parseFile(){
|
2021-10-28 13:26:15 +00:00
|
|
|
printf("Parse dxf file\n");
|
2019-10-22 00:24:54 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-28 13:26:15 +00:00
|
|
|
// 适配者类PathPlanner
|
2019-10-22 00:24:54 +00:00
|
|
|
class PathPlanner
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PathPlanner(){}
|
|
|
|
void calculate(){
|
2021-10-28 13:26:15 +00:00
|
|
|
printf("calculate path\n");
|
2019-10-22 00:24:54 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-28 13:26:15 +00:00
|
|
|
// 适配器类Adapter
|
2019-10-22 00:24:54 +00:00
|
|
|
class Adapter:public Controller
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Adapter(){
|
|
|
|
dxfParser = new DxfParser();
|
|
|
|
pathPlanner = new PathPlanner();
|
|
|
|
}
|
2021-10-28 13:21:56 +00:00
|
|
|
~Adapter(){
|
|
|
|
delete dxfParser;
|
|
|
|
delete pathPlanner;
|
|
|
|
}
|
|
|
|
Adapter(const Adapter& other) = delete;
|
|
|
|
Adapter& operator=(const Adapter& ) = delete;
|
2019-10-22 00:24:54 +00:00
|
|
|
void pathPlanning(){
|
2021-10-28 13:26:15 +00:00
|
|
|
printf("pathPlanning\n");
|
2019-10-22 00:24:54 +00:00
|
|
|
dxfParser->parseFile();
|
|
|
|
pathPlanner->calculate();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
DxfParser *dxfParser;
|
|
|
|
PathPlanner *pathPlanner;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__SINGLETON_H__
|