OpenTTD Source: src/core/pool_func.cpp Source File

OpenTTD Source 15.0-RC2

pool_func.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "../stdafx.h"
11#include "pool_type.hpp"
12
13#include "../safeguards.h"
14
19/* virtual */ PoolBase::~PoolBase()
20{
21 PoolVector *pools = PoolBase::GetPools();
22 pools->erase(std::ranges::find(*pools, this));
23 if (pools->empty()) delete pools;
24}
25
30/* static */ void PoolBase::Clean(PoolTypes pt)
31{
32 for (PoolBase *pool : *PoolBase::GetPools()) {
33 if (pt.Test(pool->type)) pool->CleanPool();
34 }
35}
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
EnumBitSet
Enum-as-bit-set wrapper.
Definition enum_type.hpp:177
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
PoolVector
std::vector< struct PoolBase * > PoolVector
Vector of pointers to PoolBase.
Definition pool_type.hpp:25
PoolBase
Base class for base of all pools.
Definition pool_type.hpp:83
PoolBase::GetPools
static PoolVector * GetPools()
Function used to access the vector of all pools.
Definition pool_type.hpp:90
PoolBase::Clean
static void Clean(PoolTypes)
Clean all pools of given type.
Definition pool_func.cpp:30
PoolBase::~PoolBase
virtual ~PoolBase()
Destructor removes this object from the pool vector and deletes the vector itself if this was the las...
Definition pool_func.cpp:19