Use forward declaration for some VFS types

This will allow to save on preprocessed code size in the future changes.
ini_importer_tests
elsid 12 months ago
parent 5ae878c248
commit a2147d70cc
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -17,6 +17,7 @@
#include <components/vfs/bsaarchive.hpp>
#include <components/vfs/filesystemarchive.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include <boost/program_options.hpp>

@ -11,6 +11,7 @@
#include <components/misc/strings/lower.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
CSMWorld::Resources::Resources(
const VFS::Manager* vfs, const std::string& baseDirectory, UniversalId::Type type, const char* const* extensions)

@ -18,6 +18,7 @@
#include <components/resource/resourcesystem.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"

@ -29,6 +29,7 @@
#include <components/sceneutil/lightmanager.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include <components/widgets/sharedstatebutton.hpp>
#include "../mwbase/environment.hpp"

@ -5,6 +5,7 @@
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/pathutil.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include "../mwbase/environment.hpp"

@ -33,6 +33,7 @@
#include <components/sceneutil/keyframe.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/lightutil.hpp>

@ -23,6 +23,7 @@
#include <components/stereo/multiview.hpp>
#include <components/stereo/stereomanager.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"

@ -13,6 +13,7 @@
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/pathutil.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"

@ -6,6 +6,7 @@
#include <components/misc/strings/conversion.hpp>
#include <components/vfs/archive.hpp>
#include <components/vfs/file.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/pathutil.hpp>

@ -1,27 +1,13 @@
#ifndef OPENMW_COMPONENTS_RESOURCE_ARCHIVE_H
#define OPENMW_COMPONENTS_RESOURCE_ARCHIVE_H
#ifndef OPENMW_COMPONENTS_VFS_ARCHIVE_H
#define OPENMW_COMPONENTS_VFS_ARCHIVE_H
#include <filesystem>
#include <map>
#include <string>
#include <string_view>
#include <components/files/istreamptr.hpp>
#include "filemap.hpp"
namespace VFS
{
class File
{
public:
virtual ~File() = default;
virtual Files::IStreamPtr open() = 0;
virtual std::filesystem::path getPath() = 0;
};
using FileMap = std::map<std::string, File*, std::less<>>;
class Archive
{
public:

@ -2,6 +2,7 @@
#define VFS_BSAARCHIVE_HPP_
#include "archive.hpp"
#include "file.hpp"
#include "pathutil.hpp"
#include <components/bsa/ba2dx10file.hpp>

@ -0,0 +1,21 @@
#ifndef OPENMW_COMPONENTS_VFS_FILE_H
#define OPENMW_COMPONENTS_VFS_FILE_H
#include <filesystem>
#include <components/files/istreamptr.hpp>
namespace VFS
{
class File
{
public:
virtual ~File() = default;
virtual Files::IStreamPtr open() = 0;
virtual std::filesystem::path getPath() = 0;
};
}
#endif

@ -0,0 +1,14 @@
#ifndef OPENMW_COMPONENTS_VFS_FILEMAP_H
#define OPENMW_COMPONENTS_VFS_FILEMAP_H
#include <map>
#include <string>
namespace VFS
{
class File;
using FileMap = std::map<std::string, File*, std::less<>>;
}
#endif

@ -2,8 +2,9 @@
#define OPENMW_COMPONENTS_RESOURCE_FILESYSTEMARCHIVE_H
#include "archive.hpp"
#include <filesystem>
#include "file.hpp"
#include <filesystem>
#include <string>
namespace VFS

@ -5,12 +5,19 @@
#include <components/files/conversion.hpp>
#include <components/misc/strings/lower.hpp>
#include <components/vfs/recursivedirectoryiterator.hpp>
#include "archive.hpp"
#include "file.hpp"
#include "pathutil.hpp"
#include "recursivedirectoryiterator.hpp"
namespace VFS
{
Manager::Manager() = default;
Manager::~Manager() = default;
void Manager::reset()
{
mIndex.clear();
@ -70,7 +77,7 @@ namespace VFS
return found->second->getPath();
}
Manager::RecursiveDirectoryRange Manager::getRecursiveDirectoryIterator(std::string_view path) const
RecursiveDirectoryRange Manager::getRecursiveDirectoryIterator(std::string_view path) const
{
if (path.empty())
return { mIndex.begin(), mIndex.end() };

@ -4,32 +4,17 @@
#include <components/files/istreamptr.hpp>
#include <filesystem>
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "archive.hpp"
#include "filemap.hpp"
namespace VFS
{
template <typename Iterator>
class IteratorPair
{
public:
IteratorPair(Iterator first, Iterator last)
: mFirst(first)
, mLast(last)
{
}
Iterator begin() const { return mFirst; }
Iterator end() const { return mLast; }
private:
Iterator mFirst;
Iterator mLast;
};
class Archive;
class RecursiveDirectoryRange;
/// @brief The main class responsible for loading files from a virtual file system.
/// @par Various archive types (e.g. directories on the filesystem, or compressed archives)
@ -37,30 +22,12 @@ namespace VFS
/// contained in multiple archives, the last added archive will have priority.
/// @par Most of the methods in this class are considered thread-safe, see each method documentation for details.
class Manager
{
class RecursiveDirectoryIterator
{
public:
RecursiveDirectoryIterator(FileMap::const_iterator it)
: mIt(it)
{
}
const std::string& operator*() const { return mIt->first; }
const std::string* operator->() const { return &mIt->first; }
bool operator!=(const RecursiveDirectoryIterator& other) { return mIt != other.mIt; }
RecursiveDirectoryIterator& operator++()
{
++mIt;
return *this;
}
Manager();
private:
FileMap::const_iterator mIt;
};
using RecursiveDirectoryRange = IteratorPair<RecursiveDirectoryIterator>;
~Manager();
public:
// Empty the file index and unregister archives.
void reset();

@ -0,0 +1,53 @@
#ifndef OPENMW_COMPONENTS_VFS_RECURSIVEDIRECTORYITERATOR_H
#define OPENMW_COMPONENTS_VFS_RECURSIVEDIRECTORYITERATOR_H
#include <string>
#include "filemap.hpp"
namespace VFS
{
class RecursiveDirectoryIterator
{
public:
RecursiveDirectoryIterator(FileMap::const_iterator it)
: mIt(it)
{
}
const std::string& operator*() const { return mIt->first; }
const std::string* operator->() const { return &mIt->first; }
RecursiveDirectoryIterator& operator++()
{
++mIt;
return *this;
}
friend bool operator==(const RecursiveDirectoryIterator& lhs, const RecursiveDirectoryIterator& rhs) = default;
private:
FileMap::const_iterator mIt;
};
class RecursiveDirectoryRange
{
public:
RecursiveDirectoryRange(RecursiveDirectoryIterator first, RecursiveDirectoryIterator last)
: mBegin(first)
, mEnd(last)
{
}
RecursiveDirectoryIterator begin() const { return mBegin; }
RecursiveDirectoryIterator end() const { return mEnd; }
private:
RecursiveDirectoryIterator mBegin;
RecursiveDirectoryIterator mEnd;
};
}
#endif
Loading…
Cancel
Save