TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Core::ResourceHandle< Type > Class Template Reference

#include <tb_resource_handle.hpp>

Public Member Functions

 ResourceHandle (void)
 
 ~ResourceHandle (void)
 
bool IsValid (void) const
 
 operator bool () const
 
bool operator== (const ResourceHandle &other) const
 
bool operator!= (const ResourceHandle &other) const
 
bool operator< (const ResourceHandle &other) const
 
size_t GetHash (void) const
 
 ResourceHandle (const tbCore::uint32 value)
 

Public Attributes

tbCore::uint32 mValue
 

Detailed Description

template<typename Type>
class TurtleBrains::Core::ResourceHandle< Type >

The ResourceHandle provides a typesafe handle specific to a type of ResourceCache so that mixing TextureHandle's and AudioHandle's and such will cause compilation errors and prevent mistakes.

Constructor & Destructor Documentation

◆ ResourceHandle() [1/2]

template<typename Type >
TurtleBrains::Core::ResourceHandle< Type >::ResourceHandle ( void  )

Constructs an invalid resource handle by default.

◆ ~ResourceHandle()

template<typename Type >
TurtleBrains::Core::ResourceHandle< Type >::~ResourceHandle ( void  )

Destructs the resource handle object.

◆ ResourceHandle() [2/2]

template<typename Type >
TurtleBrains::Core::ResourceHandle< Type >::ResourceHandle ( const tbCore::uint32  value)

Disabled constructor that allows the setting of value directly by the ResouceCache only.

Note
Consider this a private implementation detail, do NOT use. Doing so will break the ResourceHandle and ResourceCache expectations.

Member Function Documentation

◆ IsValid()

template<typename Type >
bool TurtleBrains::Core::ResourceHandle< Type >::IsValid ( void  ) const

Checks to see if the handle is a valid handle and returns true if it is valid, false if it is in invalid.

Note
It is theroetically possible that a valid handle may not be contained in a ResourceCache depending on how the caches are used.

◆ operator bool()

template<typename Type >
TurtleBrains::Core::ResourceHandle< Type >::operator bool

Checks to see if the handle is a valid handle and returns true if it is valid, false if it is in invalid.

Note
It is theroetically possible that a valid handle may not be contained in a ResourceCache depending on how the caches are used.

◆ operator!=()

template<typename Type >
bool TurtleBrains::Core::ResourceHandle< Type >::operator!= ( const ResourceHandle< Type > &  other) const

Checks to see if two ResourceHandles are NOT matching one another.

Note
Due to the possiblity of using multiple ResouceCache's of the same type, it is not a gaurentee that two equal handles are pointing to an identical resource, however this is very likely the case.

◆ operator==()

template<typename Type >
bool TurtleBrains::Core::ResourceHandle< Type >::operator== ( const ResourceHandle< Type > &  other) const

Checks to see if two ResourceHandles are matching one another.

Note
Due to the possiblity of using multiple ResouceCache's of the same type, it is not a gaurentee that two equal handles are pointing to an identical resource, however this is very likely the case.

Member Data Documentation

◆ mValue

template<typename Type >
tbCore::uint32 TurtleBrains::Core::ResourceHandle< Type >::mValue

Disabled size_t operator to convert the ResourceHandle into an index to be used for accessing in the ResourceCache arrays.

Note
Consider this a private implementation detail, do NOT use. Doing so will break the ResourceHandle and ResourceCache expectations.

The index into the ResouceCache to the Resource that the handle represents.

Note
Consider this a private implementation detail, do NOT use. Doing so will break the ResourceHandle and ResourceCache expectations.