stmm-games-doc  0.32.0
Public Member Functions | List of all members
stmg::TraitSet Class Referenceabstract

Ordered set of a tile's trait values. More...

Inheritance diagram for stmg::TraitSet:
Inheritance graph
[legend]

Public Member Functions

virtual ~TraitSet () noexcept=default
 
virtual int32_t getTotValues () const noexcept=0
 Get the total number of values in this tile trait indexed set. More...
 
virtual bool hasEmptyValue () const noexcept=0
 Whether the set contains the empty value. More...
 
virtual bool setTileTraitValueByIndex (Tile &oTile, int32_t nIdx) const noexcept=0
 Sets the trait of a tile to the value identified by an index. More...
 
virtual int32_t getIndexOfTileTraitValue (const Tile &oTile) const noexcept=0
 Gets the index of the value of the tile's trait in the set. More...
 
virtual void dump (int32_t nIndentSpaces, bool bHeader) const noexcept=0
 Dumps the trait set. More...
 

Detailed Description

Ordered set of a tile's trait values.

A trait value is of type int32_t, but it can also be 'empty'. The values are ordered and have an index. The index of the empty value, if present, is always -1.

Constructor & Destructor Documentation

◆ ~TraitSet()

virtual stmg::TraitSet::~TraitSet ( )
virtualdefaultnoexcept

Member Function Documentation

◆ dump()

virtual void stmg::TraitSet::dump ( int32_t  nIndentSpaces,
bool  bHeader 
) const
pure virtualnoexcept

◆ getIndexOfTileTraitValue()

virtual int32_t stmg::TraitSet::getIndexOfTileTraitValue ( const Tile oTile) const
pure virtualnoexcept

Gets the index of the value of the tile's trait in the set.

If the tile's trait is empty and the set contains the empty value index -1 is returned.

Parameters
oTileThe tile the trait's value of which the index of is needed.
Returns
The index or -2 if trait value not in the trait set.

Implemented in stmg::ColorTraitSet, stmg::ColorRgbTraitSet, stmg::CharTraitSet, and stmg::IntTraitSet.

◆ getTotValues()

virtual int32_t stmg::TraitSet::getTotValues ( ) const
pure virtualnoexcept

Get the total number of values in this tile trait indexed set.

The empty value, if present, is also counted.

Returns
The number of values. Is >= 0.

Implemented in stmg::ColorTraitSet, stmg::ColorRgbTraitSet, stmg::NotEmptyIntTraitSet, stmg::CharTraitSet, stmg::AlphaTraitSet, stmg::FontTraitSet, stmg::GammaTraitSet, stmg::ThetaTraitSet, and stmg::IntTraitSet.

◆ hasEmptyValue()

virtual bool stmg::TraitSet::hasEmptyValue ( ) const
pure virtualnoexcept

Whether the set contains the empty value.

Returns
Whether the set contains the empty value.

Implemented in stmg::ColorTraitSet, stmg::ColorRgbTraitSet, stmg::NotEmptyIntTraitSet, stmg::CharTraitSet, stmg::AlphaTraitSet, stmg::FontTraitSet, stmg::GammaTraitSet, stmg::ThetaTraitSet, and stmg::IntTraitSet.

◆ setTileTraitValueByIndex()

virtual bool stmg::TraitSet::setTileTraitValueByIndex ( Tile oTile,
int32_t  nIdx 
) const
pure virtualnoexcept

Sets the trait of a tile to the value identified by an index.

If the set contains the empty value the valid indexes are >=-1 and < (getTotValues()-1).

If the set doesn't contain the empty value the valid indexes are >=0 and < getTotValues().

If the -1 index is passed for a set without empty value, the tile is left untouched and false is returned, otherwise true is returned.

Parameters
oTileThe tile to modify.
nIdxThe index of the value in the set.
Returns
Whether the operation was successful.

Implemented in stmg::ColorTraitSet, stmg::ColorRgbTraitSet, stmg::CharTraitSet, and stmg::IntTraitSet.