mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Update Linker and Unlinker tool to use virtual functions directly instead of internal impl pointer
This commit is contained in:
parent
3c2774614f
commit
0da6a4dc43
@ -40,7 +40,7 @@ const IZoneCreator* const ZONE_CREATORS[]
|
|||||||
new T6::ZoneCreator()
|
new T6::ZoneCreator()
|
||||||
};
|
};
|
||||||
|
|
||||||
class Linker::Impl
|
class LinkerImpl final : public Linker
|
||||||
{
|
{
|
||||||
static constexpr const char* METADATA_GAME = "game";
|
static constexpr const char* METADATA_GAME = "game";
|
||||||
static constexpr const char* METADATA_GDT = "gdt";
|
static constexpr const char* METADATA_GDT = "gdt";
|
||||||
@ -543,13 +543,7 @@ class Linker::Impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Impl()
|
bool Start(const int argc, const char** argv) override
|
||||||
= default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \copydoc Linker::Start
|
|
||||||
*/
|
|
||||||
bool Start(const int argc, const char** argv)
|
|
||||||
{
|
{
|
||||||
if (!m_args.ParseArgs(argc, argv))
|
if (!m_args.ParseArgs(argc, argv))
|
||||||
return false;
|
return false;
|
||||||
@ -576,18 +570,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Linker::Linker()
|
std::unique_ptr<Linker> Linker::Create()
|
||||||
{
|
{
|
||||||
m_impl = new Impl();
|
return std::make_unique<LinkerImpl>();
|
||||||
}
|
|
||||||
|
|
||||||
Linker::~Linker()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Linker::Start(const int argc, const char** argv) const
|
|
||||||
{
|
|
||||||
return m_impl->Start(argc, argv);
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Linker
|
class Linker
|
||||||
{
|
{
|
||||||
class Impl;
|
|
||||||
Impl* m_impl;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Linker();
|
Linker() = default;
|
||||||
~Linker();
|
virtual ~Linker() = default;
|
||||||
|
|
||||||
Linker(const Linker& other) = delete;
|
Linker(const Linker& other) = default;
|
||||||
Linker(Linker&& other) noexcept = delete;
|
Linker(Linker&& other) noexcept = default;
|
||||||
Linker& operator=(const Linker& other) = delete;
|
Linker& operator=(const Linker& other) = default;
|
||||||
Linker& operator=(Linker&& other) noexcept = delete;
|
Linker& operator=(Linker&& other) noexcept = default;
|
||||||
|
|
||||||
|
static std::unique_ptr<Linker> Create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Starts the Linker application logic.
|
* \brief Starts the Linker application logic.
|
||||||
@ -20,5 +21,5 @@ public:
|
|||||||
* \param argv The command line arguments.
|
* \param argv The command line arguments.
|
||||||
* \return \c true if the application was successful or \c false if an error occurred.
|
* \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;
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
int main(const int argc, const char** argv)
|
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;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ const IZoneDefWriter* const ZONE_DEF_WRITERS[]
|
|||||||
new T6::ZoneDefWriter()
|
new T6::ZoneDefWriter()
|
||||||
};
|
};
|
||||||
|
|
||||||
class Unlinker::Impl
|
class UnlinkerImpl final : public Unlinker
|
||||||
{
|
{
|
||||||
UnlinkerArgs m_args;
|
UnlinkerArgs m_args;
|
||||||
SearchPaths m_search_paths;
|
SearchPaths m_search_paths;
|
||||||
@ -403,7 +403,7 @@ class Unlinker::Impl
|
|||||||
if (ShouldLoadObj())
|
if (ShouldLoadObj())
|
||||||
{
|
{
|
||||||
ObjLoading::LoadReferencedContainersForZone(&searchPathsForZone, zone.get());
|
ObjLoading::LoadReferencedContainersForZone(&searchPathsForZone, zone.get());
|
||||||
ObjLoading::LoadObjDataForZone(&searchPathsForZone, zone.get());
|
ObjLoading::LoadObjDataForZone(&searchPathsForZone, zone.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HandleZone(zone.get()))
|
if (!HandleZone(zone.get()))
|
||||||
@ -421,15 +421,12 @@ class Unlinker::Impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Impl()
|
UnlinkerImpl()
|
||||||
{
|
{
|
||||||
m_last_zone_search_path = nullptr;
|
m_last_zone_search_path = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
bool Start(const int argc, const char** argv) override
|
||||||
* \copydoc Unlinker::Start
|
|
||||||
*/
|
|
||||||
bool Start(const int argc, const char** argv)
|
|
||||||
{
|
{
|
||||||
if (!m_args.ParseArgs(argc, argv))
|
if (!m_args.ParseArgs(argc, argv))
|
||||||
return false;
|
return false;
|
||||||
@ -447,18 +444,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Unlinker::Unlinker()
|
std::unique_ptr<Unlinker> Unlinker::Create()
|
||||||
{
|
{
|
||||||
m_impl = new Impl();
|
return std::make_unique<UnlinkerImpl>();
|
||||||
}
|
|
||||||
|
|
||||||
Unlinker::~Unlinker()
|
|
||||||
{
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Unlinker::Start(const int argc, const char** argv) const
|
|
||||||
{
|
|
||||||
return m_impl->Start(argc, argv);
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Unlinker
|
class Unlinker
|
||||||
{
|
{
|
||||||
class Impl;
|
|
||||||
Impl* m_impl;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Unlinker();
|
Unlinker() = default;
|
||||||
~Unlinker();
|
virtual ~Unlinker() = default;
|
||||||
|
|
||||||
Unlinker(const Unlinker& other) = delete;
|
Unlinker(const Unlinker& other) = default;
|
||||||
Unlinker(Unlinker&& other) noexcept = delete;
|
Unlinker(Unlinker&& other) noexcept = default;
|
||||||
Unlinker& operator=(const Unlinker& other) = delete;
|
Unlinker& operator=(const Unlinker& other) = default;
|
||||||
Unlinker& operator=(Unlinker&& other) noexcept = delete;
|
Unlinker& operator=(Unlinker&& other) noexcept = default;
|
||||||
|
|
||||||
|
static std::unique_ptr<Unlinker> Create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Starts the Unlinker application logic.
|
* \brief Starts the Unlinker application logic.
|
||||||
@ -20,5 +21,5 @@ public:
|
|||||||
* \param argv The command line arguments.
|
* \param argv The command line arguments.
|
||||||
* \return \c true if the application was successful or \c false if an error occurred.
|
* \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;
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
int main(const int argc, const char** argv)
|
int main(const int argc, const char** argv)
|
||||||
{
|
{
|
||||||
Unlinker unlinker;
|
const auto unlinker = Unlinker::Create();
|
||||||
|
|
||||||
return unlinker.Start(argc, argv) ? 0 : 1;
|
return unlinker->Start(argc, argv) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user