OpenTTD Source 20250205-master-gfd85ab1e2c
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 <http://www.gnu.org/licenses/>.
6 */
7
10#include "../stdafx.h"
11#include "pool_type.hpp"
12
13#include "../safeguards.h"
14
19/* virtual */ PoolBase::~PoolBase()
20{
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}
Enum-as-bit-set wrapper.
constexpr bool Test(Tenum value) const
Test if the enum value is set.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
std::vector< struct PoolBase * > PoolVector
Vector of pointers to PoolBase.
Definition pool_type.hpp:25
Base class for base of all pools.
Definition pool_type.hpp:28
static PoolVector * GetPools()
Function used to access the vector of all pools.
Definition pool_type.hpp:35
static void Clean(PoolTypes)
Clean all pools of given type.
Definition pool_func.cpp:30
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