303 lines
7.6 KiB
C++
303 lines
7.6 KiB
C++
#include "stdafx.h"
|
|
#include "ResourceFactory.h"
|
|
#include <algorithm>
|
|
|
|
ResourceFactory::ResourceFactory(IEngine& argEngine)
|
|
: m_Engine(argEngine)
|
|
, m_LastCallCreatedResource(false)
|
|
{
|
|
}
|
|
|
|
|
|
ResourceFactory::~ResourceFactory()
|
|
{
|
|
this->ClearInternal(m_Windows);
|
|
this->ClearInternal(m_RenderCommandNodes);
|
|
this->ClearInternal(m_ShaderPool);
|
|
this->ClearInternal(m_InternalShaderPool);
|
|
this->ClearInternal(m_GeometryBufferPool);
|
|
this->ClearInternal(m_SwapChainPool);
|
|
this->ClearInternal(m_RenderTargetTexturePool);
|
|
this->ClearInternal(m_TransformationPool);
|
|
this->ClearInternal(m_PerspectiveCameraPool);
|
|
this->ClearInternal(m_OrthographicCameraPool);
|
|
this->ClearInternal(m_BonePool);
|
|
this->ClearInternal(m_BoneControllerPool);
|
|
this->ClearInternal(m_ShaderParameterCollectionPool);
|
|
}
|
|
|
|
|
|
ITransformationAnimation& ResourceFactory::CreateTransformationAnimation()
|
|
{
|
|
ITransformationAnimation* var = new TransformationAnimation(m_Engine);
|
|
m_TransformationAnimations.push_back(var);
|
|
return *var;
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteTransformationAnimation(ITransformationAnimation& argValue, bool argRemoveOnly)
|
|
{
|
|
std::vector<ITransformationAnimation*>::iterator iter = std::find(m_TransformationAnimations.begin(), m_TransformationAnimations.end(), &argValue);
|
|
if (iter != m_TransformationAnimations.end())
|
|
{
|
|
m_TransformationAnimations.erase(iter);
|
|
if (!argRemoveOnly)
|
|
delete &argValue;
|
|
}
|
|
}
|
|
|
|
|
|
IWindow& ResourceFactory::CreateSwapChainWindow()
|
|
{
|
|
IWindow* window = new Window(m_Engine);
|
|
m_Windows.push_back(window);
|
|
return *window;
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteSwapChainWindow(IWindow& argValue, bool argRemoveOnly)
|
|
{
|
|
std::vector<IWindow*>::iterator iter = std::find(m_Windows.begin(), m_Windows.end(), &argValue);
|
|
if (iter != m_Windows.end())
|
|
{
|
|
m_Windows.erase(iter);
|
|
if (!argRemoveOnly)
|
|
delete &argValue;
|
|
}
|
|
}
|
|
|
|
|
|
IRenderCommandNode& ResourceFactory::CreateRenderCommandNode()
|
|
{
|
|
IRenderCommandNode* node = new RenderCommandNode(m_Engine);
|
|
m_RenderCommandNodes.push_back(node);
|
|
return *node;
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteRenderCommandNode(IRenderCommandNode& argValue, bool argRemoveOnly)
|
|
{
|
|
std::vector<IRenderCommandNode*>::iterator iter = std::find(m_RenderCommandNodes.begin(), m_RenderCommandNodes.end(), &argValue);
|
|
if (iter != m_RenderCommandNodes.end())
|
|
{
|
|
m_RenderCommandNodes.erase(iter);
|
|
if (!argRemoveOnly)
|
|
delete &argValue;
|
|
}
|
|
}
|
|
|
|
|
|
IShader* ResourceFactory::FindShader(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_ShaderPool, argId);
|
|
}
|
|
|
|
|
|
IShader& ResourceFactory::CreateOrFindShader(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_ShaderPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteShader(IShader& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_ShaderPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IInternalShader* ResourceFactory::FindInternalShader(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_InternalShaderPool, argId);
|
|
}
|
|
|
|
|
|
IInternalShader& ResourceFactory::CreateOrFindInternalShader(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_InternalShaderPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteInternalShader(IInternalShader& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_InternalShaderPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
ISwapChain* ResourceFactory::FindSwapChain(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_SwapChainPool, argId);
|
|
}
|
|
|
|
|
|
ISwapChain& ResourceFactory::CreateOrFindSwapChain(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_SwapChainPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteSwapChain(ISwapChain& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_SwapChainPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IRenderTargetTexture* ResourceFactory::FindRenderTargetTexture(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_RenderTargetTexturePool, argId);
|
|
}
|
|
|
|
|
|
IRenderTargetTexture& ResourceFactory::CreateOrFindRenderTargetTexture(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_RenderTargetTexturePool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteRenderTargetTexture(IRenderTargetTexture& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_RenderTargetTexturePool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IGeometryBuffer* ResourceFactory::FindGeometryBuffer(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_GeometryBufferPool, argId);
|
|
}
|
|
|
|
|
|
IGeometryBuffer& ResourceFactory::CreateOrFindGeometryBuffer(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_GeometryBufferPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteGeometryBuffer(IGeometryBuffer& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_GeometryBufferPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IShaderParameterCollection* ResourceFactory::FindShaderParameterCollection(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_ShaderParameterCollectionPool, argId);
|
|
}
|
|
|
|
|
|
IShaderParameterCollection& ResourceFactory::CreateOrFindShaderParameterCollection(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_ShaderParameterCollectionPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteShaderParameterCollection(IShaderParameterCollection& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_ShaderParameterCollectionPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
ITexture* ResourceFactory::FindTexture(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_TexturePool, argId);
|
|
}
|
|
|
|
|
|
ITexture& ResourceFactory::CreateOrFindTexture(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_TexturePool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteTexture(ITexture& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_TexturePool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
ITransformation* ResourceFactory::FindTransformation(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_TransformationPool, argId);
|
|
}
|
|
|
|
|
|
ITransformation& ResourceFactory::CreateOrFindTransformation(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_TransformationPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteTransformation(ITransformation& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_TransformationPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IPerspectiveCamera* ResourceFactory::FindPerspectiveCamera(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_PerspectiveCameraPool, argId);
|
|
}
|
|
|
|
|
|
IPerspectiveCamera& ResourceFactory::CreateOrFindPerspectiveCamera(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_PerspectiveCameraPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeletePerspectiveCamera(IPerspectiveCamera& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_PerspectiveCameraPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IOrthographicCamera* ResourceFactory::FindOrthographicCamera(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_OrthographicCameraPool, argId);
|
|
}
|
|
|
|
|
|
IOrthographicCamera& ResourceFactory::CreateOrFindOrthographicCamera(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_OrthographicCameraPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteOrthographicCamera(IOrthographicCamera& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_OrthographicCameraPool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
|
|
IBone* ResourceFactory::FindBone(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_BonePool, argId);
|
|
}
|
|
|
|
|
|
IBone& ResourceFactory::CreateOrFindBone(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_BonePool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteBone(IBone& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_BonePool, argValue, argRemoveOnly);
|
|
}
|
|
|
|
IBoneController* ResourceFactory::FindBoneController(const string8& argId)
|
|
{
|
|
return this->FindInternal(m_BoneControllerPool, argId);
|
|
}
|
|
|
|
|
|
IBoneController& ResourceFactory::CreateOrFindBoneController(const string8& argId)
|
|
{
|
|
return *this->CreateOrFindInternal(m_BoneControllerPool, argId);
|
|
}
|
|
|
|
|
|
void ResourceFactory::DeleteBoneController(IBoneController& argValue, bool argRemoveOnly)
|
|
{
|
|
this->DeleteInternal(m_BoneControllerPool, argValue, argRemoveOnly);
|
|
}
|