4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file pool_func.cpp Implementation of PoolBase methods. */
12 #include "../stdafx.h"
13 #include "pool_type.hpp"
16 * Destructor removes this object from the pool vector and
17 * deletes the vector itself if this was the last item removed.
19 /* virtual */ PoolBase::~PoolBase()
21 PoolVector
*pools
= PoolBase::GetPools();
22 pools
->Erase(pools
->Find(this));
23 if (pools
->Length() == 0) delete pools
;
27 * Clean all pools of given type.
28 * @param pt pool types to clean.
30 /* static */ void PoolBase::Clean(PoolType pt
)
32 PoolVector
*pools
= PoolBase::GetPools();
33 PoolBase
**end
= pools
->End();
34 for (PoolBase
**ppool
= pools
->Begin(); ppool
!= end
; ppool
++) {
35 PoolBase
*pool
= *ppool
;
36 if (pool
->type
& pt
) pool
->CleanPool();