refactor(resource): increased const correctness
This commit is contained in:
@@ -35,10 +35,10 @@
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
|
||||
ResourceManager::ResourceManager() {
|
||||
std::string defaultDataDir = TOSTRING(DATA_DIR);
|
||||
const std::string defaultDataDir = TOSTRING(DATA_DIR);
|
||||
m_dataDir = m_config.get<std::string>("Data:Dir", defaultDataDir);
|
||||
// -- Get the index file path using filesytem to make it a system safe path
|
||||
std::string indexFilePath = m_dataDir + "/index.yaml";
|
||||
const std::string indexFilePath = m_dataDir + "/index.yaml";
|
||||
// TODO Add checks to make sure data dir exists and index.yaml exists
|
||||
const std::filesystem::path indexFile(indexFilePath);
|
||||
|
||||
@@ -49,15 +49,13 @@ ResourceManager::ResourceManager() {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> ResourceManager::getAvaliableResources() {
|
||||
std::vector<std::string> resources;
|
||||
resources = m_resourceConfig.keys();
|
||||
std::vector<std::string> ResourceManager::getAvaliableResources() const {
|
||||
const std::vector<std::string> resources = m_resourceConfig.keys();
|
||||
return resources;
|
||||
}
|
||||
|
||||
const Resource& ResourceManager::getResource(const std::string &name) const {
|
||||
auto it = m_resources.find(name);
|
||||
if (it != m_resources.end()) {
|
||||
if (const auto it = m_resources.find(name); it != m_resources.end()) {
|
||||
return it->second;
|
||||
}
|
||||
throw std::runtime_error("Resource " + name + " not found");
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
* std::vector<std::string> resources = manager.getAvaliableResources();
|
||||
* @endcode
|
||||
*/
|
||||
std::vector<std::string> getAvaliableResources();
|
||||
std::vector<std::string> getAvaliableResources() const;
|
||||
|
||||
/**
|
||||
* @brief Gets a resource by name.
|
||||
|
||||
Reference in New Issue
Block a user