Associates a context with a big resource. More...
Public Member Functions | |
void | Render (List< char[]> display, int offset_x, int image_width, int image_height, int position_x, int position_y) |
Render the image associated with this flyweight instance into the given display at the given position. | |
Package Functions | |
Flyweight_Class (BigResource resource, Flyweight_Context context) | |
Constructor (accessible only to the class factory). | |
Properties | |
Flyweight_Context | Context [get, set] |
Retrieve or set the context for this class instance. | |
int | ImageWidth [get] |
Retrieve the "image" width from underlying big resource. | |
int | ImageHeight [get] |
Retrieve the "image" height from underlying big resource. | |
Private Attributes | |
BigResource | _resource |
The big resource being referenced by this flyweight class. In C#, a class is always a reference to an instance of the class so we take advantage of that here. In other languages, this would be a pointer to the big resource or a handle from which a pointer could be obtained. | |
Flyweight_Context | _context |
The context associated with this class. The calling entity uses this context to manipulate the flyweight class. | |
Associates a context with a big resource.
Definition at line 65 of file Flyweight_Class.cs.
|
inlinepackage |
Constructor (accessible only to the class factory).
resource | The resource being represented by this class. This takes advantage of the fact that C# classes are always passed by reference so no actual copying of the resource is done. |
context | A Flyweight_Context instance containing the context for this Flyweight_Class instance. |
Definition at line 91 of file Flyweight_Class.cs.
References Flyweight_Class._context, and Flyweight_Class._resource.
|
inline |
Render the image associated with this flyweight instance into the given display at the given position.
display | A list of character arrays representing the display. |
offset_x | Offset from left edge of big resource to the left edge of the image to render. |
image_width | Width of image to render. |
image_height | Height of image to render. |
position_x | leftmost position within the display to place the upper left corner of the image, |
position_y | topmost position within the display to place the upper left corner of the image. |
Note that although this class has access to the context, it really shouldn't so as to keep a loose coupling between the context and this class. Therefore, the entity calling Render() will pass the position in as parameters even though that position is likely coming from the context.
Definition at line 165 of file Flyweight_Class.cs.
References Flyweight_Class._resource, and BigResource.Render().
Referenced by Flyweight_Exercise._Flyweight_RenderFlyweights().
|
private |
The context associated with this class. The calling entity uses this context to manipulate the flyweight class.
Definition at line 80 of file Flyweight_Class.cs.
Referenced by Flyweight_Class.Context(), Flyweight_Class.Flyweight_Class(), Flyweight_Class.ImageHeight(), and Flyweight_Class.ImageWidth().
|
private |
The big resource being referenced by this flyweight class. In C#, a class is always a reference to an instance of the class so we take advantage of that here. In other languages, this would be a pointer to the big resource or a handle from which a pointer could be obtained.
Definition at line 74 of file Flyweight_Class.cs.
Referenced by Flyweight_Class.Flyweight_Class(), Flyweight_Class.ImageHeight(), BigResource.ImageHeight(), Flyweight_Class.ImageWidth(), BigResource.ImageWidth(), Flyweight_Class.Render(), and BigResource.Render().
|
getset |
Retrieve or set the context for this class instance.
Definition at line 101 of file Flyweight_Class.cs.
Referenced by Flyweight_Exercise._Flyweight_MoveFlyweights(), and Flyweight_Exercise._Flyweight_RenderFlyweights().
|
get |
Retrieve the "image" height from underlying big resource.
Definition at line 133 of file Flyweight_Class.cs.
Referenced by Flyweight_Exercise._Flyweight_MoveFlyweights(), and Flyweight_Exercise._Flyweight_RenderFlyweights().
|
get |
Retrieve the "image" width from underlying big resource.
Definition at line 117 of file Flyweight_Class.cs.
Referenced by Flyweight_Exercise._Flyweight_MoveFlyweights(), and Flyweight_Exercise._Flyweight_RenderFlyweights().