Added a Library to most reference-counted classes

Former-commit-id: 3ed409a71dcd5ce4eec7672ac26f8fff00e3b136
This commit is contained in:
Lynix
2015-01-28 18:06:05 +01:00
parent e18e490c59
commit 53162c1722
34 changed files with 438 additions and 32 deletions

View File

@@ -8,6 +8,7 @@
#define NAZARA_ANIMATION_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@@ -33,6 +34,7 @@ class NzSkeleton;
using NzAnimationConstListener = NzObjectListenerWrapper<const NzAnimation>;
using NzAnimationConstRef = NzObjectRef<const NzAnimation>;
using NzAnimationLibrary = NzObjectLibrary<NzAnimation>;
using NzAnimationListener = NzObjectListenerWrapper<NzAnimation>;
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
using NzAnimationRef = NzObjectRef<NzAnimation>;
@@ -41,7 +43,9 @@ struct NzAnimationImpl;
class NAZARA_API NzAnimation : public NzRefCounted, public NzResource
{
friend NzAnimationLibrary;
friend NzAnimationLoader;
friend class NzUtility;
public:
NzAnimation() = default;
@@ -83,8 +87,12 @@ class NAZARA_API NzAnimation : public NzRefCounted, public NzResource
template<typename... Args> static NzAnimationRef New(Args&&... args);
private:
static bool Initialize();
static void Uninitialize();
NzAnimationImpl* m_impl = nullptr;
static NzAnimationLibrary::LibraryMap s_library;
static NzAnimationLoader::LoaderList s_loaders;
};

View File

@@ -9,6 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Resource.hpp>
@@ -29,13 +30,16 @@ struct NzFontGlyph;
using NzFontConstListener = NzObjectListenerWrapper<const NzFont>;
using NzFontConstRef = NzObjectRef<const NzFont>;
using NzFontLibrary = NzObjectLibrary<NzFont>;
using NzFontListener = NzObjectListenerWrapper<NzFont>;
using NzFontLoader = NzResourceLoader<NzFont, NzFontParams>;
using NzFontRef = NzObjectRef<NzFont>;
class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzAbstractAtlas::Listener, NzNonCopyable
{
friend NzFontLibrary;
friend NzFontLoader;
friend class NzUtility;
public:
struct Glyph;
@@ -83,16 +87,12 @@ class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzAbstractAtla
static unsigned int GetDefaultGlyphBorder();
static unsigned int GetDefaultMinimumStepSize();
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);
static void Uninitialize();
enum ModicationCode
{
ModificationCode_AtlasChanged,
@@ -131,6 +131,9 @@ class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzAbstractAtla
void OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata) override;
const Glyph& PrecacheGlyph(GlyphMap& glyphMap, unsigned int characterSize, nzUInt32 style, char32_t character) const;
static bool Initialize();
static void Uninitialize();
std::shared_ptr<NzAbstractAtlas> m_atlas;
std::unique_ptr<NzFontData> m_data;
mutable std::unordered_map<nzUInt64, std::unordered_map<nzUInt64, int>> m_kerningCache;
@@ -141,6 +144,7 @@ class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzAbstractAtla
static std::shared_ptr<NzAbstractAtlas> s_defaultAtlas;
static NzFontRef s_defaultFont;
static NzFontLibrary::LibraryMap s_library;
static NzFontLoader::LoaderList s_loaders;
static unsigned int s_defaultGlyphBorder;
static unsigned int s_defaultMinimumStepSize;

View File

@@ -10,6 +10,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@@ -36,13 +37,16 @@ class NzImage;
using NzImageConstListener = NzObjectListenerWrapper<const NzImage>;
using NzImageConstRef = NzObjectRef<const NzImage>;
using NzImageLibrary = NzObjectLibrary<NzImage>;
using NzImageListener = NzObjectListenerWrapper<NzImage>;
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
using NzImageRef = NzObjectRef<NzImage>;
class NAZARA_API NzImage : public NzAbstractImage, public NzRefCounted, public NzResource
{
friend NzImageLibrary;
friend NzImageLoader;
friend class NzUtility;
public:
struct SharedImage;
@@ -145,8 +149,12 @@ class NAZARA_API NzImage : public NzAbstractImage, public NzRefCounted, public N
void EnsureOwnership();
void ReleaseImage();
static bool Initialize();
static void Uninitialize();
SharedImage* m_sharedImage;
static NzImageLibrary::LibraryMap s_library;
static NzImageLoader::LoaderList s_loaders;
};

View File

@@ -9,6 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Primitive.hpp>
@@ -55,6 +56,7 @@ typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex;
using NzMeshConstListener = NzObjectListenerWrapper<const NzMesh>;
using NzMeshConstRef = NzObjectRef<const NzMesh>;
using NzMeshLibrary = NzObjectLibrary<NzMesh>;
using NzMeshListener = NzObjectListenerWrapper<NzMesh>;
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
using NzMeshRef = NzObjectRef<NzMesh>;
@@ -63,7 +65,9 @@ struct NzMeshImpl;
class NAZARA_API NzMesh : public NzRefCounted, public NzResource
{
friend NzMeshLibrary;
friend NzMeshLoader;
friend class NzUtility;
public:
NzMesh() = default;
@@ -128,6 +132,10 @@ class NAZARA_API NzMesh : public NzRefCounted, public NzResource
private:
NzMeshImpl* m_impl = nullptr;
static bool Initialize();
static void Uninitialize();
static NzMeshLibrary::LibraryMap s_library;
static NzMeshLoader::LoaderList s_loaders;
};

View File

@@ -8,6 +8,7 @@
#define NAZARA_SKELETON_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@@ -19,6 +20,7 @@ class NzSkeleton;
using NzSkeletonConstListener = NzObjectListenerWrapper<const NzSkeleton>;
using NzSkeletonConstRef = NzObjectRef<const NzSkeleton>;
using NzSkeletonLibrary = NzObjectLibrary<NzSkeleton>;
using NzSkeletonListener = NzObjectListenerWrapper<NzSkeleton>;
using NzSkeletonRef = NzObjectRef<NzSkeleton>;
@@ -27,6 +29,8 @@ struct NzSkeletonImpl;
class NAZARA_API NzSkeleton : public NzRefCounted
{
friend NzJoint;
friend NzSkeletonLibrary;
friend class NzUtility;
public:
NzSkeleton() = default;
@@ -60,7 +64,12 @@ class NAZARA_API NzSkeleton : public NzRefCounted
void InvalidateJointMap();
void UpdateJointMap() const;
static bool Initialize();
static void Uninitialize();
NzSkeletonImpl* m_impl = nullptr;
static NzSkeletonLibrary::LibraryMap s_library;
};
#include <Nazara/Utility/Skeleton.inl>

View File

@@ -8,6 +8,7 @@
#define NAZARA_VERTEXDECLARATION_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@@ -17,11 +18,13 @@ class NzVertexDeclaration;
using NzVertexDeclarationConstListener = NzObjectListenerWrapper<const NzVertexDeclaration>;
using NzVertexDeclarationConstRef = NzObjectRef<const NzVertexDeclaration>;
using NzVertexDeclarationLibrary = NzObjectLibrary<NzVertexDeclaration>;
using NzVertexDeclarationListener = NzObjectListenerWrapper<NzVertexDeclaration>;
using NzVertexDeclarationRef = NzObjectRef<NzVertexDeclaration>;
class NAZARA_API NzVertexDeclaration : public NzRefCounted
{
friend NzVertexDeclarationLibrary;
friend class NzUtility;
public:
@@ -66,6 +69,7 @@ class NAZARA_API NzVertexDeclaration : public NzRefCounted
unsigned int m_stride;
static NzVertexDeclaration s_declarations[nzVertexLayout_Max+1];
static NzVertexDeclarationLibrary::LibraryMap s_library;
};
#include <Nazara/Utility/VertexDeclaration.hpp>