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

Integer set that can be empty and can contain the empty value as long as it is representable as an integer. More...

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

Public Member Functions

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

Protected Member Functions

 IntTraitSet () noexcept
 Constructs empty trait set. More...
 
 IntTraitSet (int32_t nValue) noexcept
 Constructs trait set with one value. More...
 
 IntTraitSet (int32_t nFromValue, int32_t nToValue) noexcept
 Constructs trait set with ordered value range. More...
 
 IntTraitSet (int32_t nFromValue, int32_t nToValue, int32_t nStep) noexcept
 Constructs trait set with ordered stepped value range. More...
 
 IntTraitSet (const std::vector< int32_t > &aValues) noexcept
 Constructs trait set with array of values. More...
 
 IntTraitSet (const IntSet &oIntSet) noexcept
 Constructs trait set from an integer set. More...
 
 IntTraitSet (IntSet &&oIntSet) noexcept
 Constructs trait set from an integer set. More...
 
 IntTraitSet (const IntTraitSet &oSource) noexcept=default
 
 IntTraitSet (IntTraitSet &&oSource) noexcept=default
 
IntTraitSetoperator= (const IntTraitSet &oSource) noexcept=default
 
IntTraitSetoperator= (IntTraitSet &&oSource) noexcept=default
 
bool hasValue (int32_t nValue) const noexcept
 
virtual std::pair< bool, int32_t > getTraitValue (const Tile &oTile) const noexcept=0
 Either the value of the tile's trait or empty. More...
 
virtual void setTileTraitValue (Tile &oTile, int32_t nValue) const noexcept=0
 Sets the tile's trait value. More...
 
virtual void resetTileTraitValue (Tile &oTile) const noexcept=0
 Sets the tile's trait to empty. More...
 

Detailed Description

Integer set that can be empty and can contain the empty value as long as it is representable as an integer.

Constructor & Destructor Documentation

◆ IntTraitSet() [1/9]

stmg::IntTraitSet::IntTraitSet ( )
inlineprotectednoexcept

Constructs empty trait set.

◆ IntTraitSet() [2/9]

stmg::IntTraitSet::IntTraitSet ( int32_t  nValue)
inlineexplicitprotectednoexcept

Constructs trait set with one value.

Parameters
nValueThe value.

◆ IntTraitSet() [3/9]

stmg::IntTraitSet::IntTraitSet ( int32_t  nFromValue,
int32_t  nToValue 
)
inlineprotectednoexcept

Constructs trait set with ordered value range.

Value at index 0 is nFromValue, the last is nToValue. Parameter nFromValue can be > nToValue.

Parameters
nFromValueThe start value.
nToValueThe end value.

◆ IntTraitSet() [4/9]

stmg::IntTraitSet::IntTraitSet ( int32_t  nFromValue,
int32_t  nToValue,
int32_t  nStep 
)
inlineprotectednoexcept

Constructs trait set with ordered stepped value range.

Value at index 0 is nFromValue, value at index 1 is nFromValue + nStep provided it isn't past nToValue, etc.

Parameters
nFromValueThe start value.
nToValueThe end value.
nStepThe step between generated values. Can be < 0.

◆ IntTraitSet() [5/9]

stmg::IntTraitSet::IntTraitSet ( const std::vector< int32_t > &  aValues)
inlineexplicitprotectednoexcept

Constructs trait set with array of values.

Parameters
aValuesThe values.

◆ IntTraitSet() [6/9]

stmg::IntTraitSet::IntTraitSet ( const IntSet oIntSet)
inlineexplicitprotectednoexcept

Constructs trait set from an integer set.

Parameters
oIntSetThe set.

◆ IntTraitSet() [7/9]

stmg::IntTraitSet::IntTraitSet ( IntSet &&  oIntSet)
inlineexplicitprotectednoexcept

Constructs trait set from an integer set.

Parameters
oIntSetThe set.

◆ IntTraitSet() [8/9]

stmg::IntTraitSet::IntTraitSet ( const IntTraitSet oSource)
protecteddefaultnoexcept

◆ IntTraitSet() [9/9]

stmg::IntTraitSet::IntTraitSet ( IntTraitSet &&  oSource)
protecteddefaultnoexcept

Member Function Documentation

◆ dump()

void stmg::IntTraitSet::dump ( int32_t  nIndentSpaces,
bool  bHeader 
) const
overridevirtualnoexcept

Dumps the trait set.

This only works if NDEBUG macro is not defined.

Implements stmg::TraitSet.

Reimplemented in stmg::ColorChannelTraitSet< 0 >, stmg::ColorChannelTraitSet< 1 >, stmg::ColorChannelTraitSet< 2 >, stmg::NotEmptyIntTraitSet, and stmg::ThetaTraitSet.

◆ getIndexOfTileTraitValue()

int32_t stmg::IntTraitSet::getIndexOfTileTraitValue ( const Tile oTile) const
inlinefinaloverridevirtualnoexcept

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.

Implements stmg::TraitSet.

◆ getTotValues()

int32_t stmg::IntTraitSet::getTotValues ( ) const
inlineoverridevirtualnoexcept

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.

Implements stmg::TraitSet.

Reimplemented in stmg::NotEmptyIntTraitSet, and stmg::ThetaTraitSet.

◆ getTraitValue()

virtual std::pair<bool, int32_t> stmg::IntTraitSet::getTraitValue ( const Tile oTile) const
protectedpure virtualnoexcept

◆ hasEmptyValue()

bool stmg::IntTraitSet::hasEmptyValue ( ) const
inlineoverridevirtualnoexcept

Whether the trait set contains the empty value.

Default implementation returns false. If a subclass of this class can contain the empty value override the function.

Returns
Whether the set contains the empty value.

Implements stmg::TraitSet.

Reimplemented in stmg::NotEmptyIntTraitSet, and stmg::ThetaTraitSet.

◆ hasValue()

bool stmg::IntTraitSet::hasValue ( int32_t  nValue) const
inlineprotectednoexcept

◆ operator=() [1/2]

IntTraitSet& stmg::IntTraitSet::operator= ( const IntTraitSet oSource)
protecteddefaultnoexcept

◆ operator=() [2/2]

IntTraitSet& stmg::IntTraitSet::operator= ( IntTraitSet &&  oSource)
protecteddefaultnoexcept

◆ resetTileTraitValue()

virtual void stmg::IntTraitSet::resetTileTraitValue ( Tile oTile) const
protectedpure virtualnoexcept

Sets the tile's trait to empty.

Parameters
oTileThe tile to modify.

Implemented in stmg::NotEmptyIntTraitSet, stmg::AlphaTraitSet, stmg::FontTraitSet, stmg::GammaTraitSet, and stmg::ThetaTraitSet.

◆ setTileTraitValue()

virtual void stmg::IntTraitSet::setTileTraitValue ( Tile oTile,
int32_t  nValue 
) const
protectedpure virtualnoexcept

◆ setTileTraitValueByIndex()

bool stmg::IntTraitSet::setTileTraitValueByIndex ( Tile oTile,
int32_t  nIdx 
) const
inlinefinaloverridevirtualnoexcept

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.

Implements stmg::TraitSet.