Implementation of the BigResourceList structure and its supporting functions, along with the Big Resource Manager functions, BigResourceManager_Clear(), BigResourceManager_AddResource(), and BigResourceManager_GetResource(), used in the Flyweight Pattern. More...
Go to the source code of this file.
Classes | |
struct | BigResourceList |
Represents an expandable list of pointers to BigResource objects. Use the BigResourceList_Clear() to free up the resources in the list. Use the BigResourceList_AddResource() to add a BigResource object to the list (and also take ownership of the BigResource object). More... | |
Functions | |
static void | BigResourceList_Clear (BigResourceList *resourceList) |
Clear the given BigResourceList object by freeing up all allocated BigResource objects and resetting the list to a "new" state so it can be reused. | |
static int | BigResourceList_AddResource (BigResourceList *resourceList, BigResource *resource) |
Add a BigResource object to the given BigResourceList object. The list takes ownership of the BigResource object and is responsible for releasing all memory associated with it. | |
void | BigResourceManager_Clear (void) |
Release all resources owned by the Big Resource Manager. | |
int | BigResourceManager_AddResource (BigResource *rawResource) |
Add a new big resource and return the ID of the resource. If the resource is successfully added, the Big Resource Manager owns the resource and will free it on exit. | |
BigResource * | BigResourceManager_GetResource (int bigResourceId) |
Retrieve the requested big resource. | |
Variables | |
static BigResourceList | _resources = { 0 } |
A list of BigResource objects. Initialized by a call to the BigResourceList_AddResource(). This is used by the BigResourceManager_GetResource() to retrieve a BigResource object. | |
Implementation of the BigResourceList structure and its supporting functions, along with the Big Resource Manager functions, BigResourceManager_Clear(), BigResourceManager_AddResource(), and BigResourceManager_GetResource(), used in the Flyweight Pattern.
Definition in file Flyweight_BigResourceManager.c.
|
static |
Add a BigResource object to the given BigResourceList object. The list takes ownership of the BigResource object and is responsible for releasing all memory associated with it.
This is called from the BigResourceManager_AddResource() function.
resourceList | The BigResourceList object to add to. |
resource | The BigResource object to add to the BigResourceList. |
Definition at line 69 of file Flyweight_BigResourceManager.c.
References BigResourceList::resources, and BigResourceList::resources_count.
Referenced by BigResourceManager_AddResource().
|
static |
Clear the given BigResourceList object by freeing up all allocated BigResource objects and resetting the list to a "new" state so it can be reused.
This is called from the BigResourceManager_Clear() function.
resourceList | A pointer to the BigResourceList to be cleared. |
Definition at line 44 of file Flyweight_BigResourceManager.c.
References BigResource_Clear(), BigResourceList::resources, and BigResourceList::resources_count.
Referenced by BigResourceManager_Clear().
int BigResourceManager_AddResource | ( | BigResource * | rawResource | ) |
Add a new big resource and return the ID of the resource. If the resource is successfully added, the Big Resource Manager owns the resource and will free it on exit.
rawResource | The BigResource object to add. |
Definition at line 114 of file Flyweight_BigResourceManager.c.
References _resources, and BigResourceList_AddResource().
Referenced by _Flyweight_GenerateBigResource().
void BigResourceManager_Clear | ( | void | ) |
Release all resources owned by the Big Resource Manager.
Definition at line 105 of file Flyweight_BigResourceManager.c.
References _resources, and BigResourceList_Clear().
Referenced by Flyweight_Exercise().
BigResource * BigResourceManager_GetResource | ( | int | bigResourceId | ) |
Retrieve the requested big resource.
bigResourceId | Handle to the big resource to retrieve. |
Definition at line 127 of file Flyweight_BigResourceManager.c.
References _resources, BigResourceList::resources, and BigResourceList::resources_count.
Referenced by BigResource_Render().
|
static |
A list of BigResource objects. Initialized by a call to the BigResourceList_AddResource(). This is used by the BigResourceManager_GetResource() to retrieve a BigResource object.
Definition at line 32 of file Flyweight_BigResourceManager.c.
Referenced by BigResourceManager_AddResource(), BigResourceManager_Clear(), and BigResourceManager_GetResource().