Design Pattern Examples
Overview of object-oriented design patterns
BigResource Class Reference

Represents some big resource. In this case, a text "image" rendered as a list of strings. each entry in the list is the same width. The height of the "image" is the number of entries in the list. This image is provided by the user. More...

Collaboration diagram for BigResource:
Collaboration graph

Public Member Functions

Flyweight_Class CreateFlyweight (Flyweight_Context context)
 Generate a Flyweight class that will represent this big resource in some context-dependent way.
 

Package Functions

 BigResource (List< string > resource, int resourceId)
 Constructor (accessibly only to the class factory).
 
void Render (List< char[]> display, int offset_x, int image_width, int image_height, int position_x, int position_y)
 Render the big resource into the given display at the given position.
 

Properties

int ResourceId [get]
 Retrieve the resource ID for this resource.
 
int ImageWidth [get]
 Retrieve the "image" width of the resource.
 
int ImageHeight [get]
 Retrieve the "image" height of the resource.
 

Private Attributes

List< string > _resource
 
int _resourceId
 

Detailed Description

Represents some big resource. In this case, a text "image" rendered as a list of strings. each entry in the list is the same width. The height of the "image" is the number of entries in the list. This image is provided by the user.

The resource is represented by an ID. This ID is known by the user and is passed to the Flyweight_Class factory so the Flyweight_Class can get a reference to an instance of this BigResource class. Instances of this BigResource class are managed through the BigResourceManager class.

Definition at line 192 of file Flyweight_Class.cs.

Constructor & Destructor Documentation

◆ BigResource()

BigResource ( List< string >  resource,
int  resourceId 
)
inlinepackage

Constructor (accessibly only to the class factory).

Parameters
resourceThe resource to manage.
resourceIdID of the resource.

Definition at line 202 of file Flyweight_Class.cs.

References BigResource._resource, and BigResource._resourceId.

Member Function Documentation

◆ CreateFlyweight()

Flyweight_Class CreateFlyweight ( Flyweight_Context  context)
inline

Generate a Flyweight class that will represent this big resource in some context-dependent way.

Parameters
contextA Flyweight_Context instance containing the context for the desired Flyweight_Class instance.
Returns
A new instance of the Flyweight_Class.

Definition at line 322 of file Flyweight_Class.cs.

Referenced by BigResourceManager.CreateFlyweight().

◆ Render()

void Render ( List< char[]>  display,
int  offset_x,
int  image_width,
int  image_height,
int  position_x,
int  position_y 
)
inlinepackage

Render the big resource into the given display at the given position.

Parameters
displayThe display in which to render.
offset_xOffset from left edge of big resource to the left edge of the image to render.
image_widthWidth of image to render.
image_heightHeight of image to render.
position_xX position where to put upper left corner of resource.
position_yY position where to put upper left corner of resource.

Definition at line 218 of file Flyweight_Class.cs.

References BigResource._resource.

Referenced by Flyweight_Class.Render().

Member Data Documentation

◆ _resource

◆ _resourceId

int _resourceId
private

Definition at line 195 of file Flyweight_Class.cs.

Referenced by BigResource.BigResource(), and BigResource.ResourceId().

Property Documentation

◆ ImageHeight

int ImageHeight
get

Retrieve the "image" height of the resource.

Definition at line 303 of file Flyweight_Class.cs.

◆ ImageWidth

int ImageWidth
get

Retrieve the "image" width of the resource.

Definition at line 288 of file Flyweight_Class.cs.

◆ ResourceId

int ResourceId
get

Retrieve the resource ID for this resource.

Definition at line 277 of file Flyweight_Class.cs.

Referenced by BigResourceManager.FindResource().


The documentation for this class was generated from the following file: