mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
ObjLoading/ObjWriting: Initial skeleton for loading and writing obj files
This commit is contained in:
12
src/ObjLoading/SearchPath/ISearchPath.h
Normal file
12
src/ObjLoading/SearchPath/ISearchPath.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/FileAPI.h"
|
||||
#include <string>
|
||||
|
||||
class ISearchPath
|
||||
{
|
||||
public:
|
||||
virtual ~ISearchPath() = default;
|
||||
|
||||
virtual FileAPI::IFile* Open(const std::string& fileName) = 0;
|
||||
};
|
0
src/ObjLoading/SearchPath/SearchPathFilesystem.cpp
Normal file
0
src/ObjLoading/SearchPath/SearchPathFilesystem.cpp
Normal file
0
src/ObjLoading/SearchPath/SearchPathFilesystem.h
Normal file
0
src/ObjLoading/SearchPath/SearchPathFilesystem.h
Normal file
78
src/ObjLoading/SearchPath/SearchPaths.cpp
Normal file
78
src/ObjLoading/SearchPath/SearchPaths.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
#include "SearchPaths.h"
|
||||
|
||||
SearchPaths::~SearchPaths()
|
||||
{
|
||||
for(auto searchPath : m_search_paths)
|
||||
{
|
||||
delete searchPath;
|
||||
}
|
||||
m_search_paths.clear();
|
||||
}
|
||||
|
||||
SearchPaths::SearchPaths(const SearchPaths& other)
|
||||
: m_search_paths(other.m_search_paths)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SearchPaths::SearchPaths(SearchPaths&& other) noexcept
|
||||
: m_search_paths(std::move(other.m_search_paths))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SearchPaths& SearchPaths::operator=(const SearchPaths& other)
|
||||
{
|
||||
m_search_paths = other.m_search_paths;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
SearchPaths& SearchPaths::operator=(SearchPaths&& other) noexcept
|
||||
{
|
||||
m_search_paths = std::move(other.m_search_paths);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
FileAPI::IFile* SearchPaths::Open(const std::string& fileName)
|
||||
{
|
||||
for(auto searchPath : m_search_paths)
|
||||
{
|
||||
auto* file = searchPath->Open(fileName);
|
||||
|
||||
if(file != nullptr)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SearchPaths::AddSearchPath(ISearchPath* searchPath)
|
||||
{
|
||||
m_search_paths.push_back(searchPath);
|
||||
}
|
||||
|
||||
void SearchPaths::RemoveSearchPath(ISearchPath* searchPath)
|
||||
{
|
||||
for(auto i = m_search_paths.begin(); i != m_search_paths.end(); ++i)
|
||||
{
|
||||
if(*i == searchPath)
|
||||
{
|
||||
m_search_paths.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SearchPaths::iterator SearchPaths::begin()
|
||||
{
|
||||
return m_search_paths.begin();
|
||||
}
|
||||
|
||||
SearchPaths::iterator SearchPaths::end()
|
||||
{
|
||||
return m_search_paths.end();
|
||||
}
|
26
src/ObjLoading/SearchPath/SearchPaths.h
Normal file
26
src/ObjLoading/SearchPath/SearchPaths.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "ISearchPath.h"
|
||||
#include <vector>
|
||||
|
||||
class SearchPaths final : public ISearchPath
|
||||
{
|
||||
std::vector<ISearchPath*> m_search_paths;
|
||||
|
||||
public:
|
||||
using iterator = std::vector<ISearchPath*>::iterator;
|
||||
|
||||
~SearchPaths() override;
|
||||
FileAPI::IFile* Open(const std::string& fileName) override;
|
||||
|
||||
SearchPaths(const SearchPaths& other);
|
||||
SearchPaths(SearchPaths&& other) noexcept;
|
||||
SearchPaths& operator=(const SearchPaths& other);
|
||||
SearchPaths& operator=(SearchPaths&& other) noexcept;
|
||||
|
||||
void AddSearchPath(ISearchPath* searchPath);
|
||||
void RemoveSearchPath(ISearchPath* searchPath);
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
};
|
Reference in New Issue
Block a user