mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-17 10:17:59 -05:00
ObjLoading/ObjWriting: Initial skeleton for loading and writing obj files
This commit is contained in:
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();
|
||||
}
|
Reference in New Issue
Block a user