Use factory method to create mouse controller on Linux

This commit is contained in:
dijunkun
2023-12-14 16:27:13 +08:00
parent bfecf47226
commit daecc0d1e9
6 changed files with 306 additions and 75 deletions

View File

@@ -0,0 +1,33 @@
/*
* @Author: DI JUNKUN
* @Date: 2023-12-14
* Copyright (c) 2023 by DI JUNKUN, All Rights Reserved.
*/
#ifndef _DEVICE_CONTROLLER_FACTORY_H_
#define _DEVICE_CONTROLLER_FACTORY_H_
#include "device_controller.h"
#include "mouse_controller.h"
class DeviceControllerFactory {
public:
enum Device { Mouse, Keyboard };
public:
virtual ~DeviceControllerFactory() {}
public:
DeviceController* Create(Device device) {
switch (device) {
case Mouse:
return new MouseController();
case Keyboard:
return nullptr;
default:
return nullptr;
}
}
};
#endif