Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Resource class. More...
#include <ilviews/base/resource.h>
Public Member Functions | |
IlvDisplay * | getDisplay () const |
Gets the IlvDisplay instance. | |
const char * | getName () const |
Gets the resource name. | |
void | lock () |
Locks the resource. | |
virtual void | setName (const char *name) |
Sets the name of the resource. | |
virtual void | unLock () |
Unlocks the resource. |
Resource class.
Library: display
Resources should be used in Rogue Wave Views in the following manner:
IlvDisplay
instance to allocate a resource for you. If this resource already exists in the system (that is, you ask for a color that is already in use in a palette somewhere), no further allocation is done, and the existing resource is returned. IlvDisplay
object that this resource must be kept safe. IlvResource
objects have a member function lock
for this purpose. Resource objects are maintained by the IlvDisplay
instances of your application. They are allocated and released in your display system by specific mechanisms of the IlvDisplay
class.
You will notice that very few resources actually have constructors. This is because resources are managed by the IlvDisplay
object used by your application, so that resource creation and destruction are performed transparently for the end user.
IlvDisplay
. IlvDisplay* IlvResource::getDisplay | ( | ) | const |
Gets the IlvDisplay
instance.
IlvDisplay
instance that has created this resource. const char* IlvResource::getName | ( | ) | const |
Gets the resource name.
Returns the name of the resource. The IlvDisplay
object has a set of resource-specific member functions that let you obtain a resource through its name. The IlvDisplay
object also includes numerous member functions that let you start to work with predefined resources such as colors, line styles, and patterns. These predefined resources let you start your application without having to allocate resources.
void IlvResource::lock | ( | ) |
Locks the resource.
Ensures that this resource will not be destroyed before it is unlocked.
This function increments a reference count initially set to 0
. When you keep a pointer on a resource (because you store it in the field of an object or it is in a variable), you should lock this resource so that it cannot be destroyed by another object using it. When you do not need the resource any more, you should release it with a call to unLock
; if the lock you just removed was the last one, Rogue Wave Views will free the resource.
virtual void IlvResource::setName | ( | const char * | name | ) | [virtual] |
virtual void IlvResource::unLock | ( | ) | [virtual] |
Unlocks the resource.
This function decrements the reference count of the resource, and deletes it if this count becomes 0
. Resource management is closely concerned with the way resources are locked and unlocked. Whenever you need a specific resource in one of your persistent objects, you should use this mechanism to make sure that it will stay safe within your IlvDisplay
instance. If your application needs more than one instance of IlvDisplay
, you have to create resources within each environment, since resources cannot be shared between the different IlvDisplay
contexts.
Reimplemented in IlvPalette, and IlvColor.
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.