Added a static New method to RefCounted-derived classes

Former-commit-id: efd9e68e050fb6cc7e0df7a7c222ca759c502dc5
This commit is contained in:
Lynix
2015-01-25 23:41:09 +01:00
parent 5f5be93992
commit 0db92e671d
59 changed files with 532 additions and 354 deletions

View File

@@ -80,10 +80,14 @@ class NAZARA_API NzAnimation : public NzRefCounted, public NzResource
void RemoveSequence(const NzString& sequenceName);
void RemoveSequence(unsigned int index);
template<typename... Args> static NzAnimationRef New(Args&&... args);
private:
NzAnimationImpl* m_impl = nullptr;
static NzAnimationLoader::LoaderList s_loaders;
};
#include <Nazara/Utility/Animation.inl>
#endif // NAZARA_ANIMATION_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzAnimationRef NzAnimation::New(Args&&... args)
{
std::unique_ptr<NzAnimation> object(new NzAnimation(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -58,6 +58,7 @@ class NAZARA_API NzBuffer : public NzRefCounted, NzNonCopyable
void Unmap() const;
static bool IsStorageSupported(nzUInt32 storage);
template<typename... Args> static NzBufferRef New(Args&&... args);
static void SetBufferFactory(nzUInt32 storage, BufferFactory func);
private:
@@ -73,4 +74,6 @@ class NAZARA_API NzBuffer : public NzRefCounted, NzNonCopyable
static BufferFactory s_bufferFactories[nzDataStorage_Max+1];
};
#include <Nazara/Utility/Buffer.inl>
#endif // NAZARA_BUFFER_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzBufferRef NzBuffer::New(Args&&... args)
{
std::unique_ptr<NzBuffer> object(new NzBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -85,6 +85,8 @@ class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzAbstractAtla
static bool Initialize();
template<typename... Args> static NzFontRef New(Args&&... args);
static void SetDefaultAtlas(const std::shared_ptr<NzAbstractAtlas>& atlas);
static void SetDefaultGlyphBorder(unsigned int borderSize);
static void SetDefaultMinimumStepSize(unsigned int minimumStepSize);
@@ -138,10 +140,12 @@ class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzAbstractAtla
unsigned int m_minimumStepSize;
static std::shared_ptr<NzAbstractAtlas> s_defaultAtlas;
static NzFont* s_defaultFont;
static NzFontRef s_defaultFont;
static NzFontLoader::LoaderList s_loaders;
static unsigned int s_defaultGlyphBorder;
static unsigned int s_defaultMinimumStepSize;
};
#include <Nazara/Utility/Font.inl>
#endif // NAZARA_FONT_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzFontRef NzFont::New(Args&&... args)
{
std::unique_ptr<NzFont> object(new NzFont(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -112,6 +112,7 @@ class NAZARA_API NzImage : public NzAbstractImage, public NzRefCounted, public N
static void Copy(nzUInt8* destination, const nzUInt8* source, nzUInt8 bpp, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0);
static nzUInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1);
static nzUInt8 GetMaxLevel(nzImageType type, unsigned int width, unsigned int height, unsigned int depth = 1);
template<typename... Args> static NzImageRef New(Args&&... args);
struct SharedImage
{
@@ -149,4 +150,6 @@ class NAZARA_API NzImage : public NzAbstractImage, public NzRefCounted, public N
static NzImageLoader::LoaderList s_loaders;
};
#include <Nazara/Utility/Image.inl>
#endif // NAZARA_IMAGE_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzImageRef NzImage::New(Args&&... args)
{
std::unique_ptr<NzImage> object(new NzImage(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -64,6 +64,8 @@ class NAZARA_API NzIndexBuffer : public NzRefCounted
NzIndexBuffer& operator=(const NzIndexBuffer& indexBuffer);
template<typename... Args> static NzIndexBufferRef New(Args&&... args);
private:
NzBufferRef m_buffer;
bool m_largeIndices;
@@ -72,4 +74,6 @@ class NAZARA_API NzIndexBuffer : public NzRefCounted
unsigned int m_startOffset;
};
#include <Nazara/Utility/IndexBuffer.inl>
#endif // NAZARA_INDEXBUFFER_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzIndexBufferRef NzIndexBuffer::New(Args&&... args)
{
std::unique_ptr<NzIndexBuffer> object(new NzIndexBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -123,10 +123,14 @@ class NAZARA_API NzMesh : public NzRefCounted, public NzResource
void Transform(const NzMatrix4f& matrix);
template<typename... Args> static NzMeshRef New(Args&&... args);
private:
NzMeshImpl* m_impl = nullptr;
static NzMeshLoader::LoaderList s_loaders;
};
#include <Nazara/Utility/Mesh.inl>
#endif // NAZARA_MESH_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzMeshRef NzMesh::New(Args&&... args)
{
std::unique_ptr<NzMesh> object(new NzMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -41,10 +41,14 @@ class NAZARA_API NzSkeletalMesh final : public NzSubMesh
void SetAABB(const NzBoxf& aabb);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
template<typename... Args> static NzSkeletalMeshRef New(Args&&... args);
private:
NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr;
NzVertexBufferRef m_vertexBuffer = nullptr;
};
#include <Nazara/Utility/SkeletalMesh.inl>
#endif // NAZARA_SKELETALMESH_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzSkeletalMeshRef NzSkeletalMesh::New(Args&&... args)
{
std::unique_ptr<NzSkeletalMesh> object(new NzSkeletalMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -53,6 +53,8 @@ class NAZARA_API NzSkeleton : public NzRefCounted
NzSkeleton& operator=(const NzSkeleton& skeleton);
template<typename... Args> static NzSkeletonRef New(Args&&... args);
private:
void InvalidateJoints();
void InvalidateJointMap();
@@ -61,4 +63,6 @@ class NAZARA_API NzSkeleton : public NzRefCounted
NzSkeletonImpl* m_impl = nullptr;
};
#include <Nazara/Utility/Skeleton.inl>
#endif // NAZARA_SKELETON_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzSkeletonRef NzSkeleton::New(Args&&... args)
{
std::unique_ptr<NzSkeleton> object(new NzSkeleton(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -45,10 +45,14 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh
void SetAABB(const NzBoxf& aabb);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
template<typename... Args> static NzStaticMeshRef New(Args&&... args);
private:
NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr;
NzVertexBufferRef m_vertexBuffer = nullptr;
};
#include <Nazara/Utility/StaticMesh.inl>
#endif // NAZARA_STATICMESH_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzStaticMeshRef NzStaticMesh::New(Args&&... args)
{
std::unique_ptr<NzStaticMesh> object(new NzStaticMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -62,6 +62,8 @@ class NAZARA_API NzVertexBuffer : public NzRefCounted
NzVertexBuffer& operator=(const NzVertexBuffer& vertexBuffer);
template<typename... Args> static NzVertexBufferRef New(Args&&... args);
private:
NzBufferRef m_buffer;
NzVertexDeclarationConstRef m_vertexDeclaration;
@@ -70,4 +72,6 @@ class NAZARA_API NzVertexBuffer : public NzRefCounted
unsigned int m_vertexCount;
};
#include <Nazara/Utility/VertexBuffer.inl>
#endif // NAZARA_VERTEXBUFFER_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzVertexBufferRef NzVertexBuffer::New(Args&&... args)
{
std::unique_ptr<NzVertexBuffer> object(new NzVertexBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -41,6 +41,7 @@ class NAZARA_API NzVertexDeclaration : public NzRefCounted
static NzVertexDeclaration* Get(nzVertexLayout layout);
static bool IsTypeSupported(nzComponentType type);
template<typename... Args> static NzVertexDeclarationRef New(Args&&... args);
private:
static bool Initialize();
@@ -67,4 +68,6 @@ class NAZARA_API NzVertexDeclaration : public NzRefCounted
static NzVertexDeclaration s_declarations[nzVertexLayout_Max+1];
};
#include <Nazara/Utility/VertexDeclaration.hpp>
#endif // NAZARA_VERTEXDECLARATION_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzVertexDeclarationRef NzVertexDeclaration::New(Args&&... args)
{
std::unique_ptr<NzVertexDeclaration> object(new NzVertexDeclaration(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -2,8 +2,8 @@
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/Debug.hpp>
#include <Nazara/Utility/VertexDeclaration.hpp>
#include <Nazara/Utility/Debug.hpp>
template <typename T>
NzSparsePtr<T> NzVertexMapper::GetComponentPtr(nzVertexComponent component)