From 780cc2a35217e887c9bba0573be1146505114521 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Wed, 4 Nov 2020 21:46:39 +0100 Subject: Add IModInterface::fileTree(). --- src/modinfo.h | 11 +++++++++++ src/modinforegular.cpp | 2 +- src/modinfowithconflictinfo.cpp | 6 +++--- src/modinfowithconflictinfo.h | 24 ++++++++++++------------ 4 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/modinfo.h b/src/modinfo.h index 7223cece..ad917c17 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -368,6 +368,17 @@ public: // IModInterface implementations / Re-declaration */ virtual MOBase::EndorsedState endorsedState() const override { return MOBase::EndorsedState::ENDORSED_NEVER; } + /** + * @brief Retrieve a file tree corresponding to the underlying disk content + * of this mod. + * + * The file tree should not be cached since it is already cached and updated when + * required. + * + * @return a file tree representing the content of this mod. + */ + virtual std::shared_ptr fileTree() const = 0; + public: // Mutable operations: /** diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 78c04f2d..3f5fc7fc 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -682,7 +682,7 @@ std::set ModInfoRegular::doGetContents() const ModDataContent* contentFeature = m_GamePlugin->feature(); if (contentFeature) { - auto result = contentFeature->getContentsFor(contentFileTree()); + auto result = contentFeature->getContentsFor(fileTree()); return std::set(std::begin(result), std::end(result)); } diff --git a/src/modinfowithconflictinfo.cpp b/src/modinfowithconflictinfo.cpp index 70f9b3f1..dd8618e3 100644 --- a/src/modinfowithconflictinfo.cpp +++ b/src/modinfowithconflictinfo.cpp @@ -310,21 +310,21 @@ void ModInfoWithConflictInfo::diskContentModified() { void ModInfoWithConflictInfo::prefetch() { // Populating the tree to 1-depth (IFileTree is lazy, so size() forces the // tree to populate the first level): - contentFileTree()->size(); + fileTree()->size(); } bool ModInfoWithConflictInfo::doIsValid() const { auto mdc = m_GamePlugin->feature(); if (mdc) { - auto qdirfiletree = contentFileTree(); + auto qdirfiletree = fileTree(); return mdc->dataLooksValid(qdirfiletree) == ModDataChecker::CheckReturn::VALID; } return true; } -std::shared_ptr ModInfoWithConflictInfo::contentFileTree() const { +std::shared_ptr ModInfoWithConflictInfo::fileTree() const { return m_FileTree.value(); } diff --git a/src/modinfowithconflictinfo.h b/src/modinfowithconflictinfo.h index 7109b83d..feded99b 100644 --- a/src/modinfowithconflictinfo.h +++ b/src/modinfowithconflictinfo.h @@ -34,7 +34,18 @@ public: * * @return true if the content is there, false otherwise. */ - virtual bool hasContent(int content) const override; + virtual bool hasContent(int content) const override; /** + * @brief Retrieve a file tree corresponding to the underlying disk content + * of this mod. + * + * The file tree should not be cached since it is already cached and updated when + * required. + * + * @return a file tree representing the content of this mod. + */ + std::shared_ptr fileTree() const override; + +public: /** * @brief clear all caches held for this mod @@ -78,17 +89,6 @@ protected: **/ virtual std::set doGetContents() const { return {}; } - /** - * @brief Retrieve a file tree corresponding to the underlying disk content - * of this mod. - * - * The file tree should not be cached since it is already cached and updated when - * required. - * - * @return a file tree representing the content of this mod. - */ - std::shared_ptr contentFileTree() const; - ModInfoWithConflictInfo( PluginContainer* pluginContainer, const MOBase::IPluginGame* gamePlugin, -- cgit v1.3.1