#ifndef RESOURCE_MANAGER_H #define RESOURCE_MANAGER_H #include #include #include #include #include "resourceManagerTypes.h" #include "config.h" #include "probe.h" #include "quill/LogMacros.h" /** * @class ResourceManager * @brief Manages resources within the application. * * The ResourceManager class is responsible for loading, storing, and providing access to resources. * It follows the Singleton design pattern to ensure only one instance of the manager exists. */ class ResourceManager { private: /** * @brief Private constructor to prevent instantiation. */ ResourceManager(); /** * @brief Deleted copy constructor to prevent copying. */ ResourceManager(const ResourceManager&) = delete; /** * @brief Deleted assignment operator to prevent assignment. */ ResourceManager& operator=(const ResourceManager&) = delete; Config& m_config = Config::getInstance(); Probe::LogManager& m_logManager = Probe::LogManager::getInstance(); quill::Logger* m_logger = m_logManager.getLogger("log"); Config m_resourceConfig; std::string m_dataDir; std::unordered_map m_resources; /** * @brief Loads a resource by name. * @param name The name of the resource to load. * @return True if the resource was loaded successfully, false otherwise. */ bool load(const std::string& name); public: /** * @brief Gets the singleton instance of the ResourceManager. * @return The singleton instance of the ResourceManager. */ static ResourceManager& getInstance() { static ResourceManager instance; return instance; } /** * @brief Gets a list of available resources. * @return A vector of strings containing the names of available resources. * * Example usage: * @code * ResourceManager& manager = ResourceManager::getInstance(); * std::vector resources = manager.getAvaliableResources(); * @endcode */ std::vector getAvaliableResources(); /** * @brief Gets a resource by name. * @param name The name of the resource to retrieve. * @return A constant reference to the requested resource. * @throws std::runtime_error if the resource is not found. * * Example usage: * @code * ResourceManager& manager = ResourceManager::getInstance(); * const Resource& resource = manager.getResource("exampleResource"); * @endcode */ const Resource& getResource(const std::string &name) const; /** * @brief Loads a resource by name. * @param name The name of the resource to load. * @return True if the resource was loaded successfully, false otherwise. * * Example usage: * @code * ResourceManager& manager = ResourceManager::getInstance(); * bool success = manager.loadResource("exampleResource"); * @endcode */ bool loadResource(std::string& name); /** * @brief Loads all resources. * @return An unordered map with resource names as keys and load success as values. * * Example usage: * @code * ResourceManager& manager = ResourceManager::getInstance(); * std::unordered_map results = manager.loadAllResources(); * @endcode */ std::unordered_map loadAllResources(); }; #endif // RESOURCE_MANAGER_H