38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#ifndef __JABYENGINE_FILE_PROCESSOR_HPP__
|
|
#define __JABYENGINE_FILE_PROCESSOR_HPP__
|
|
#include "../File_Types.hpp"
|
|
|
|
namespace FileProcessor {
|
|
class State {
|
|
private:
|
|
struct Reserved {
|
|
uint32_t reserved[2];
|
|
};
|
|
|
|
struct Configuration;
|
|
typedef bool (*ProcessRoutine)(Configuration&, Reserved&, size_t);
|
|
|
|
struct Configuration {
|
|
ProcessRoutine process_routine = nullptr;
|
|
const uint32_t* data_adr = nullptr;
|
|
|
|
template<typename T>
|
|
static __always_inline Configuration from(bool (*process_routine)(Configuration&, T&, size_t), const uint32_t* data_adr) {
|
|
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
|
}
|
|
};
|
|
|
|
private:
|
|
Configuration config;
|
|
Reserved reserved;
|
|
|
|
public:
|
|
bool process(size_t size) {
|
|
return (*this->config.process_routine)(this->config, this->reserved, size);
|
|
}
|
|
};
|
|
|
|
State create(const uint32_t* data_adr, const SimpleTIM& file);
|
|
}
|
|
|
|
#endif // !__JABYENGINE_FILE_PROCESSOR_HPP__
|