From c311e6e4a975cf6fa4bfa379e238922acaf443d4 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Fri, 31 Jan 2025 21:43:40 +0100 Subject: [PATCH] Codechange: strongly type LinkGraphID and LinkGraphJobID --- src/linkgraph/linkgraph.h | 2 +- src/linkgraph/linkgraph_type.h | 10 ++++++---- src/linkgraph/linkgraphjob.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 3d3d0f0565..c4cb1ba5a5 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -24,7 +24,7 @@ class LinkGraph; * Type of the pool for link graph components. Each station can be in at up to * 32 link graphs. So we allow for plenty of them to be created. */ -typedef Pool LinkGraphPool; +using LinkGraphPool = Pool; /** The actual pool with link graphs. */ extern LinkGraphPool _link_graph_pool; diff --git a/src/linkgraph/linkgraph_type.h b/src/linkgraph/linkgraph_type.h index 6d472a5069..e60134b112 100644 --- a/src/linkgraph/linkgraph_type.h +++ b/src/linkgraph/linkgraph_type.h @@ -10,11 +10,13 @@ #ifndef LINKGRAPH_TYPE_H #define LINKGRAPH_TYPE_H -typedef uint16_t LinkGraphID; -static const LinkGraphID INVALID_LINK_GRAPH = UINT16_MAX; +#include "../core/pool_type.hpp" -typedef uint16_t LinkGraphJobID; -static const LinkGraphJobID INVALID_LINK_GRAPH_JOB = UINT16_MAX; +using LinkGraphID = PoolID; +static constexpr LinkGraphID INVALID_LINK_GRAPH = LinkGraphID::Invalid(); + +using LinkGraphJobID = PoolID; +static constexpr LinkGraphJobID INVALID_LINK_GRAPH_JOB = LinkGraphJobID::Invalid(); typedef uint16_t NodeID; static const NodeID INVALID_NODE = UINT16_MAX; diff --git a/src/linkgraph/linkgraphjob.h b/src/linkgraph/linkgraphjob.h index 490185aa27..ce383da970 100644 --- a/src/linkgraph/linkgraphjob.h +++ b/src/linkgraph/linkgraphjob.h @@ -19,7 +19,7 @@ class Path; typedef std::list PathList; /** Type of the pool for link graph jobs. */ -typedef Pool LinkGraphJobPool; +using LinkGraphJobPool = Pool; /** The actual pool with link graph jobs. */ extern LinkGraphJobPool _link_graph_job_pool;