Skip to content

Commit

Permalink
[#26]: Remove dead code in FileManager
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Aug 1, 2021
1 parent 8932306 commit 51846b9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 59 deletions.
36 changes: 0 additions & 36 deletions engine/FileManager/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,6 @@ FileManager::LoadImageData(const std::string& fileName)
return {std::move(textureData), {w, h}, n};
}

uint8_t*
FileManager::LoadImageRawBytes(const std::string& fileName)
{
const auto pathToImage = std::filesystem::path(IMAGES_DIR / fileName).string();
int force_channels = 0;
int w, h, n;

uint8_t* textureData = stbi_load(pathToImage.c_str(), &w, &h, &n, force_channels);

if (!textureData)
{
m_logger.Log(Logger::Type::FATAL,
"FileManager::LoadImageRawBytes -> " + pathToImage + " can't be opened!");
}

return textureData;
}

FileManager::ImageRaw
FileManager::LoadImageRawData(const std::string& fileName)
{
const auto pathToImage = std::filesystem::path(IMAGES_DIR / fileName).string();
int force_channels = 0;
int w, h, n;

uint8_t* textureData = stbi_load(pathToImage.c_str(), &w, &h, &n, force_channels);

if (!textureData)
{
m_logger.Log(Logger::Type::FATAL,
"FileManager::LoadImageRawData -> " + pathToImage + " can't be opened!");
}

return {textureData, {w, h}, n};
}

nlohmann::json
FileManager::LoadJsonFile(const std::string& pathToFile)
{
Expand Down
16 changes: 0 additions & 16 deletions engine/FileManager/FileManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class FileManager

using ImageHandleType = std::unique_ptr< uint8_t[], std::function< void(uint8_t*) > >;
using ImageSmart = ImageData< ImageHandleType >;
using ImageRaw = ImageData< uint8_t* >;

enum class FileType
{
Expand All @@ -39,24 +38,9 @@ class FileManager
static std::string
ReadFile(const std::string& fileName, FileType type = FileType::TEXT);

static void
WriteToFile(const std::string& fileName, FileType type = FileType::TEXT);

// NOTE!
// image data is not freed
// TODO: Handle freeing the data
static uint8_t*
LoadImageRawBytes(const std::string& fileName);

static ImageSmart
LoadImageData(const std::string& fileName);

// NOTE!
// image data is not freed
// TODO: Handle freeing the data
static ImageRaw
LoadImageRawData(const std::string& fileName);

static nlohmann::json
LoadJsonFile(const std::string& pathToFile);

Expand Down
4 changes: 1 addition & 3 deletions engine/Logger/Logger.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "Logger.hpp"

#include <iostream>

namespace dgame {

Logger::Logger(const std::string& name) : m_moduleName(name)
Expand All @@ -15,7 +13,7 @@ Logger::Init(const std::string& name)
}

std::string
Logger::ToString(const Logger::Type& type) const
Logger::ToString(Logger::Type type) const
{
std::string returnValue;

Expand Down
8 changes: 4 additions & 4 deletions engine/Logger/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Logger

explicit Logger(const std::string& name);
Logger() = default;
~Logger() = default;

void
Init(const std::string& name);
Expand All @@ -37,14 +36,15 @@ class Logger
}
}

static void SetLogType(Type);
static void
SetLogType(Type type);

std::string
ToString(const Logger::Type& type) const;
ToString(Type type) const;

private:
std::string m_moduleName;
static inline Type m_currentLogType = Logger::Type::DEBUG;
static inline Type m_currentLogType = Type::DEBUG;
};

} // namespace dgame

0 comments on commit 51846b9

Please sign in to comment.