37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
// Copyright (C) 2012 Jérôme Leclercq
|
|
// This file is part of the "Nazara Engine - Utility module"
|
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
|
|
|
#pragma once
|
|
|
|
#ifndef NAZARA_RESOURCELOADER_HPP
|
|
#define NAZARA_RESOURCELOADER_HPP
|
|
|
|
#include <Nazara/Core/String.hpp>
|
|
#include <set>
|
|
#include <tuple>
|
|
|
|
class NzInputStream;
|
|
|
|
template<typename Type, typename Parameters>
|
|
class NzResourceLoader
|
|
{
|
|
public:
|
|
using CheckFunction = bool (*)(NzInputStream& stream, const Parameters& parameters);
|
|
using LoadFunction = bool (*)(Type* resource, NzInputStream& stream, const Parameters& parameters);
|
|
|
|
static bool LoadFromFile(Type* resource, const NzString& filePath, const Parameters& parameters = Parameters());
|
|
static bool LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters = Parameters());
|
|
static bool LoadFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters = Parameters());
|
|
|
|
static void RegisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadfunc);
|
|
static void UnregisterLoader(const NzString& fileExtensions, CheckFunction checkFunc, LoadFunction loadfunc);
|
|
|
|
using Loader = std::tuple<std::set<NzString>, CheckFunction, LoadFunction>;
|
|
using LoaderList = std::set<Loader>;
|
|
};
|
|
|
|
#include <Nazara/Core/ResourceLoader.inl>
|
|
|
|
#endif // NAZARA_RESOURCELOADER_HPP
|