com.threerings.cast.bundle
Class BundledComponentRepository

java.lang.Object
  extended by com.threerings.cast.bundle.BundledComponentRepository
All Implemented Interfaces:
ComponentRepository, DirectionCodes

public class BundledComponentRepository
extends Object
implements DirectionCodes, ComponentRepository

A component repository implementation that obtains information from resource bundles.

See Also:
ResourceManager

Nested Class Summary
protected  class BundledComponentRepository.ResourceBundleProvider
          Instances of these provide images to our component action tilesets and frames to our components.
static class BundledComponentRepository.TileSetFrameImage
          Used to provide multiframe images using data obtained from a tileset.
 
Field Summary
protected  Map<String,ActionSequence> _actions
          A table of action sequences.
protected  Map<String,TileSet> _actionSets
          A table of action sequence tilesets.
protected  Map<String,ArrayList<CharacterComponent>> _classComps
          A table of component lists indexed on classname.
protected  Map<String,ComponentClass> _classes
          A table of component classes.
protected  IntMap<CharacterComponent> _components
          The component table.
protected  ImageManager _imgr
          We use the image manager to decode and cache images.
protected  boolean _wipeOnFailure
          Whether or not we wipe our bundles on any failure.
 
Fields inherited from interface com.threerings.util.DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST
 
Constructor Summary
BundledComponentRepository(ResourceManager rmgr, ImageManager imgr, String name)
          Constructs a repository which will obtain its resource set from the supplied resource manager.
 
Method Summary
protected  void createComponent(int componentId, String cclass, String cname, FrameProvider fprov)
          Creates a component and inserts it into the component table.
protected  BundledComponentRepository.TileSetFrameImage createTileSetFrameImage(TileSet aset, ActionSequence actseq)
           
 Iterator<ActionSequence> enumerateActionSequences()
          Iterates over the ActionSequence instances representing every available action sequence.
 Iterator<ComponentClass> enumerateComponentClasses()
          Iterates over the ComponentClass instances representing all available character component classes.
 Iterator<Integer> enumerateComponentIds(ComponentClass compClass)
          Iterates over the component ids of all components in the specified class.
 CharacterComponent getComponent(int componentId)
          Returns the CharacterComponent object for the given component identifier.
 CharacterComponent getComponent(String className, String compName)
          Returns the CharacterComponent object with the given component class and name.
 ComponentClass getComponentClass(String className)
          Returns the ComponentClass with the specified name or null if none exists with that name.
 void setWipeOnFailure(boolean wipeOnFailure)
          Configures the bundled component repository to wipe any bundles that report certain kinds of failure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_imgr

protected ImageManager _imgr
We use the image manager to decode and cache images.


_actions

protected Map<String,ActionSequence> _actions
A table of action sequences.


_actionSets

protected Map<String,TileSet> _actionSets
A table of action sequence tilesets.


_classes

protected Map<String,ComponentClass> _classes
A table of component classes.


_classComps

protected Map<String,ArrayList<CharacterComponent>> _classComps
A table of component lists indexed on classname.


_components

protected IntMap<CharacterComponent> _components
The component table.


_wipeOnFailure

protected boolean _wipeOnFailure
Whether or not we wipe our bundles on any failure.

Constructor Detail

BundledComponentRepository

public BundledComponentRepository(ResourceManager rmgr,
                                  ImageManager imgr,
                                  String name)
                           throws IOException
Constructs a repository which will obtain its resource set from the supplied resource manager.

Parameters:
rmgr - the resource manager from which to obtain our resource set.
imgr - the image manager that we'll use to decode and cache images.
name - the name of the resource set from which we will be loading our component data.
Throws:
IOException - thrown if an I/O error occurs while reading our metadata from the resource bundles.
Method Detail

setWipeOnFailure

public void setWipeOnFailure(boolean wipeOnFailure)
Configures the bundled component repository to wipe any bundles that report certain kinds of failure. In the event that an unpacked bundle becomes corrupt, this is useful in that it will force the bundle to be unpacked on the next application invocation, potentially remedying the problem of a corrupt unpacking.


getComponent

public CharacterComponent getComponent(int componentId)
                                throws NoSuchComponentException
Description copied from interface: ComponentRepository
Returns the CharacterComponent object for the given component identifier.

Specified by:
getComponent in interface ComponentRepository
Throws:
NoSuchComponentException

getComponent

public CharacterComponent getComponent(String className,
                                       String compName)
                                throws NoSuchComponentException
Description copied from interface: ComponentRepository
Returns the CharacterComponent object with the given component class and name.

Specified by:
getComponent in interface ComponentRepository
Throws:
NoSuchComponentException

getComponentClass

public ComponentClass getComponentClass(String className)
Description copied from interface: ComponentRepository
Returns the ComponentClass with the specified name or null if none exists with that name.

Specified by:
getComponentClass in interface ComponentRepository

enumerateComponentClasses

public Iterator<ComponentClass> enumerateComponentClasses()
Description copied from interface: ComponentRepository
Iterates over the ComponentClass instances representing all available character component classes.

Specified by:
enumerateComponentClasses in interface ComponentRepository

enumerateActionSequences

public Iterator<ActionSequence> enumerateActionSequences()
Description copied from interface: ComponentRepository
Iterates over the ActionSequence instances representing every available action sequence.

Specified by:
enumerateActionSequences in interface ComponentRepository

enumerateComponentIds

public Iterator<Integer> enumerateComponentIds(ComponentClass compClass)
Description copied from interface: ComponentRepository
Iterates over the component ids of all components in the specified class.

Specified by:
enumerateComponentIds in interface ComponentRepository

createComponent

protected void createComponent(int componentId,
                               String cclass,
                               String cname,
                               FrameProvider fprov)
Creates a component and inserts it into the component table.


createTileSetFrameImage

protected BundledComponentRepository.TileSetFrameImage createTileSetFrameImage(TileSet aset,
                                                                               ActionSequence actseq)