summaryrefslogtreecommitdiff
path: root/src/core/pool_type.hpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2011-02-19 23:05:47 +0000
committersmatz <smatz@openttd.org>2011-02-19 23:05:47 +0000
commit756cc6cf651aa5650f055c70f31f7e07391be8c6 (patch)
tree8bf5af85e6523ad91ce99606e2b068b9f7513976 /src/core/pool_type.hpp
parent642fb19d4fe4fbb249ddc314f75a35282ce6d28d (diff)
downloadopenttd-756cc6cf651aa5650f055c70f31f7e07391be8c6.tar.xz
(svn r22116) -Codechange: use PoolBase::Clean() at more places
Diffstat (limited to 'src/core/pool_type.hpp')
-rw-r--r--src/core/pool_type.hpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp
index 9f4f8d99c..e5e58238c 100644
--- a/src/core/pool_type.hpp
+++ b/src/core/pool_type.hpp
@@ -13,11 +13,25 @@
#define POOL_TYPE_HPP
#include "smallvec_type.hpp"
+#include "enum_type.hpp"
+
+/** Various types of a pool. */
+enum PoolType {
+ PT_NONE = 0x00, ///< No pool is selected.
+ PT_NORMAL = 0x01, ///< Normal pool containing game objects.
+ PT_NCLIENT = 0x02, ///< Network client pools.
+ PT_NADMIN = 0x04, ///< Network admin pool.
+ PT_DATA = 0x08, ///< NewGRF or other data, that is not reset together with normal pools.
+ PT_ALL = 0x0F, ///< All pool types.
+};
+DECLARE_ENUM_AS_BIT_SET(PoolType)
typedef SmallVector<struct PoolBase *, 4> PoolVector; ///< Vector of pointers to PoolBase
/** Base class for base of all pools. */
struct PoolBase {
+ const PoolType type; ///< Type of this pool.
+
/**
* Function used to access the vector of all pools.
* @return pointer to vector of all pools
@@ -28,12 +42,13 @@ struct PoolBase {
return pools;
}
- static void CleanAll();
+ static void Clean(PoolType);
/**
* Contructor registers this object in the pool vector.
+ * @param pt type of this pool.
*/
- PoolBase()
+ PoolBase(PoolType pt) : type(pt)
{
*PoolBase::GetPools()->Append() = this;
}
@@ -52,11 +67,12 @@ struct PoolBase {
* @tparam Tindex Type of the index for this pool
* @tparam Tgrowth_step Size of growths; if the pool is full increase the size by this amount
* @tparam Tmax_size Maximum size of the pool
+ * @tparam Tpool_type Type of this pool
* @tparam Tcache Whether to perform 'alloc' caching, i.e. don't actually free/malloc just reuse the memory
* @tparam Tzero Whether to zero the memory
* @warning when Tcache is enabled *all* instances of this pool's item must be of the same size.
*/
-template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, bool Tcache = false, bool Tzero = true>
+template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
struct Pool : PoolBase {
static const size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside
@@ -116,7 +132,7 @@ struct Pool : PoolBase {
* Base class for all PoolItems
* @tparam Tpool The pool this item is going to be part of
*/
- template <struct Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero> *Tpool>
+ template <struct Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero> *Tpool>
struct PoolItem {
Tindex index; ///< Index of this pool item