docs(src): added documentation to all changes related to the resource manager
This commit is contained in:
@@ -11,11 +11,30 @@
|
||||
#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");
|
||||
@@ -24,24 +43,73 @@ private:
|
||||
std::string m_dataDir;
|
||||
std::unordered_map<std::string, Resource> 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<std::string> resources = manager.getAvaliableResources();
|
||||
* @endcode
|
||||
*/
|
||||
std::vector<std::string> 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<std::string, bool> results = manager.loadAllResources();
|
||||
* @endcode
|
||||
*/
|
||||
std::unordered_map<std::string, bool> loadAllResources();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // RESOURCE_MANAGER_H
|
||||
Reference in New Issue
Block a user