feat: directory-based resource resolver

This commit is contained in:
maelstrom 2026-06-02 11:27:44 +02:00
commit 656549f039
12 changed files with 223 additions and 11 deletions

View file

@ -5,25 +5,35 @@
namespace fishbone {
class Client;
};
class ResourceResolver;
}; // namespace fishbone
#include <fishbone/sound.h>
#include <fishbone/window.h>
#include <fishbone/mixer.h>
#include <fishbone/draw.h>
#include <fishbone/logger.h>
namespace fishbone {
class Client {
class BaseEngine : public Logger {
protected:
ResourceResolver* resourceResolver;
public:
ResourceResolver* getResourceResolver();
};
class Client : public BaseEngine {
public:
Client(std::unordered_map<std::string, std::vector<std::string>> param);
~Client();
bool step();
fishbone::Window* window;
fishbone::SoundDriver* sounddrv;
fishbone::Mixer* mixer;
fishbone::Renderer* renderer;
fishbone::Mixer* mixer;
fishbone::Renderer* renderer;
};
}; // namespace fishbone

View file

@ -0,0 +1,23 @@
#ifndef __FISHBONE_LOGGER_H__
#define __FISHBONE_LOGGER_H__
#include <fishbone/pre.h>
namespace fishbone {
class Logger {
public:
enum class Cause {
INFO,
DEBUG,
WARNING,
ERROR,
CRITICAL,
};
void log(std::string message);
void log(Cause cause, std::string message);
};
} // namespace fishbone
#endif

View file

@ -1,21 +1,47 @@
#ifndef __FISHBONE_THREAD_H__
#define __FISHBONE_THREAD_H__
#ifndef __FISHBONE_RESOURCE_H__
#define __FISHBONE_RESOURCE_H__
#include <fishbone/pre.h>
namespace fishbone {
class Resource;
class BaseEngine;
}; // namespace fishbone
#include <fishbone/file.h>
namespace fishbone {
class ResourceResolver {
public:
virtual bool exists(std::string path) = 0;
virtual size_t getSize(std::string path) = 0;
virtual bool copyData(std::string path, char* buffer, size_t maxSize) = 0;
};
class DirectoryResourceResolver : public ResourceResolver {
std::vector<std::string> searchPaths;
std::string findAbsolutePath(std::string path);
public:
DirectoryResourceResolver(std::vector<std::string> searchPaths);
bool exists(std::string path) override;
size_t getSize(std::string path) override;
bool copyData(std::string path, char* buffer, size_t maxSize) override;
};
class Resource {
char* buffer;
size_t bufferSize;
public:
fishbone::File* open(std::string path);
Resource(std::string path);
Resource(BaseEngine* engine, std::string path);
~Resource();
char* getBuffer();
size_t getSize();
};
}; // namespace fishbone