Resource Generator: Class Usage

PreviousNext
The following descriptions assume that your input file was named resources.xml and the classes were generated with
em_resource_generator resources.xml

Resources Singleton

After you have generated the classes resources.e and shared_resources.e with the EiffelMedia resource generator, you should inherit from SHARED_RESOURCES in every class you would like to access resources from. When you inherit from SHARED_RESOURCES, you will have the object "resources" available in your class.

Load resources

There are different ways to to load resources. The easiest way is to call

resources.load_all
which will load all resources.
You can also load a section by calling
resources.load_sectionname
If you want to have more control over loading, you can load the resources one by one. In order to do this, you call
resources.start_loading_sectionename
followed by several
resources.load_next_sectionname_resource
until all resources in a section are loaded, which can be checked with
resources.is_sectionname_loaded
The current progress of loading can be accessed with
resources.sectionname_progress
Note: When loading music and sound resources you have to pay attention that you fulfil all requirements when loading EM_MUSIC and EM_SOUND instances. If you're using the EM_MUSIC_PLAYER and EM_SOUND_PLAYER you probably don't want to load these resources, because you just need the paths of the audio files.
See Audio Documentation for details.

Access Resources

After the resources have been loaded, they're accessible through the corresponding attributes.

Free Resources

The resources can be freed using the features free_sectionname, which will just set the references to void, so the garbage collector can do his work.