#pragma once

// C++ system level
#include <map>
#include <vector>
// #include <cstring>     // memset, strncmp
// #include <cstdlib>     // TODO: is this for memcpy?
// #include <functional>

// ESP32 specific
#include "esp_log.h"

// project specific
#include <Types.hpp>
#include "Service.hpp"

// qthing stuff
// #include <qthing>


namespace SiliconTorch {

  namespace ServiceManager {

    extern const str NVSStateKey;


    using ServiceMap = std::map<str, Service*>;


    class ServiceManager {
      public:

        ServiceManager();

        u32 startEnabledServices();

        void printServiceTable() const;

        void setServiceEnabled(const str& name, bool enabled);
        bool getServiceEnabled(const str& name) const;


        std::vector<Service*> getServicesInStartOrder() const;


        void registerService(Service* s);

      private:

        bool registrationLocked = false;
        ServiceMap serviceMap;

    };


  }
}