nrEngine::ResourcePtr< ResType > Class Template Reference
[Resource managment]

Resource pointer is a smart pointer pointing to the resource. More...

Inheritance diagram for nrEngine::ResourcePtr< ResType >:

nrEngine::IResourcePtr

Public Member Functions

 ResourcePtr ()
 ResourcePtr (const IResourcePtr &res)
NR_FORCEINLINE ResType * operator-> () const
NR_FORCEINLINE ResType * get ()
NR_FORCEINLINE ResType & operator * () const

Detailed Description

template<typename ResType>
class nrEngine::ResourcePtr< ResType >

Resource pointer is a smart pointer pointing to the resource.

This is a smart pointer that can be used to access resources manages by the resource manager. This pointer will automaticly be pointing to empty resource if the resource was unloaded by the manager.

You can create more than one resource pointer to a resource. Each access to such a resource through the manager will create a new one for you. However the pointers are pointing to one resource holder. Each resource holder is controlled/managed by the manager. So if you for example unload a resource to which one you has pointers, the manager will replace the resource holding by the holder with empty one. So if you try to access the resource you can still access them, but they are empty. Our systems also allows you to delete the manager from the memory, but the pointers will stay valid. So you can also remove the manager after you loaded all resources. However you can then do not manage the resources, so this is a way you should not do it !!!

Note:
We do not have any public constructors or destructors. This will prevent you by using the resource management system in the wrong way. You have to use manager before you can use the pointers to resources. This will give the nrEngine the safety of using its resource management system.

Definition at line 216 of file ResourcePtr.h.


Constructor & Destructor Documentation

template<typename ResType>
nrEngine::ResourcePtr< ResType >::ResourcePtr (  ) 

Create an empty resource pointer. Such a pointer does not point to anything. So using of not initialized pointers will give you an exception

Definition at line 224 of file ResourcePtr.h.

template<typename ResType>
nrEngine::ResourcePtr< ResType >::ResourcePtr ( const IResourcePtr< ResType > &  res  ) 

Copy constructor to allow copying from base class

Definition at line 229 of file ResourcePtr.h.


Member Function Documentation

template<typename ResType>
NR_FORCEINLINE ResType* nrEngine::ResourcePtr< ResType >::operator-> (  )  const

Access to the resource to which one this pointer points. This access need 1 static_cast, 3 function calls until it returns the resource. So this function is running in O(1) and is pretty efficient

Definition at line 236 of file ResourcePtr.h.

References nrEngine::IResourcePtr::getBase(), nrEngine::Log::LL_ERROR, nrEngine::Log::LOG_ENGINE, and NR_ASSERT.

template<typename ResType>
NR_FORCEINLINE ResType* nrEngine::ResourcePtr< ResType >::get (  ) 

Get the object stored by this pointer. NOTE: The instance is controlled by the pointer, so do not delete it

Definition at line 252 of file ResourcePtr.h.

template<typename ResType>
NR_FORCEINLINE ResType& nrEngine::ResourcePtr< ResType >::operator * (  )  const

Access to the resource to which one this pointer points. This access need 1 static_cast, 3 function calls until it returns the resource. So this function is running in O(1) and is pretty efficient

Definition at line 262 of file ResourcePtr.h.


The documentation for this class was generated from the following file:
Generated on Wed Sep 12 23:19:43 2007 for nrEngine by  doxygen 1.5.1