OpenTTD Source 20260421-master-gc2fbc6fdeb
WindowNumber Struct Reference

Number to differentiate different windows of the same class. More...

#include <window_type.h>

Public Member Functions

 WindowNumber ()=default
 Create a WindowNumber 0.
 WindowNumber (int32_t value)
 Create a WindowNumber with the given value.
 WindowNumber (ConvertibleThroughBase auto value)
 Create a WindowNumber with the given value.
template<typename T>
 WindowNumber (T value)
 Create a WindowNumber with the given value.
 operator int32_t () const
 Automatically convert to int32_t.
template<typename T>
 operator T () const
 Automatically convert to any other type that might be requested.
constexpr bool operator== (const std::integral auto &rhs) const
 Compare the right hand side against our window number.
constexpr bool operator== (const ConvertibleThroughBase auto &rhs) const
 Compare the right hand side against our window number.
template<typename T>
constexpr bool operator== (const T &rhs) const
 Compare the right hand side against our window number.

Private Attributes

int32_t value = 0
 The identifier of the window.

Detailed Description

Number to differentiate different windows of the same class.

This number generally implicitly passes some information, e.g. the TileIndex or Company associated with the window. To ease this use, the window number is lenient with what it accepts and broad with what it returns.

Anything that converts into a number and ConvertibleThroughBase types will be accepted. When it's being used it returns int32_t or any other type when that's specifically requested, e.g. VehicleType type = window_number or GetEngineListHeight(window_number) in which the returned value will be a VehicleType.

Definition at line 761 of file window_type.h.

Constructor & Destructor Documentation

◆ WindowNumber() [1/3]

WindowNumber::WindowNumber ( int32_t value)
inline

Create a WindowNumber with the given value.

Parameters
valueThe new window number.

Definition at line 772 of file window_type.h.

References value.

◆ WindowNumber() [2/3]

WindowNumber::WindowNumber ( ConvertibleThroughBase auto value)
inline

Create a WindowNumber with the given value.

Parameters
valueThe new window number.

Definition at line 774 of file window_type.h.

References value.

◆ WindowNumber() [3/3]

template<typename T>
WindowNumber::WindowNumber ( T value)
inline

Create a WindowNumber with the given value.

Parameters
valueThe new window number.

Definition at line 777 of file window_type.h.

References T, to_underlying(), and value.

Member Function Documentation

◆ operator int32_t()

WindowNumber::operator int32_t ( ) const
inline

Automatically convert to int32_t.

Returns
The window number.

Definition at line 783 of file window_type.h.

References value.

◆ operator T()

template<typename T>
WindowNumber::operator T ( ) const
inline

Automatically convert to any other type that might be requested.

Returns
The window number in the requested type.

Definition at line 790 of file window_type.h.

References T, and value.

◆ operator==() [1/3]

bool WindowNumber::operator== ( const ConvertibleThroughBase auto & rhs) const
inlineconstexpr

Compare the right hand side against our window number.

Parameters
rhsThe other value to compare to.
Returns
true iff the underlying window number matches the underlying value.

Definition at line 799 of file window_type.h.

◆ operator==() [2/3]

bool WindowNumber::operator== ( const std::integral auto & rhs) const
inlineconstexpr

Compare the right hand side against our window number.

Parameters
rhsThe other value to compare to.
Returns
true iff the underlying window number matches the underlying value.

Definition at line 797 of file window_type.h.

◆ operator==() [3/3]

template<typename T>
bool WindowNumber::operator== ( const T & rhs) const
inlineconstexpr

Compare the right hand side against our window number.

Parameters
rhsThe other value to compare to.
Returns
true iff the underlying window number matches the underlying value.

Definition at line 802 of file window_type.h.

References T, and to_underlying().

Field Documentation

◆ value

int32_t WindowNumber::value = 0
private

The identifier of the window.

Definition at line 763 of file window_type.h.

Referenced by operator int32_t(), operator T(), WindowNumber(), WindowNumber(), and WindowNumber().


The documentation for this struct was generated from the following file: