The user of my library calls a generic method to retrieve resources from outside the application.
They receive these resources in form of a Resource
instance for each resource. These instances can be any subtype of Resource
; this allows storing images in RAM differently from sounds, etc...
The issue is this runs behind the scenes, thus the user does nothing beyond calling getResource(String)
method.
Possible ways to identify the resource-type:
instanceof
operator (user action)- passing on a type enum on the resource (allows using switches, etc.)
- having the user pass in the type they want the resource loaded (not applicable here)
Question: What other ways are there for me to tell the user what type his resource is?
Addendum: The correct resource type is determined by the code that loads the data from disc. If anyone cares, it first checks the filetype and then makes another check on the raw data looking for magic numbers and such. The user will e.g. store a .png in the container and receive a ready-loaded and compressed RGBA8 texture.