Design Pattern Examples
Overview of object-oriented design patterns
Flyweight_BigResourceManager.h File Reference

Declaration of the Big Resource Manager functions, BigResourceManager_Clear(), BigResourceManager_AddResource(), and BigResourceManager_GetResource(), used in the Flyweight Pattern. More...

#include <stdbool.h>
#include "Flyweight_BigResource.h"
#include "Flyweight_Image.h"
Include dependency graph for Flyweight_BigResourceManager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __FLYWEIGHT_BIGRESOURCEMANAGER_H__
 

Functions

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.
 
BigResourceBigResourceManager_GetResource (int bigResourceId)
 Retrieve the requested big resource.
 

Detailed Description

Declaration of the Big Resource Manager functions, BigResourceManager_Clear(), BigResourceManager_AddResource(), and BigResourceManager_GetResource(), used in the Flyweight Pattern.

Definition in file Flyweight_BigResourceManager.h.

Macro Definition Documentation

◆ __FLYWEIGHT_BIGRESOURCEMANAGER_H__

#define __FLYWEIGHT_BIGRESOURCEMANAGER_H__

Definition at line 9 of file Flyweight_BigResourceManager.h.

Function Documentation

◆ BigResourceManager_AddResource()

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.

Parameters
rawResourceThe BigResource object to add.
Returns
Returns the handle to the new big resource added to the manager. Returns -1 if something went wrong (typically an out of memory condition).

Definition at line 114 of file Flyweight_BigResourceManager.c.

References _resources, and BigResourceList_AddResource().

Referenced by _Flyweight_GenerateBigResource().

◆ BigResourceManager_Clear()

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().

◆ BigResourceManager_GetResource()

BigResource * BigResourceManager_GetResource ( int  bigResourceId)

Retrieve the requested big resource.

Parameters
bigResourceIdHandle to the big resource to retrieve.
Returns
Returns a pointer to the big resource if found; otherwise, returns NULL.

Definition at line 127 of file Flyweight_BigResourceManager.c.

References _resources, BigResourceList::resources, and BigResourceList::resources_count.

Referenced by BigResource_Render().