#pragma once

#include "../Common/can_mv.hpp"
#include "../Common/df_player.hpp"
#include "../Common/ultrasonic.hpp"
#include "../config.hpp"

class CommonCenter {
public:
    static Ultrasonic& GetUltrasonic() {
        static Ultrasonic* instance = nullptr;
        if (instance == nullptr) {
            instance = new Ultrasonic(
                Config::kCaptureConfig.trigger, Config::kCaptureConfig.timer, Config::kCaptureConfig.channel);
        }
        return *instance;
    }

    static DfPlayer& GetDfPlayer() {
        static DfPlayer* instance = nullptr;
        if (instance == nullptr) {
            instance = new DfPlayer(Config::kDfPlayerUart);
        }
        return *instance;
    }

    static CanMv& GetCanMv() {
        static CanMv* instance = nullptr;
        if (instance == nullptr) {
            instance = new CanMv(Config::kCanMvUart);
        }
        return *instance;
    }
};
