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...
#include <Flyweight_Classes.h>
Public Types | |
using | unique_ptr_t = std::unique_ptr< BigResource > |
Public Member Functions | |
BigResource (std::vector< std::string > resource, int resourceId) | |
Constructor (accessibly only to the class factory). | |
~BigResource () | |
void | Render (std::vector< std::vector< 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. | |
int | ResourceId () |
Retrieve the resource ID for this resource. | |
int | ImageWidth () |
Retrieve the "image" width of the resource. | |
int | ImageHeight () |
Retrieve the "image" height of the resource. | |
Flyweight_Class::unique_ptr_t | CreateFlyweight (Flyweight_Context context) |
Generate a Flyweight class that will represent this big resource in some context-dependent way. | |
Private Attributes | |
std::vector< std::string > | _resource |
int | _resourceId |
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 198 of file Flyweight_Classes.h.
using unique_ptr_t = std::unique_ptr<BigResource> |
Definition at line 201 of file Flyweight_Classes.h.
|
inline |
Constructor (accessibly only to the class factory).
resource | The resource to manage. |
resourceId | ID of the resource. |
Definition at line 213 of file Flyweight_Classes.h.
References BigResource::_resource, and BigResource::_resourceId.
|
inline |
Definition at line 219 of file Flyweight_Classes.h.
Flyweight_Class::unique_ptr_t CreateFlyweight | ( | Flyweight_Context | context | ) |
Generate a Flyweight class that will represent this big resource in some context-dependent way.
context | A Flyweight_Context instance containing the context for the desired Flyweight_Class instance. |
Definition at line 145 of file Flyweight_Classes.cpp.
Referenced by BigResourceManager::CreateFlyweight().
int ImageHeight | ( | ) |
Retrieve the "image" height of the resource.
Definition at line 140 of file Flyweight_Classes.cpp.
References BigResource::_resource.
int ImageWidth | ( | ) |
Retrieve the "image" width of the resource.
Definition at line 131 of file Flyweight_Classes.cpp.
References BigResource::_resource.
void Render | ( | std::vector< std::vector< 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.
display | The display in which to render. |
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 | X position where to put upper left corner of resource. |
position_y | Y position where to put upper left corner of resource. |
Definition at line 70 of file Flyweight_Classes.cpp.
References BigResource::_resource.
Referenced by Flyweight_Class::Render().
int ResourceId | ( | ) |
Retrieve the resource ID for this resource.
Definition at line 126 of file Flyweight_Classes.cpp.
References BigResource::_resourceId.
|
private |
Definition at line 204 of file Flyweight_Classes.h.
Referenced by BigResource::BigResource(), BigResource::ImageHeight(), Flyweight_Class::ImageHeight(), BigResource::ImageWidth(), Flyweight_Class::ImageWidth(), Flyweight_Class::Render(), and BigResource::Render().
|
private |
Definition at line 205 of file Flyweight_Classes.h.
Referenced by BigResource::BigResource(), and BigResource::ResourceId().