2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-11 13:41:50 +00:00

Use unique_ptr for ZoneLoading

This commit is contained in:
Jan
2021-03-14 12:34:50 +01:00
parent 94230cefb0
commit 301f6e3e7a
14 changed files with 118 additions and 153 deletions

View File

@ -1,15 +1,9 @@
#include "StepAddProcessor.h"
#include <cassert>
StepAddProcessor::StepAddProcessor(StreamProcessor* streamProcessor)
StepAddProcessor::StepAddProcessor(std::unique_ptr<StreamProcessor> streamProcessor)
: m_stream_processor(std::move(streamProcessor))
{
m_stream_processor = streamProcessor;
}
StepAddProcessor::~StepAddProcessor()
{
delete m_stream_processor;
m_stream_processor = nullptr;
}
void StepAddProcessor::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
@ -17,6 +11,6 @@ void StepAddProcessor::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* strea
assert(zoneLoader != nullptr);
assert(m_stream_processor != nullptr);
zoneLoader->AddStreamProcessor(m_stream_processor);
zoneLoader->AddStreamProcessor(std::move(m_stream_processor));
m_stream_processor = nullptr;
}

View File

@ -1,14 +1,15 @@
#pragma once
#include <memory>
#include "Loading/ILoadingStep.h"
class StepAddProcessor final : public ILoadingStep
{
StreamProcessor* m_stream_processor;
std::unique_ptr<StreamProcessor> m_stream_processor;
public:
explicit StepAddProcessor(StreamProcessor* streamProcessor);
~StepAddProcessor() override;
explicit StepAddProcessor(std::unique_ptr<StreamProcessor> streamProcessor);
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
};

View File

@ -2,18 +2,12 @@
#include "Zone/Stream/Impl/XBlockInputStream.h"
#include <cassert>
StepLoadZoneContent::StepLoadZoneContent(IContentLoadingEntryPoint* entryPoint, Zone* zone, const int offsetBlockBitCount, const block_t insertBlock)
StepLoadZoneContent::StepLoadZoneContent(std::unique_ptr<IContentLoadingEntryPoint> entryPoint, Zone* zone, const int offsetBlockBitCount, const block_t insertBlock)
: m_content_loader(std::move(entryPoint)),
m_zone(zone),
m_offset_block_bit_count(offsetBlockBitCount),
m_insert_block(insertBlock)
{
m_content_loader = entryPoint;
m_zone = zone;
m_offset_block_bit_count = offsetBlockBitCount;
m_insert_block = insertBlock;
}
StepLoadZoneContent::~StepLoadZoneContent()
{
delete m_content_loader;
m_content_loader = nullptr;
}
void StepLoadZoneContent::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
@ -23,4 +17,4 @@ void StepLoadZoneContent::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* st
m_content_loader->Load(m_zone, inputStream);
delete inputStream;
}
}

View File

@ -1,18 +1,19 @@
#pragma once
#include <memory>
#include "Loading/ILoadingStep.h"
#include "Loading/IContentLoadingEntryPoint.h"
class StepLoadZoneContent final : public ILoadingStep
{
IContentLoadingEntryPoint* m_content_loader;
std::unique_ptr<IContentLoadingEntryPoint> m_content_loader;
Zone* m_zone;
int m_offset_block_bit_count;
block_t m_insert_block;
public:
StepLoadZoneContent(IContentLoadingEntryPoint* entryPoint, Zone* zone, int offsetBlockBitCount, block_t insertBlock);
~StepLoadZoneContent();
StepLoadZoneContent(std::unique_ptr<IContentLoadingEntryPoint> entryPoint, Zone* zone, int offsetBlockBitCount, block_t insertBlock);
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
};