ImageSet

A repository of knowledge about a .tex file.  An ImageSet is a data structure that describes a .tex file and a way of knowing what is in that .tex file so that the images contained in it can be used in the rest of the game.  When a RuleSet is loaded, its ImageSets are given to the IImageEngine which manages them and provides access for the rest of the modules.

All ImageSets are accessed by ‘keys’, which are string values that name groups of images.  It may be that multiple ImageSets may have the same key if they are all extensions for a certain kind of image.  For instance, all tile images are referenced by the key ‘TileType’ and there may be several ImageSets that provide images for tiles, so they would all have the same key.

ImageSets also contain a string hash that maps a string name to the index into the images in the .tex file.  When an ImageSet is created, its hash must be filled with data that corresponds to the layout of the .tex file it is supposed to represent.  This allows for objects that need to use the images in the .tex file to ask for a particular image by name, and the hash maps the name to the index into the .tex file of the image to return.  In this way, all image requests can be done without the use of difficult and error-prone number indices, but rather through simple strings.

Project

RulesCore

Include

ImageSet.h

Summary
A repository of knowledge about a .tex file.
The ImageSet constructor.
Returns the number of images in the .tex file the ImageSet describes.
Returns the key used to group the images in the ImageSet.
Returns the file name of the .tex file the ImageSet describes.
Returns the index in the .tex file of the given image name.
Sets the index in the .tex file of the given image name.
Provides an iterator to the start of the .tex file index hash.
Provides an iterator to the end of the .tex file index hash.
The key used to group the ImageSet.
The .tex file the ImageSet describes.
The hash map of strings that name the images contained in the .tex file to their index in that .tex file.

Public

Summary
The ImageSet constructor.
Returns the number of images in the .tex file the ImageSet describes.
Returns the key used to group the images in the ImageSet.
Returns the file name of the .tex file the ImageSet describes.
Returns the index in the .tex file of the given image name.
Sets the index in the .tex file of the given image name.
Provides an iterator to the start of the .tex file index hash.
Provides an iterator to the end of the .tex file index hash.

Constructors

ImageSet

ImageSet(const wxString &key,
const wxString &file) : mKey(key), mFile(file)

The ImageSet constructor.  Stores the given key and .tex file name.

Parameters

keyThe key for this ImageSet.  See ImageSet for more details.
fileThe name of the .tex file this ImageSet describes.

Functions

numImages

wxInt32 numImages() const

Returns the number of images in the .tex file the ImageSet describes.

Returns

The number of images in the .tex file.

key

const wxString &key() const

Returns the key used to group the images in the ImageSet.

Returns

A const reference to the key of the ImageSet.

file

const wxString &file() const

Returns the file name of the .tex file the ImageSet describes.

Returns

A const reference to the name of the .tex file

index

wxInt32 index(const wxString &key) const

Returns the index in the .tex file of the given image name.

Parameters

keyThe name of the image to look up.

Returns

The index in the .tex file of the given key.  May be -1 if the key does not exist in the ImageSet.

index

void index(const wxString &key,
const wxInt32 index)

Sets the index in the .tex file of the given image name.

Parameters

keyThe name of the image in the .tex file.
indexThe index in the .tex file of the given key.

hash_begin

IntHash::const_iterator hash_begin() const

Provides an iterator to the start of the .tex file index hash.

Returns

A const_iterator to the start of the index hash.

hash_end

IntHash::const_iterator hash_end() const

Provides an iterator to the end of the .tex file index hash.

Returns

A const_iterator to the end of the index hash.

Private

Summary
The key used to group the ImageSet.
The .tex file the ImageSet describes.
The hash map of strings that name the images contained in the .tex file to their index in that .tex file.

Variables

mKey

wxString mKey

The key used to group the ImageSet.

mFile

wxString mFile

The .tex file the ImageSet describes.

mIndexHash

IntHash mIndexHash

The hash map of strings that name the images contained in the .tex file to their index in that .tex file.

ImageSet(const wxString &key,
const wxString &file) : mKey(key), mFile(file)
The ImageSet constructor.
wxInt32 numImages() const
Returns the number of images in the .tex file the ImageSet describes.
const wxString &key() const
Returns the key used to group the images in the ImageSet.
const wxString &file() const
Returns the file name of the .tex file the ImageSet describes.
wxInt32 index(const wxString &key) const
Returns the index in the .tex file of the given image name.
IntHash::const_iterator hash_begin() const
Provides an iterator to the start of the .tex file index hash.
IntHash::const_iterator hash_end() const
Provides an iterator to the end of the .tex file index hash.
wxString mKey
The key used to group the ImageSet.
wxString mFile
The .tex file the ImageSet describes.
IntHash mIndexHash
The hash map of strings that name the images contained in the .tex file to their index in that .tex file.
A repository of all things rules-related.
The interface of the image engine.
RulesCore is the HOSS of Cities3D.