Eris::InnerTerrainMod Class Reference

Base class for all terrain mod specific classes.This is not meant to be used directly by anything else than the TerrainMod class. The TerrainMod class in itself doesn't hold the actual reference to the terrain mod, and doesn't handle the final parsing of Atlas data. This is instead handled by the different subclasses of this class. Since the different kinds of terrain mods found in Mercator behave differently depending on their type and the kind of shape used, we need to separate the code for handling them into different classes. More...

#include <TerrainMod.h>

Inheritance diagram for Eris::InnerTerrainMod:

Eris::InnerTerrainModAdjust Eris::InnerTerrainModCrater Eris::InnerTerrainModLevel Eris::InnerTerrainModSlope

List of all members.

Public Member Functions

virtual ~InnerTerrainMod ()
 Dtor.
const std::string & getTypename () const
 Gets the type of terrain mod handled by this.
virtual bool parseAtlasData (const Atlas::Message::MapType &modElement)=0
 Tries to parse the Atlas data.
virtual Mercator::TerrainMod * getModifier ()=0
 Accessor for the Mercator::TerrainMod created and held by this instance.

Protected Member Functions

 InnerTerrainMod (TerrainMod &terrainMod, const std::string &typemod)
 Ctor.
const std::string & parseShape (const Atlas::Message::MapType &modElement, const Atlas::Message::Element **shapeMap)
 Parses the atlas data of the modifiers, finding the base atlas element for the shape definition, and returning the kind of shape specified.
WFMath::Point< 3 > parsePosition (const Atlas::Message::MapType &modElement)
 Parses the position of the mod.

Protected Attributes

std::string mTypeName
 The type of mod this instance handles.
TerrainModmTerrainMod
 The TerrainMod instance to which this instance belongs.


Detailed Description

Base class for all terrain mod specific classes.This is not meant to be used directly by anything else than the TerrainMod class. The TerrainMod class in itself doesn't hold the actual reference to the terrain mod, and doesn't handle the final parsing of Atlas data. This is instead handled by the different subclasses of this class. Since the different kinds of terrain mods found in Mercator behave differently depending on their type and the kind of shape used, we need to separate the code for handling them into different classes.

Author:
Erik Hjortsberg <erik.hjortsberg@iteam.se>

Constructor & Destructor Documentation

Eris::InnerTerrainMod::InnerTerrainMod ( TerrainMod terrainMod,
const std::string &  typemod 
) [protected]

Ctor.

This is protected to prevent any other class than subclasses of this to call it.

Parameters:
terrainMod The TerrainMod instance to which this instance belongs to.
typemod The type of terrainmod this handles, such as "cratermod" or "slopemod. This will be stored in mTypeName.


Member Function Documentation

virtual Mercator::TerrainMod* Eris::InnerTerrainMod::getModifier (  )  [pure virtual]

Accessor for the Mercator::TerrainMod created and held by this instance.

If no terrain mod could be created, such as with faulty Atlas data, or if parseAtlasData() hasn't been called yet, this will return a null pointer.

Returns:
A pointer to the TerrainMod held by this instance, or null if none created.

Implemented in Eris::InnerTerrainModSlope, Eris::InnerTerrainModCrater, Eris::InnerTerrainModLevel, and Eris::InnerTerrainModAdjust.

Referenced by Eris::TerrainMod::getMod().

const std::string & Eris::InnerTerrainMod::getTypename (  )  const

Gets the type of terrain mod handled by this.

This corresponds to the "type" attribute of the "terrainmod" atlas attribute, for example "cratermod" or "slopemod". Internally, it's stored in the mTypeName field, as set through the constructor.

Returns:
The type of mod handled by any instance of this.

References mTypeName.

virtual bool Eris::InnerTerrainMod::parseAtlasData ( const Atlas::Message::MapType &  modElement  )  [pure virtual]

Tries to parse the Atlas data.

It's up to the specific subclasses to provide proper parsing of the data depending on their needs. If the data is successfully parsed, a new Mercator::TerrainMod instance will be created.

Parameters:
modElement The Atlas element describing the terrainmod. This should in most instances correspond directly to the "terrainmod" element found in the root atlas attribute map.
Returns:
If the parsing was successful, true will be returned, and a new Mercator::TerrainMod will have been created, else false.

Implemented in Eris::InnerTerrainModSlope, Eris::InnerTerrainModCrater, Eris::InnerTerrainModLevel, and Eris::InnerTerrainModAdjust.

Referenced by Eris::TerrainMod::parseMod().

WFMath::Point< 3 > Eris::InnerTerrainMod::parsePosition ( const Atlas::Message::MapType &  modElement  )  [protected]

Parses the position of the mod.

If no height data is given the height of the entity the mod belongs to will be used. If however a "height" value is set, that will be used instead. If no "height" value is set, but a "heightoffset" is present, that value will be added to the height set by the position of the entity the mod belongs to.

Parameters:
modElement The top mod element.
Returns:
The position of the mod, where the height has been adjusted.

If the height is specified use that, else check for a height offset. If none is found, use the default height of the entity position

References Eris::TerrainMod::getEntity(), Eris::Entity::getPosition(), and mTerrainMod.

Referenced by Eris::InnerTerrainModLevel::parseAtlasData(), Eris::InnerTerrainModSlope::parseAtlasData(), and Eris::InnerTerrainModCrater::parseAtlasData().

const std::string & Eris::InnerTerrainMod::parseShape ( const Atlas::Message::MapType &  modElement,
const Atlas::Message::Element **  shapeMap 
) [protected]

Parses the atlas data of the modifiers, finding the base atlas element for the shape definition, and returning the kind of shape specified.

This is an utility method to help with those many cases where we need to parse the shape data in order to determine the kind of shape. The actual parsing and creation of the shape happens in InnerTerrainMod_impl however, since that depends on templated calls. However, in order to know what kind of template to use we must first look at the type of shape, thus the need for this method.

Parameters:
modElement The atlas element containing the modifier.
shapeMap A shape data is found, and it's in the map form, it will be put here.
Returns:
The name of the shape, or an empty string if no valid data could be found.

Referenced by Eris::InnerTerrainModAdjust::parseAtlasData(), Eris::InnerTerrainModLevel::parseAtlasData(), Eris::InnerTerrainModSlope::parseAtlasData(), and Eris::InnerTerrainModCrater::parseAtlasData().


Member Data Documentation

std::string Eris::InnerTerrainMod::mTypeName [protected]

The type of mod this instance handles.

See also:
getTypename()

Referenced by getTypename().


The documentation for this class was generated from the following files:

Generated for Eris by  doxygen 1.5.8