新建了策略控制基类
实现了三种策略的策略控制类
This commit is contained in:
19
include/BusFCFSStrategy.h
Normal file
19
include/BusFCFSStrategy.h
Normal 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
21
include/BusSCANStrategy.h
Normal 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
19
include/BusSSTFStrategy.h
Normal 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
40
include/BusStrategyBase.h
Normal 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
|
Reference in New Issue
Block a user