Represents a manager for big resources. Also provides the class factory for the Flyweight_Class instances that are associated with a particular big resource. More...
Static Public Member Functions | |
static int | AddResource (List< string > rawResource) |
Add a new big resource and return the ID of the resource. | |
static ? Flyweight_Class | CreateFlyweight (int bigResourceId, Flyweight_Context context) |
Create a new instance of the Flyweight_Class associated with the given big resource and a context, in this case an X,Y position. | |
Static Package Functions | |
static ? BigResource | FindResource (int resourceId) |
Retrieve the BigResource corresponding to the specified ID. | |
Static Private Member Functions | |
static int | GetNextResourceId () |
Retrieve the next resource ID that can be used. | |
Static Private Attributes | |
static List< BigResource > | _resources = new List<BigResource>() |
A list of all big resources managed by this class. | |
static int | _nextResourceId = 1 |
The next ID to assign a raw resource for management. | |
Represents a manager for big resources. Also provides the class factory for the Flyweight_Class instances that are associated with a particular big resource.
Note: The raw resource is provided by the caller and an ID is then associated with it. The ID is returned to the caller who then passes that ID to the Flyweight_Class factory along with a context.
In the exercise, only one big resource is ever created so this class is likely overkill for an example but it fully shows the architectural context in which a flyweight class is utilized.
Definition at line 350 of file Flyweight_Class.cs.
|
inlinestatic |
Add a new big resource and return the ID of the resource.
rawResource | The resource to add. |
Definition at line 378 of file Flyweight_Class.cs.
References BigResourceManager._resources, and BigResourceManager.GetNextResourceId().
Referenced by Flyweight_Exercise._Flyweight_GenerateBigResource().
|
inlinestatic |
Create a new instance of the Flyweight_Class associated with the given big resource and a context, in this case an X,Y position.
bigResourceId | ID of the big resource to associate with. |
context | A Flyweight_Context instance containing the context for the desired Flyweight_Class instance. |
Definition at line 417 of file Flyweight_Class.cs.
References BigResource.CreateFlyweight(), and BigResourceManager.FindResource().
Referenced by Flyweight_Exercise._Flyweight_GenerateFlyweightClasses().
|
inlinestaticpackage |
Retrieve the BigResource corresponding to the specified ID.
resourceId | ID of the big resource to find. |
Definition at line 393 of file Flyweight_Class.cs.
References BigResourceManager._resources, and BigResource.ResourceId.
Referenced by BigResourceManager.CreateFlyweight().
|
inlinestaticprivate |
Retrieve the next resource ID that can be used.
Definition at line 366 of file Flyweight_Class.cs.
References BigResourceManager._nextResourceId.
Referenced by BigResourceManager.AddResource().
|
staticprivate |
The next ID to assign a raw resource for management.
Definition at line 360 of file Flyweight_Class.cs.
Referenced by BigResourceManager.GetNextResourceId().
|
staticprivate |
A list of all big resources managed by this class.
Definition at line 355 of file Flyweight_Class.cs.
Referenced by BigResourceManager.AddResource(), and BigResourceManager.FindResource().