mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
chore: use method static array for zoneloaderfactory
This commit is contained in:
27
src/ZoneLoading/Loading/IZoneLoaderFactory.cpp
Normal file
27
src/ZoneLoading/Loading/IZoneLoaderFactory.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "IZoneLoaderFactory.h"
|
||||
|
||||
#include "Game/IW3/ZoneLoaderFactoryIW3.h"
|
||||
#include "Game/IW4/ZoneLoaderFactoryIW4.h"
|
||||
#include "Game/IW5/ZoneLoaderFactoryIW5.h"
|
||||
#include "Game/T5/ZoneLoaderFactoryT5.h"
|
||||
#include "Game/T6/ZoneLoaderFactoryT6.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
const IZoneLoaderFactory* IZoneLoaderFactory::GetZoneLoaderFactoryForGame(GameId game)
|
||||
{
|
||||
static const IZoneLoaderFactory* zoneCreators[static_cast<unsigned>(GameId::COUNT)]{
|
||||
new IW3::ZoneLoaderFactory(),
|
||||
new IW4::ZoneLoaderFactory(),
|
||||
new IW5::ZoneLoaderFactory(),
|
||||
new T5::ZoneLoaderFactory(),
|
||||
new T6::ZoneLoaderFactory(),
|
||||
};
|
||||
static_assert(std::extent_v<decltype(zoneCreators)> == static_cast<unsigned>(GameId::COUNT));
|
||||
|
||||
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
|
||||
const auto* result = zoneCreators[static_cast<unsigned>(game)];
|
||||
assert(result);
|
||||
|
||||
return result;
|
||||
}
|
@ -3,6 +3,8 @@
|
||||
#include "Zone/ZoneTypes.h"
|
||||
#include "ZoneLoader.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class IZoneLoaderFactory
|
||||
{
|
||||
public:
|
||||
@ -13,5 +15,7 @@ public:
|
||||
IZoneLoaderFactory& operator=(const IZoneLoaderFactory& other) = default;
|
||||
IZoneLoaderFactory& operator=(IZoneLoaderFactory&& other) noexcept = default;
|
||||
|
||||
virtual ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) = 0;
|
||||
virtual std::unique_ptr<ZoneLoader> CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) const = 0;
|
||||
|
||||
static const IZoneLoaderFactory* GetZoneLoaderFactoryForGame(GameId game);
|
||||
};
|
||||
|
Reference in New Issue
Block a user