ObjLoading/ObjWriting: Initial skeleton for loading and writing obj files

This commit is contained in:
Jan
2019-12-29 16:40:03 +01:00
parent a0d4e87b8e
commit af55c202cf
39 changed files with 689 additions and 2 deletions

View 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;
};

View 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();
}

View 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();
};