2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-03 17:51:54 +00:00

Update Linker and Unlinker tool to use virtual functions directly instead of internal impl pointer

This commit is contained in:
Jan
2023-06-19 21:15:43 +02:00
parent 3c2774614f
commit 0da6a4dc43
6 changed files with 38 additions and 67 deletions

View File

@ -40,7 +40,7 @@ const IZoneCreator* const ZONE_CREATORS[]
new T6::ZoneCreator()
};
class Linker::Impl
class LinkerImpl final : public Linker
{
static constexpr const char* METADATA_GAME = "game";
static constexpr const char* METADATA_GDT = "gdt";
@ -543,13 +543,7 @@ class Linker::Impl
}
public:
Impl()
= default;
/**
* \copydoc Linker::Start
*/
bool Start(const int argc, const char** argv)
bool Start(const int argc, const char** argv) override
{
if (!m_args.ParseArgs(argc, argv))
return false;
@ -576,18 +570,7 @@ public:
}
};
Linker::Linker()
std::unique_ptr<Linker> Linker::Create()
{
m_impl = new Impl();
}
Linker::~Linker()
{
delete m_impl;
m_impl = nullptr;
}
bool Linker::Start(const int argc, const char** argv) const
{
return m_impl->Start(argc, argv);
return std::make_unique<LinkerImpl>();
}

View File

@ -1,18 +1,19 @@
#pragma once
#include <memory>
class Linker
{
class Impl;
Impl* m_impl;
public:
Linker();
~Linker();
Linker() = default;
virtual ~Linker() = default;
Linker(const Linker& other) = delete;
Linker(Linker&& other) noexcept = delete;
Linker& operator=(const Linker& other) = delete;
Linker& operator=(Linker&& other) noexcept = delete;
Linker(const Linker& other) = default;
Linker(Linker&& other) noexcept = default;
Linker& operator=(const Linker& other) = default;
Linker& operator=(Linker&& other) noexcept = default;
static std::unique_ptr<Linker> Create();
/**
* \brief Starts the Linker application logic.
@ -20,5 +21,5 @@ public:
* \param argv The command line arguments.
* \return \c true if the application was successful or \c false if an error occurred.
*/
bool Start(int argc, const char** argv) const;
};
virtual bool Start(int argc, const char** argv) = 0;
};

View File

@ -2,7 +2,7 @@
int main(const int argc, const char** argv)
{
Linker linker;
const auto linker = Linker::Create();
return linker.Start(argc, argv) ? 0 : 1;
return linker->Start(argc, argv) ? 0 : 1;
}