#pragma once #if ENABLE_PISTACHE #define DEBUG_SERVER_AVAILABLE #endif #include #include #ifdef DEBUG_SERVER_AVAILABLE namespace Pistache { namespace Rest { class Request; class Router; } namespace Http { class ResponseWriter; } } #endif namespace Debugger { #ifdef DEBUG_SERVER_AVAILABLE struct Service { virtual ~Service() = default; virtual void RegisterRoutes(Pistache::Rest::Router& router) = 0; }; /** * Factory function to create a service of the given type. * Must be specialized by service implementors */ template std::unique_ptr CreateService(); class DebugServerImpl; #endif class DebugServer { #ifdef DEBUG_SERVER_AVAILABLE std::unique_ptr impl; Service& GetService(const std::type_info& service_type) const; #endif public: #ifdef DEBUG_SERVER_AVAILABLE DebugServer(); ~DebugServer(); void Run(unsigned port); template ConcreteService& GetService() const { return static_cast(GetService(typeid(ConcreteService))); } #endif }; } // namespace Debugger