新建了策略控制基类

实现了三种策略的策略控制类
This commit is contained in:
2022-06-27 13:59:58 +08:00
parent ce7986b5a6
commit ad37da5974
8 changed files with 492 additions and 0 deletions

19
include/BusFCFSStrategy.h Normal file
View File

@@ -0,0 +1,19 @@
//
// Created by ricardo on 2022/6/27.
//
#ifndef AUTO_BUS_GUI_BUS_FCFS_STRATEGY_H
#define AUTO_BUS_GUI_BUS_FCFS_STRATEGY_H
#include "BusStrategyBase.h"
class BusFCFSStrategy : public BusStrategyBase
{
int GetBusDirection(bus_query_t *query);
bus_query_t *GetTargetQuery();
bus_query_t *HandleQuery();
};
#endif //AUTO_BUS_GUI_BUS_FCFS_STRATEGY_H

21
include/BusSCANStrategy.h Normal file
View File

@@ -0,0 +1,21 @@
//
// Created by ricardo on 2022/6/27.
//
#ifndef AUTO_BUS_GUI_BUS_SCAN_STRATEGY_H
#define AUTO_BUS_GUI_BUS_SCAN_STRATEGY_H
#include "BusStrategyBase.h"
class BusSCANStrategy : public BusStrategyBase
{
int GetBusDirection(bus_query_t *query);
bus_query_t *GetTargetQuery();
bus_query_t *HandleQuery();
};
#endif //AUTO_BUS_GUI_BUS_SCAN_STRATEGY_H

19
include/BusSSTFStrategy.h Normal file
View File

@@ -0,0 +1,19 @@
//
// Created by ricardo on 2022/6/27.
//
#ifndef AUTO_BUS_GUI_BUS_SSTF_STRATEGY_H
#define AUTO_BUS_GUI_BUS_SSTF_STRATEGY_H
#include "BusStrategyBase.h"
class BusSSTFStrategy : public BusStrategyBase
{
int GetBusDirection(bus_query_t *query);
bus_query_t *GetTargetQuery();
bus_query_t *HandleQuery();
};
#endif //AUTO_BUS_GUI_BUS_SSTF_STRATEGY_H

40
include/BusStrategyBase.h Normal file
View File

@@ -0,0 +1,40 @@
//
// Created by ricardo on 2022/6/27.
//
#ifndef AUTO_BUS_GUI_BUS_CONTROLLER_BASE_H
#define AUTO_BUS_GUI_BUS_CONTROLLER_BASE_H
#include "QObject"
#include "QString"
#include "railsModel.h"
#include "queryModel.h"
#include "busModel.h"
class BusStrategyBase : public QObject
{
Q_OBJECT
public:
RailsModel *rails_model;
QueryModel *query_model;
BusModel *bus_model;
int bus_tick;
BusStrategyBase();
virtual ~BusStrategyBase();
virtual int GetBusDirection(bus_query_t *query) = 0;
virtual bus_query_t *GetTargetQuery() = 0;
virtual bus_query_t *HandleQuery() = 0;
private:
QString PrintState() const;
};
#endif //AUTO_BUS_GUI_BUS_CONTROLLER_BASE_H