Skip to content

Commit 992f63b

Browse files
authored
Cleanup: Use enum class (#12249)
This pull request converts non-class enums to enum classes. There are still many non-class enums not addressed in this pull request. However, since the changes have grown quite large, I'm submitting it at this point.
1 parent 0704455 commit 992f63b

132 files changed

Lines changed: 4278 additions & 4263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/admin-guide/files/records.yaml.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ Origin Server Connect Attempts
17301730
Set a limit for the number of concurrent connections to an upstream server group. A value of
17311731
``0`` disables checking. If a transaction attempts to connect to a group which already has the
17321732
maximum number of concurrent connections a 503
1733-
(``HTTP_STATUS_SERVICE_UNAVAILABLE``) error response is sent to the user agent. To configure
1733+
(``HTTPStatus::SERVICE_UNAVAILABLE``) error response is sent to the user agent. To configure
17341734

17351735
Upstream server group definition
17361736
See :ts:cv:`proxy.config.http.per_server.connection.match`.

doc/developer-guide/api/functions/TSHttpTxnServerRespGet.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ calls to retrieve information from the header.
5252
if (TS_SUCCESS == TSHttpTxnServerRespGet(tnx, &resp_heap, &resp_hdr)) {
5353
return TSHttpHdrStatusGet(resp_headp, resp_hdr);
5454
}
55-
return HTTP_STATUS_NONE;
55+
return HTTPStatus::NONE;
5656
}

doc/developer-guide/core-architecture/heap.en.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,32 @@ Classes
3030
This is the abstract base class for objects allocated in a :class:`HdrHeap`. This allows updating
3131
objects in a heap in a generic way, without having to locate all of the pointers to the objects.
3232

33-
The type of an instance stored in a heap must be one of the following values.
33+
.. class:: HdrHeapObjType
3434

35-
.. enumerator:: HDR_HEAP_OBJ_EMPTY = 0
35+
This is the enum class for type of a :class:`HdrHeapObjImpl`.
36+
The type of a :class:`HdrHeapObjImpl` instance stored in a heap must be one of the following values.
37+
38+
.. enumerator:: EMPTY = 0
3639

3740
Used to mark invalid objects, ones not yet constructed or ones that have been destroyed.
3841

39-
.. enumerator:: HDR_HEAP_OBJ_RAW = 1
42+
.. enumerator:: RAW = 1
4043

4144
Some sort of raw object, I have no idea.
4245

43-
.. enumerator:: HDR_HEAP_OBJ_URL = 2
46+
.. enumerator:: URL = 2
4447

4548
A URL object.
4649

47-
.. enumerator:: HDR_HEAP_OBJ_HTTP_HEADER = 3
50+
.. enumerator:: HTTP_HEADER = 3
4851

4952
The header for an HTTP request or response.
5053

51-
.. enumerator:: HDR_HEAP_OBJ_MIME_HEADER = 4
54+
.. enumerator:: MIME_HEADER = 4
5255

5356
A MIME header, containing MIME style fields with names and values.
5457

55-
.. enumerator:: HDR_HEAP_OBJ_FIELD_BLOCK = 5
58+
.. enumerator:: FIELD_BLOCK = 5
5659

5760
Who the heck knows?
5861

include/iocore/cache/Cache.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct CacheProcessor : public Processor {
108108
*/
109109
bool has_online_storage() const;
110110

111-
static int IsCacheEnabled();
111+
static CacheInitState IsCacheEnabled();
112112

113113
static bool IsCacheReady(CacheFragType type);
114114

@@ -137,14 +137,14 @@ struct CacheProcessor : public Processor {
137137
return wait_for_cache;
138138
}
139139

140-
static uint32_t cache_ready;
141-
static int initialized;
142-
static int start_done;
143-
static bool clear;
144-
static bool fix;
145-
static bool check;
146-
static int start_internal_flags;
147-
static int auto_clear_flag;
140+
static uint32_t cache_ready;
141+
static CacheInitState initialized;
142+
static int start_done;
143+
static bool clear;
144+
static bool fix;
145+
static bool check;
146+
static int start_internal_flags;
147+
static int auto_clear_flag;
148148

149149
ts::VersionNumber min_stripe_version;
150150
ts::VersionNumber max_stripe_version;

include/iocore/cache/CacheDefs.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
#include "tscore/Version.h"
2929
#include "tscore/CryptoHash.h"
3030

31-
#define CACHE_INIT_FAILED -1
32-
#define CACHE_INITIALIZING 0
33-
#define CACHE_INITIALIZED 1
31+
enum class CacheInitState : int {
32+
FAILED = -1,
33+
INITIALIZING = 0,
34+
INITIALIZED = 1,
35+
};
3436

3537
#define CACHE_ALT_INDEX_DEFAULT -1
3638
#define CACHE_ALT_REMOVED -2
@@ -62,10 +64,10 @@ static const uint8_t CACHE_DIR_MINOR_VERSION = 0;
6264
#define CACHE_DEREF 12
6365
#define CACHE_LOOKUP_OP 13
6466

65-
enum CacheType {
66-
CACHE_NONE_TYPE = 0, // for empty disk fragments
67-
CACHE_HTTP_TYPE = 1,
68-
CACHE_RTSP_TYPE = 2
67+
enum class CacheType {
68+
NONE = 0, // for empty disk fragments
69+
HTTP = 1,
70+
RTSP = 2
6971
};
7072

7173
// NOTE: All the failures are ODD, and one greater than the success

include/iocore/cache/HttpTransactCache.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
static const time_t CacheHighAgeWatermark = UINT_MAX;
4040
struct CacheHTTPInfoVector;
4141

42-
enum Variability_t {
43-
VARIABILITY_NONE = 0,
44-
VARIABILITY_SOME,
45-
VARIABILITY_ALL,
42+
enum class Variability_t {
43+
NONE = 0,
44+
SOME,
45+
ALL,
4646
};
4747

4848
class HttpTransactCache

include/proxy/CacheControl.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ const int CC_UNSET_TIME = -1;
4444
// load to verify memory allocation
4545
// #define CACHE_CONTROL_TIMEOUT (HRTIME_SECOND*10)
4646

47-
enum CacheControlType {
48-
CC_INVALID = 0,
49-
CC_REVALIDATE_AFTER,
50-
CC_NEVER_CACHE,
51-
CC_STANDARD_CACHE,
52-
CC_IGNORE_NO_CACHE,
53-
CC_IGNORE_CLIENT_NO_CACHE,
54-
CC_IGNORE_SERVER_NO_CACHE,
55-
CC_PIN_IN_CACHE,
56-
CC_TTL_IN_CACHE,
57-
CC_NUM_TYPES
47+
enum class CacheControlType {
48+
INVALID = 0,
49+
REVALIDATE_AFTER,
50+
NEVER_CACHE,
51+
STANDARD_CACHE,
52+
IGNORE_NO_CACHE,
53+
IGNORE_CLIENT_NO_CACHE,
54+
IGNORE_SERVER_NO_CACHE,
55+
PIN_IN_CACHE,
56+
TTL_IN_CACHE,
57+
NUM_TYPES
5858
};
5959

6060
struct matcher_line;
@@ -104,7 +104,7 @@ class CacheControlRecord : public ControlBase
104104
{
105105
public:
106106
CacheControlRecord();
107-
CacheControlType directive = CC_INVALID;
107+
CacheControlType directive = CacheControlType::INVALID;
108108
int time_arg = 0;
109109
int cache_responses_to_cookies = -1;
110110
Result Init(matcher_line *line_info);

include/proxy/ControlBase.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ class ControlBase
4343
{
4444
public:
4545
struct Modifier {
46-
enum Type {
47-
MOD_INVALID,
48-
MOD_PORT,
49-
MOD_SCHEME,
50-
MOD_PREFIX,
51-
MOD_SUFFIX,
52-
MOD_METHOD,
53-
MOD_TIME,
54-
MOD_SRC_IP,
55-
MOD_IPORT,
56-
MOD_TAG,
57-
MOD_INTERNAL,
46+
enum class Type {
47+
INVALID,
48+
PORT,
49+
SCHEME,
50+
PREFIX,
51+
SUFFIX,
52+
METHOD,
53+
TIME,
54+
SRC_IP,
55+
IPORT,
56+
TAG,
57+
INTERNAL,
5858
};
5959
/// Destructor - force virtual.
6060
virtual ~Modifier();

include/proxy/FetchSM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class FetchSM : public Continuation
5353
resp_buffer = new_MIOBuffer(BUFFER_SIZE_INDEX_32K);
5454
resp_reader = resp_buffer->alloc_reader();
5555
http_parser_init(&http_parser);
56-
client_response_hdr.create(HTTP_TYPE_RESPONSE);
56+
client_response_hdr.create(HTTPType::RESPONSE);
5757
SET_HANDLER(&FetchSM::fetch_handler);
5858
}
5959

include/proxy/IPAllow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class IpAllow : public ConfigInfo
9191
using IpCategories = std::unordered_map<std::string, swoc::IPSpace<bool>>;
9292

9393
// indicator for whether we should be checking the acl record for src ip or dest ip
94-
enum match_key_t { SRC_ADDR, DST_ADDR };
94+
enum class match_key_t { SRC_ADDR, DST_ADDR };
9595

9696
/// Token strings for configuration
9797
static constexpr swoc::TextView OPT_MATCH_SRC{"src_ip"};

0 commit comments

Comments
 (0)