nrEngine::IResourcePtr Class Reference
[Resource managment]

Base untemplated class for resource pointers. More...

Inheritance diagram for nrEngine::IResourcePtr:

nrEngine::ResourcePtr< ResType >

Public Member Functions

 IResourcePtr (const IResourcePtr &resPtr)
 IResourcePtr ()
virtual ~IResourcePtr ()
virtual bool operator== (IResourcePtr &res) const
virtual bool operator== (const IResource *p) const
virtual bool operator!= (IResourcePtr &res) const
virtual bool operator!= (const IResource *res) const
NR_FORCEINLINE bool isNull () const
NR_FORCEINLINE bool valid () const
Result lockResource ()
Result unlockResource ()
Result lockEmpty ()
Result unlockEmpty ()
IResourcegetBase () const

Protected Member Functions

NR_FORCEINLINE SharedPtr<
ResourceHolder
getResourceHolder () const
 IResourcePtr (SharedPtr< ResourceHolder > holder)

Protected Attributes

SharedPtr< ResourceHoldermHolder
 Shared pointer holding the holder of the resource.

Friends

class IResourceLoader
 Resource Manager is a friend, so it can freely work with this pointers.
class ResourceManager
 Also resource manager is a friend.

Detailed Description

Base untemplated class for resource pointers.

This is a base class for resource pointers. You can use this pointers as normal pointers, except you can not use new,delete functions. We need this base class which is not templated to implement converting functions in derived classes

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 40 of file ResourcePtr.h.


Constructor & Destructor Documentation

nrEngine::IResourcePtr::IResourcePtr ( const IResourcePtr resPtr  ) 

Copy constructor

Definition at line 24 of file ResourcePtr.cpp.

References getResourceHolder(), and mHolder.

nrEngine::IResourcePtr::IResourcePtr (  ) 

Create an empty resource pointer, that do not point to anywhere

Definition at line 51 of file ResourcePtr.h.

virtual nrEngine::IResourcePtr::~IResourcePtr (  )  [virtual]

Virtual destructor

Definition at line 59 of file ResourcePtr.h.

nrEngine::IResourcePtr::IResourcePtr ( SharedPtr< ResourceHolder holder  )  [protected]

Create an instance of the resource pointer. This pointer is pointing to the resource stored by the holder. The constructor is private, so you can not use the new function to create the pointer.

Definition at line 181 of file ResourcePtr.h.


Member Function Documentation

bool nrEngine::IResourcePtr::operator== ( IResourcePtr res  )  const [virtual]

Check if the given pointer is the same as this one.

Note:
Two pointers are the same, if they showing to the same resource, and if their holders are the same or if both pointers points to NULL. If one of the pointers is an empty pointer, so also false will be returned.

Definition at line 29 of file ResourcePtr.cpp.

References nrEngine::ResourceHolder::getResource(), getResourceHolder(), isNull(), and nrEngine::IResource::isResourceEmpty().

Referenced by operator!=().

bool nrEngine::IResourcePtr::operator== ( const IResource p  )  const [virtual]

Check equality to normal pointers.

Definition at line 52 of file ResourcePtr.cpp.

References getResourceHolder(), and isNull().

bool nrEngine::IResourcePtr::operator!= ( IResourcePtr res  )  const [virtual]

Check whenver two pointers are not the same.

See also:
operator==

Definition at line 62 of file ResourcePtr.cpp.

References operator==().

bool nrEngine::IResourcePtr::operator!= ( const IResource res  )  const [virtual]

Check whenver two pointers are not the same.

See also:
operator==

Definition at line 67 of file ResourcePtr.cpp.

References operator==().

NR_FORCEINLINE bool nrEngine::IResourcePtr::isNull (  )  const

Check whenever this pointer is NULL - does not contain data

Definition at line 97 of file ResourcePtr.h.

Referenced by nrEngine::ResourceManager::createResource(), nrEngine::ScriptEngine::load(), nrEngine::ResourceManager::loadResource(), lockEmpty(), lockResource(), nrEngine::ResourceManager::lockResource(), operator==(), nrEngine::ResourceManager::reload(), nrEngine::ResourceManager::remove(), nrEngine::ScriptFunctionDec(), nrEngine::ResourceManager::unload(), unlockEmpty(), unlockResource(), and nrEngine::ResourceManager::unlockResource().

NR_FORCEINLINE bool nrEngine::IResourcePtr::valid (  )  const

Check whenever the pointer contains valid data. The method if opossite to isNull()

Definition at line 105 of file ResourcePtr.h.

Result nrEngine::IResourcePtr::lockResource (  ) 

Lock the resource to which one this pointer points, to prevent using of empty resource. See more information about locking of real resources in the documentation about ResourceManager::lockPure() or ResourceHolder::lockPure()

Returns:
either OK or:
  • RES_PTR_IS_NULL if this pointer is null
  • RES_LOCK_STATE_STACK_IS_FULL if we are not able to lock anymore

Definition at line 72 of file ResourcePtr.cpp.

References getResourceHolder(), isNull(), nrEngine::OK, nrEngine::RES_LOCK_STATE_STACK_IS_FULL, and nrEngine::RES_PTR_IS_NULL.

Referenced by nrEngine::ResourceManager::lockResource().

Result nrEngine::IResourcePtr::unlockResource (  ) 

Unlock the resource to which one this pointer points, to prevent using of empty resource. See more information about locking of real resources in the documentation about ResourceManager::unlockpure()

Returns:
either OK or RES_PTR_IS_NULL if this pointer is null

Definition at line 84 of file ResourcePtr.cpp.

References getResourceHolder(), isNull(), nrEngine::OK, and nrEngine::RES_PTR_IS_NULL.

Result nrEngine::IResourcePtr::lockEmpty (  ) 

Lock an empty resource, so that even if resource is loaded, empty resource will be used.

See also:
lockPure()

Definition at line 95 of file ResourcePtr.cpp.

References getResourceHolder(), isNull(), nrEngine::OK, nrEngine::RES_LOCK_STATE_STACK_IS_FULL, and nrEngine::RES_PTR_IS_NULL.

Result nrEngine::IResourcePtr::unlockEmpty (  ) 

Unlock empty resource

Definition at line 107 of file ResourcePtr.cpp.

References getResourceHolder(), isNull(), nrEngine::OK, and nrEngine::RES_PTR_IS_NULL.

IResource * nrEngine::IResourcePtr::getBase (  )  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 118 of file ResourcePtr.cpp.

References mHolder, and NR_ASSERT.

Referenced by nrEngine::ResourcePtr< ResType >::operator->(), and nrEngine::ResourceManager::remove().

NR_FORCEINLINE SharedPtr<ResourceHolder> nrEngine::IResourcePtr::getResourceHolder (  )  const [protected]

Get the holder to which one this pointer shows

Definition at line 171 of file ResourcePtr.h.

Referenced by IResourcePtr(), lockEmpty(), lockResource(), operator==(), unlockEmpty(), unlockResource(), and nrEngine::ResourceManager::unlockResource().


Friends And Related Function Documentation

friend class IResourceLoader [friend]

Resource Manager is a friend, so it can freely work with this pointers.

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 160 of file ResourcePtr.h.


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