OpenTTD Source 20250205-master-gfd85ab1e2c
EnumBitSet< Tenum, Tstorage > Class Template Reference

Enum-as-bit-set wrapper. More...

#include <enum_type.hpp>

Public Types

using EnumType = Tenum
 Enum type of this EnumBitSet.
 
using BaseType = Tstorage
 Storage type of this EnumBitSet, be ConvertibleThroughBase.
 

Public Member Functions

constexpr EnumBitSet (Tenum value)
 
constexpr EnumBitSet (Tstorage data)
 
constexpr EnumBitSet (std::initializer_list< const Tenum > values)
 Construct an EnumBitSet from a list of enum values.
 
constexpr auto operator<=> (const EnumBitSet &) const noexcept=default
 
constexpr EnumBitSetSet (Tenum value)
 Set the enum value.
 
constexpr EnumBitSetReset (Tenum value)
 Reset the enum value to not set.
 
constexpr EnumBitSetFlip (Tenum value)
 Flip the enum value.
 
constexpr bool Test (Tenum value) const
 Test if the enum value is set.
 
constexpr bool All (const EnumBitSet &other) const
 Test if all of the enum values are set.
 
constexpr bool Any (const EnumBitSet &other) const
 Test if any of the enum values are set.
 
constexpr EnumBitSet operator| (const EnumBitSet &other) const
 
constexpr EnumBitSet operator& (const EnumBitSet &other) const
 
constexpr Tstorage base () const noexcept
 Retrieve the raw value behind this EnumBitSet.
 

Private Attributes

Tstorage data
 Bitmask of enum values.
 

Detailed Description

template<typename Tenum, typename Tstorage>
class EnumBitSet< Tenum, Tstorage >

Enum-as-bit-set wrapper.

Allows wrapping enum values as a bit set. Methods are loosely modelled on std::bitset.

Template Parameters
TenumEnum values to wrap.
TsorageStorage type required to hold eenum values.

Definition at line 118 of file enum_type.hpp.

Member Typedef Documentation

◆ BaseType

template<typename Tenum , typename Tstorage >
using EnumBitSet< Tenum, Tstorage >::BaseType = Tstorage

Storage type of this EnumBitSet, be ConvertibleThroughBase.

Definition at line 121 of file enum_type.hpp.

◆ EnumType

template<typename Tenum , typename Tstorage >
using EnumBitSet< Tenum, Tstorage >::EnumType = Tenum

Enum type of this EnumBitSet.

Definition at line 120 of file enum_type.hpp.

Constructor & Destructor Documentation

◆ EnumBitSet() [1/4]

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet< Tenum, Tstorage >::EnumBitSet ( )
inlineconstexpr

Definition at line 123 of file enum_type.hpp.

◆ EnumBitSet() [2/4]

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet< Tenum, Tstorage >::EnumBitSet ( Tenum  value)
inlineconstexpr

Definition at line 124 of file enum_type.hpp.

◆ EnumBitSet() [3/4]

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet< Tenum, Tstorage >::EnumBitSet ( Tstorage  data)
inlineexplicitconstexpr

Definition at line 125 of file enum_type.hpp.

◆ EnumBitSet() [4/4]

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet< Tenum, Tstorage >::EnumBitSet ( std::initializer_list< const Tenum >  values)
inlineconstexpr

Construct an EnumBitSet from a list of enum values.

Parameters
valuesList of enum values.

Definition at line 131 of file enum_type.hpp.

References EnumBitSet< Tenum, Tstorage >::Set().

Member Function Documentation

◆ All()

template<typename Tenum , typename Tstorage >
constexpr bool EnumBitSet< Tenum, Tstorage >::All ( const EnumBitSet< Tenum, Tstorage > &  other) const
inlineconstexpr

Test if all of the enum values are set.

Parameters
otherBitSet of enum values to test.
Returns
true iff all of the enum values are set.

Definition at line 191 of file enum_type.hpp.

References EnumBitSet< Tenum, Tstorage >::data.

◆ Any()

template<typename Tenum , typename Tstorage >
constexpr bool EnumBitSet< Tenum, Tstorage >::Any ( const EnumBitSet< Tenum, Tstorage > &  other) const
inlineconstexpr

Test if any of the enum values are set.

Parameters
otherBitSet of enum values to test.
Returns
true iff any of the enum values are set.

Definition at line 201 of file enum_type.hpp.

References EnumBitSet< Tenum, Tstorage >::data.

Referenced by AdvanceHouseConstruction(), ClearTownHouse(), CmdBuildObject(), IndustriesScopeResolver::GetVariable(), IsHouseSpecValid(), MakeTownHouse(), RemoveNearbyStations(), TileLoop_Town(), IndustrySpec::UsesOriginalEconomy(), and WatchedCargoCallback().

◆ base()

template<typename Tenum , typename Tstorage >
constexpr Tstorage EnumBitSet< Tenum, Tstorage >::base ( ) const
inlineconstexprnoexcept

Retrieve the raw value behind this EnumBitSet.

Returns
the raw value.

Definition at line 220 of file enum_type.hpp.

References EnumBitSet< Tenum, Tstorage >::data.

Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().

◆ Flip()

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet & EnumBitSet< Tenum, Tstorage >::Flip ( Tenum  value)
inlineconstexpr

◆ operator&()

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet EnumBitSet< Tenum, Tstorage >::operator& ( const EnumBitSet< Tenum, Tstorage > &  other) const
inlineconstexpr

Definition at line 211 of file enum_type.hpp.

◆ operator|()

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet EnumBitSet< Tenum, Tstorage >::operator| ( const EnumBitSet< Tenum, Tstorage > &  other) const
inlineconstexpr

Definition at line 206 of file enum_type.hpp.

◆ Reset()

template<typename Tenum , typename Tstorage >
constexpr EnumBitSet & EnumBitSet< Tenum, Tstorage >::Reset ( Tenum  value)
inlineconstexpr

◆ Set()

◆ Test()

template<typename Tenum , typename Tstorage >
constexpr bool EnumBitSet< Tenum, Tstorage >::Test ( Tenum  value) const
inlineconstexpr

Test if the enum value is set.

Parameters
valueEnum value to check.
Returns
true iff the requested value is set.

Definition at line 181 of file enum_type.hpp.

References EnumBitSet< Tenum, Tstorage >::data, and to_underlying().

Referenced by AddAcceptedCargoOfHouse(), AddArticulatedParts(), NewGRFWindow::AddGRFToActive(), AfterLoadGame(), AfterLoadGRFs(), AircraftVehicleChangeInfo(), AnimateNewObjectTile(), BuildObject(), RefitWindow::BuildRefitList(), BuildTownHouse(), CalcEngineReliability(), CalculateRefitMasks(), CcRoadStop(), ChangeIndustryProduction(), IntSettingDesc::ChangeValue(), CheckAutoreplaceValidity(), CheckFlatLandRailStation(), CheckIfIndustryTileSlopes(), CheckSoftLimit(), PoolBase::Clean(), ClearTownHouse(), CloseAllNonVitalWindows(), CloseConstructionWindows(), CloseNonVitalWindows(), CloseWindowById(), CmdAutoreplaceVehicle(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildObject(), CmdBuildRailStation(), CmdBuildRailVehicle(), CmdBuildRoadStop(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdReverseTrainDirection(), CmdSendVehicleToDepot(), CmdWantEnginePreview(), Train::ConsistChanged(), Engine::DetermineCapacity(), DispatchLeftClickEvent(), DispatchRightClickEvent(), DoCreateNewIndustry(), NWidgetLeaf::Draw(), DrawFrameRect(), DrawHouseInGUI(), DrawNewHouseTileInGUI(), DrawNewObjectTileInGUI(), DrawRoadDepotSprite(), DrawRoadStopTile(), SettingEntry::DrawSetting(), DrawStationTile(), DrawTile_Road(), DrawTileLayout(), VehicleGroupWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), Window::DrawWidgets(), ErrorUnknownCallbackResult(), FillGRFDetails(), FinaliseEngineArray(), FixTTOEngines(), EnumBitSet< Tenum, Tstorage >::Flip(), GetArticulatedRefitMasks(), GetBestFittingSubType(), GetCapacityOfArticulatedParts(), GetCargoSubtypeText(), GetCargoSuffix(), GetCargoTypesOfArticulatedParts(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetEngineLiveryScheme(), GetFoundation_Town(), BuildHouseWindow::GetHouseInformation(), GetIfStopIsForType(), GetIndustryProbabilityCallback(), GetLoadAmount(), NewGRFWindow::GetPalette(), GetRailTypes(), GetRoadTypes(), GetSettingsDesc(), GetTownRoadType(), GetTownRoadTypeFirstIntroductionDate(), SettingDesc::GetType(), HandleAutoscroll(), HandleWindowDragging(), HasRailCatenary(), HasRoadCatenary(), HasRoadTypeAvail(), HeightMapCoastLines(), HeightMapSmoothCoasts(), IConsoleGetSetting(), IndustryTemporarilyRefusesCargo(), IniSaveSettings(), InitRailTypes(), InitRoadTypes(), IsArticulatedEngine(), IsArticulatedVehicleRefittable(), SettingDesc::IsEditable(), Engine::IsEnabled(), IsEngineBuildable(), IsEngineRefittable(), ObjectSpec::IsEverAvailable(), IsGoodGRFConfigList(), IsLoggableGrfConfig(), IsRoadStopAvailable(), IsStationAvailable(), PATSChunkHandler::Load(), LoadNewGRF(), LoadNewGRFFile(), LoadSettings(), IntSettingDesc::MakeValueValid(), MaybeBringWindowToFront(), NewVehicleAvailable(), ReplaceVehicleWindow::OnClick(), BuildVehicleWindow::OnClick(), GenerateLandscapeWindow::OnClick(), CreateScenarioWindow::OnClick(), VehicleGroupWindow::OnClick(), NetworkStartServerWindow::OnClick(), NewGRFWindow::OnClick(), BuildRoadStationWindow::OnClick(), GameSettingsWindow::OnClick(), GenerateLandscapeWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), SelectGameWindow::OnResize(), GameOptionsWindow::OnResize(), ParamSet(), PlayVehicleSound(), Window::ProcessHighlightedInvalidations(), Rail90DegTurnDisallowed(), RailNoLevelCrossings(), RailVehicleChangeInfo(), RefitVehicle(), RelocateAllWindows(), StationResolverObject::ResolveReal(), RoadNoLevelCrossing(), RoadVehicleChangeInfo(), Vehicle::SendToDepot(), SetSettingValue(), SetSettingValue(), ReplaceVehicleWindow::SetStringParameters(), GenerateLandscapeWindow::SetStringParameters(), IntSettingDesc::SetValueDParams(), SetYearEngineAgingStops(), ShipVehicleChangeInfo(), ShowMissingContentWindow(), ShowNewGrfVehicleError(), StartupOneEngine(), TileLoop_Town(), TownCanGrowRoad(), TriggerIndustryProduction(), TryBuildTownHouse(), Train::UpdateDeltaXY(), UpdateHousesAndTowns(), UpdateObjectColours(), Vehicle::UpdateVisualEffect(), VehicleLengthChanged(), StringData::Version(), and ViewportAddString().

Field Documentation

◆ data

template<typename Tenum , typename Tstorage >
Tstorage EnumBitSet< Tenum, Tstorage >::data
private

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