2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-08 04:45:52 +00:00

Merge pull request #8 from lioncash/db

Database: Minor cleanup
This commit is contained in:
Phillip Stephens 2019-08-20 06:56:17 -07:00 committed by GitHub
commit 31e9ee50b9

View File

@ -1,21 +1,17 @@
#pragma once #pragma once
#include <iterator> #include <cassert>
#include <string> #include <cstddef>
#include <cstdint>
#include <cstdio>
#include <functional> #include <functional>
#include <vector> #include <memory>
#include <map> #include <string>
#include <list>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <memory> #include <vector>
#include <atomic>
#include <fstream>
#include <stdint.h>
#include <cassert>
#include "athena/IStreamReader.hpp" #include <logvisor/logvisor.hpp>
#include "logvisor/logvisor.hpp"
#include "hecl.hpp" #include "hecl.hpp"
@ -62,7 +58,7 @@ class IDataSpec {
public: public:
IDataSpec(const DataSpecEntry* specEntry) : m_specEntry(specEntry) {} IDataSpec(const DataSpecEntry* specEntry) : m_specEntry(specEntry) {}
virtual ~IDataSpec() {} virtual ~IDataSpec() = default;
using FCookProgress = std::function<void(const SystemChar*)>; using FCookProgress = std::function<void(const SystemChar*)>;
/** /**
@ -91,43 +87,33 @@ public:
virtual void setThreadProject() {} virtual void setThreadProject() {}
virtual bool canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps) { virtual bool canExtract([[maybe_unused]] const ExtractPassInfo& info,
(void)info; [[maybe_unused]] std::vector<ExtractReport>& reps) {
(void)reps;
LogModule.report(logvisor::Error, fmt("not implemented")); LogModule.report(logvisor::Error, fmt("not implemented"));
return false; return false;
} }
virtual void doExtract(const ExtractPassInfo& info, const MultiProgressPrinter& progress) { virtual void doExtract([[maybe_unused]] const ExtractPassInfo& info,
(void)info; [[maybe_unused]] const MultiProgressPrinter& progress) {}
(void)progress;
}
virtual bool canCook(const ProjectPath& path, blender::Token& btok) { virtual bool canCook([[maybe_unused]] const ProjectPath& path, [[maybe_unused]] blender::Token& btok) {
(void)path;
LogModule.report(logvisor::Error, fmt("not implemented")); LogModule.report(logvisor::Error, fmt("not implemented"));
return false; return false;
} }
virtual const DataSpecEntry* overrideDataSpec(const ProjectPath& path, virtual const DataSpecEntry* overrideDataSpec([[maybe_unused]] const ProjectPath& path,
const Database::DataSpecEntry* oldEntry) const { const DataSpecEntry* oldEntry) const {
(void)path;
return oldEntry; return oldEntry;
} }
virtual void doCook(const ProjectPath& path, const ProjectPath& cookedPath, bool fast, blender::Token& btok, virtual void doCook([[maybe_unused]] const ProjectPath& path, [[maybe_unused]] const ProjectPath& cookedPath,
FCookProgress progress) { [[maybe_unused]] bool fast, [[maybe_unused]] blender::Token& btok,
(void)path; [[maybe_unused]] FCookProgress progress) {}
(void)cookedPath;
(void)fast;
(void)progress;
}
virtual bool canPackage(const ProjectPath& path) { virtual bool canPackage([[maybe_unused]] const ProjectPath& path) {
(void)path;
return false; return false;
} }
virtual void doPackage(const ProjectPath& path, const Database::DataSpecEntry* entry, bool fast, blender::Token& btok, virtual void doPackage([[maybe_unused]] const ProjectPath& path, [[maybe_unused]] const DataSpecEntry* entry,
const MultiProgressPrinter& progress, ClientProcess* cp = nullptr) { [[maybe_unused]] bool fast, [[maybe_unused]] blender::Token& btok,
(void)path; [[maybe_unused]] const MultiProgressPrinter& progress,
} [[maybe_unused]] ClientProcess* cp = nullptr) {}
virtual void interruptCook() {} virtual void interruptCook() {}
@ -190,7 +176,7 @@ protected:
Cafe /**< Swizzled textures and R700 shader objects */ Cafe /**< Swizzled textures and R700 shader objects */
}; };
typedef std::function<void(const void* data, size_t len)> FDataAppender; using FDataAppender = std::function<void(const void* data, size_t len)>;
/** /**
* @brief Optional private method implemented by subclasses to cook objects * @brief Optional private method implemented by subclasses to cook objects
@ -203,14 +189,12 @@ protected:
* Part of the cooking process may include embedding database-refs to dependencies. * Part of the cooking process may include embedding database-refs to dependencies.
* This method should store the 64-bit value provided by IDataObject::id() when doing this. * This method should store the 64-bit value provided by IDataObject::id() when doing this.
*/ */
virtual bool cookObject(FDataAppender dataAppender, DataEndianness endianness, DataPlatform platform) { virtual bool cookObject([[maybe_unused]] FDataAppender dataAppender, [[maybe_unused]] DataEndianness endianness,
(void)dataAppender; [[maybe_unused]] DataPlatform platform) {
(void)endianness;
(void)platform;
return true; return true;
} }
typedef std::function<void(ObjectBase*)> FDepAdder; using FDepAdder = std::function<void(ObjectBase*)>;
/** /**
* @brief Optional private method implemented by CProjectObject subclasses to resolve dependencies * @brief Optional private method implemented by CProjectObject subclasses to resolve dependencies
@ -220,7 +204,7 @@ protected:
* Dependencies registered via this method will eventually have this method called on themselves * Dependencies registered via this method will eventually have this method called on themselves
* as well. This is a non-recursive operation, no need for subclasses to implement recursion-control. * as well. This is a non-recursive operation, no need for subclasses to implement recursion-control.
*/ */
virtual void gatherDeps(FDepAdder depAdder) { (void)depAdder; } virtual void gatherDeps([[maybe_unused]] FDepAdder depAdder) {}
/** /**
* @brief Get a packagable FourCC representation of the object's type * @brief Get a packagable FourCC representation of the object's type
@ -273,7 +257,7 @@ public:
class ConfigFile { class ConfigFile {
SystemString m_filepath; SystemString m_filepath;
std::vector<std::string> m_lines; std::vector<std::string> m_lines;
FILE* m_lockedFile = NULL; FILE* m_lockedFile = nullptr;
public: public:
ConfigFile(const Project& project, SystemStringView name, SystemStringView subdir = _SYS_STR("/.hecl/")); ConfigFile(const Project& project, SystemStringView name, SystemStringView subdir = _SYS_STR("/.hecl/"));
@ -311,7 +295,7 @@ public:
/** /**
* @brief Get the path of project's cooked directory for a specific DataSpec * @brief Get the path of project's cooked directory for a specific DataSpec
* @param DataSpec to retrieve path for * @param spec DataSpec to retrieve path for
* @return project cooked path * @return project cooked path
* *
* The cooked path matches the directory layout of the working directory * The cooked path matches the directory layout of the working directory
@ -320,7 +304,7 @@ public:
/** /**
* @brief Add given file(s) to the database * @brief Add given file(s) to the database
* @param path file or pattern within project * @param paths files or patterns within project
* @return true on success * @return true on success
* *
* This method blocks while object hashing takes place * This method blocks while object hashing takes place