mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-02 15:07:26 +00:00
chore: use method static array for zonewriterfactory
This commit is contained in:
27
src/ZoneWriting/Writing/IZoneWriterFactory.cpp
Normal file
27
src/ZoneWriting/Writing/IZoneWriterFactory.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "IZoneWriterFactory.h"
|
||||
|
||||
#include "Game/IW3/ZoneWriterFactoryIW3.h"
|
||||
#include "Game/IW4/ZoneWriterFactoryIW4.h"
|
||||
#include "Game/IW5/ZoneWriterFactoryIW5.h"
|
||||
#include "Game/T5/ZoneWriterFactoryT5.h"
|
||||
#include "Game/T6/ZoneWriterFactoryT6.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
const IZoneWriterFactory* IZoneWriterFactory::GetZoneWriterFactoryForGame(GameId game)
|
||||
{
|
||||
static const IZoneWriterFactory* zoneCreators[static_cast<unsigned>(GameId::COUNT)]{
|
||||
new IW3::ZoneWriterFactory(),
|
||||
new IW4::ZoneWriterFactory(),
|
||||
new IW5::ZoneWriterFactory(),
|
||||
new T5::ZoneWriterFactory(),
|
||||
new T6::ZoneWriterFactory(),
|
||||
};
|
||||
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;
|
||||
}
|
@@ -14,6 +14,7 @@ public:
|
||||
IZoneWriterFactory& operator=(const IZoneWriterFactory& other) = default;
|
||||
IZoneWriterFactory& operator=(IZoneWriterFactory&& other) noexcept = default;
|
||||
|
||||
_NODISCARD virtual bool SupportsZone(Zone* zone) const = 0;
|
||||
_NODISCARD virtual std::unique_ptr<ZoneWriter> CreateWriter(Zone* zone) const = 0;
|
||||
|
||||
static const IZoneWriterFactory* GetZoneWriterFactoryForGame(GameId game);
|
||||
};
|
||||
|
Reference in New Issue
Block a user