Skip to content

Commit d6fefc6

Browse files
committed
Replacing REQUEST macros with enum
1 parent f2af1a6 commit d6fefc6

25 files changed

+228
-284
lines changed

source/c_api/udaPutAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int udaPutAPI(const char* putInstruction, PUTDATA_BLOCK* inPutData)
188188
//-------------------------------------------------------------------------
189189
// Free Heap
190190

191-
freeClientPutDataBlockList(&request_block.requests[0].putDataBlockList);
191+
free_client_put_data_block_list(&request_block.requests[0].putDataBlockList);
192192

193193
return handle;
194194
}

source/client/makeClientRequestBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void uda::client::freeClientRequestBlock(RequestBlock* request_block)
173173
if (request_block != nullptr && request_block->requests != nullptr) {
174174
for (int i = 0; i < request_block->num_requests; i++) {
175175
free_name_value_list(&request_block->requests[i].nameValueList);
176-
freeClientPutDataBlockList(&request_block->requests[i].putDataBlockList);
176+
free_client_put_data_block_list(&request_block->requests[i].putDataBlockList);
177177
}
178178
free(request_block->requests);
179179
request_block->requests = nullptr;

source/client/udaClient.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int getCurrentDataBlockIndex()
110110
return data_blocks.size() - 1;
111111
}
112112

113-
void freeDataBlocks()
113+
void free_data_blocks()
114114
{
115115
data_blocks.clear();
116116
udaPutThreadLastHandle(-1);
@@ -576,14 +576,14 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
576576
int rc = check_file_cache(request, &data_block, g_log_malloc_list, g_user_defined_type_list,
577577
&log_struct_list, client_flags, *private_flags, malloc_source);
578578
if (rc >= 0) {
579-
request_block->requests[i].request = REQUEST_CACHED;
579+
request_block->requests[i].request = Request::Cached;
580580
++num_cached;
581581
continue;
582582
}
583583
rc = check_mem_cache(cache, request, &data_block, g_log_malloc_list, g_user_defined_type_list,
584584
&log_struct_list, client_flags, *private_flags, malloc_source);
585585
if (rc >= 0) {
586-
request_block->requests[i].request = REQUEST_CACHED;
586+
request_block->requests[i].request = Request::Cached;
587587
++num_cached;
588588
continue;
589589
}
@@ -1073,7 +1073,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
10731073
DataBlock* data_block = getDataBlock(data_block_idx);
10741074

10751075
// DataBlock* in_data;
1076-
// if (request_block->requests[i].request == REQUEST_CACHED) {
1076+
// if (request_block->requests[i].request == Request::Cached) {
10771077
// in_data = &cached_data_block_list.data[i];
10781078
// } else {
10791079
// in_data = &recv_data_block_list.data[recv_idx];
@@ -1563,13 +1563,13 @@ void udaFreeAll()
15631563

15641564
for (int i = 0; i < getCurrentDataBlockIndex(); ++i) {
15651565
#ifndef FATCLIENT
1566-
freeDataBlock(getDataBlock(i));
1566+
free_data_block(getDataBlock(i));
15671567
#else
1568-
freeDataBlock(getDataBlock(i));
1568+
free_data_block(getDataBlock(i));
15691569
#endif
15701570
}
15711571

1572-
freeDataBlocks();
1572+
free_data_blocks();
15731573

15741574
#ifndef FATCLIENT
15751575
g_user_defined_type_list = nullptr; // malloc'd within protocolXML

source/client2/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ int uda::client::Client::put(std::string_view put_instruction, uda::client_serve
12231223
std::vector<int> indices(request_block.num_requests);
12241224
get_requests(request_block, indices.data());
12251225

1226-
freeClientPutDataBlockList(&request_block.requests[0].putDataBlockList);
1226+
free_client_put_data_block_list(&request_block.requests[0].putDataBlockList);
12271227

12281228
return indices[0];
12291229
}

source/clientserver/makeRequestBlock.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
100100
//------------------------------------------------------------------------------
101101
// Start with ignorance about which plugin to use
102102

103-
request->request = REQUEST_READ_UNKNOWN;
103+
request->request = (int)Request::ReadUnknown;
104104

105105
//------------------------------------------------------------------------------
106106
// Check there is something to work with!
@@ -142,7 +142,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
142142
bool is_proxy = config.get("server.is_proxy").as_or_default(false);
143143

144144
if (is_proxy) {
145-
request->request = REQUEST_READ_IDAM;
145+
request->request = (int)Request::ReadUDA;
146146
}
147147

148148
//==============================================================================
@@ -304,7 +304,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
304304
left_trim_string(work2);
305305
trim_string(work2);
306306

307-
request->request = REQUEST_READ_SERVERSIDE;
307+
request->request = (int)Request::ReadServerside;
308308
extract_function_name(work, request);
309309

310310
UDA_LOG(UDA_LOG_DEBUG, "**** Server Side Function ??? ****")
@@ -379,11 +379,11 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
379379
// configuration file. The request must be a generic lookup of how to access data remotely for the specified
380380
// device. The external server providing access to the foreign device's data will interpret the arguments
381381

382-
if (request->request == REQUEST_READ_UNKNOWN) {
382+
if (request->request == (int)Request::ReadUnknown) {
383383
UDA_LOG(UDA_LOG_DEBUG, "No plugin was identified for the format: {}", work2)
384384
is_foreign = true;
385385
strcpy(request->device_name, work2); // Copy the DEVICE prefix
386-
request->request = REQUEST_READ_GENERIC; // The database will identify the target
386+
request->request = (int)Request::ReadGeneric; // The database will identify the target
387387

388388
break;
389389
}
@@ -499,7 +499,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
499499
// server) the Plugin Name is synonymous with the Archive Name and takes priority (The archive name is discarded as
500500
// unimportant)
501501

502-
if (request->request == REQUEST_READ_IDAM) {
502+
if (request->request == (int)Request::ReadUDA) {
503503
reduce_signal = false;
504504
err = extract_archive(config, request, reduce_signal);
505505
} else {
@@ -566,7 +566,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
566566
if (!is_function) { // Must be a default server-side function
567567
for (const auto& plugin : pluginList) {
568568
if (plugin.entry_func_name == "ServerSide" && plugin.library_name.empty()) {
569-
request->request = REQUEST_READ_SERVERSIDE; // Found
569+
request->request = (int)Request::ReadServerside; // Found
570570
copy_string(plugin.name, request->format, STRING_LENGTH);
571571
is_function = true;
572572
break;
@@ -581,7 +581,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
581581

582582
} else {
583583
// Select the Generic plugin: No source => no format or protocol or library was specified.
584-
request->request = REQUEST_READ_GENERIC;
584+
request->request = (int)Request::ReadGeneric;
585585
UDA_LOG(UDA_LOG_DEBUG, "C request: {}", request->request)
586586
}
587587

@@ -595,7 +595,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
595595
if (id >= 0
596596
&& pluginList[id].type == UDA_PLUGIN_CLASS_FUNCTION
597597
&& pluginList[id].entry_func_name != "serverside") {
598-
if (request->request == REQUEST_READ_GENERIC || request->request == REQUEST_READ_UNKNOWN) {
598+
if (request->request == (int)Request::ReadGeneric || request->request == (int)Request::ReadUnknown) {
599599
request->request = id; // Found
600600
copy_string(pluginList[id].name, request->format, STRING_LENGTH);
601601
UDA_LOG(UDA_LOG_DEBUG, "D request: {}", request->request);
@@ -622,7 +622,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
622622
// MDS+::server
623623
// MDS+::
624624

625-
if (request->request == REQUEST_READ_MDS && !is_proxy) {
625+
if (request->request == (int)Request::ReadMDS && !is_proxy) {
626626

627627
reverse_string(test + ldelim, work); // Drop the delimiters and Reverse the Source String
628628

@@ -668,7 +668,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
668668
//---------------------------------------------------------------------------------------------------------------------
669669
// UDA and WEB Servers ... parse source modelled as: server:port/source
670670

671-
if (request->request == REQUEST_READ_IDAM || request->request == REQUEST_READ_WEB) {
671+
if (request->request == (int)Request::ReadUDA || request->request == (int)Request::ReadWeb) {
672672
strcpy(work, test + ldelim); // Drop the delimiters
673673

674674
// Isolate the Server from the source UDA::server:port/source or SSL://server:port/source
@@ -699,7 +699,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
699699
//---------------------------------------------------------------------------------------------------------------------
700700
// SQL Servers ...
701701

702-
if (request->request == REQUEST_READ_SQL) {
702+
if (request->request == (int)Request::ReadSQL) {
703703
strcpy(request->server, request->path);
704704
if ((test = strchr(request->server, '/')) != nullptr) {
705705
test[0] = '\0';
@@ -779,7 +779,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc
779779

780780
request->format[0] = '\0';
781781
request->file[0] = '\0';
782-
request->request = REQUEST_READ_UNKNOWN;
782+
request->request = (int)Request::ReadUnknown;
783783

784784
if (source[0] == '\0') {
785785
return rc;
@@ -983,7 +983,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc
983983
auto format = config.get("server.default_format").as_or_default(""s);
984984
if (source[0] == '/' && source[1] != '\0' && isdigit(source[1])) { // Default File Format?
985985
if (generic_request_test(&source[1], request)) { // Matches 99999/999
986-
request->request = REQUEST_READ_UNKNOWN;
986+
request->request = (int)Request::ReadUnknown;
987987
strcpy(request->format, format.c_str()); // the default Server File Format
988988
break;
989989
}
@@ -1035,7 +1035,7 @@ int generic_request_test(const char* source, RequestData* request)
10351035

10361036
request->format[0] = '\0';
10371037
request->file[0] = '\0';
1038-
request->request = REQUEST_READ_UNKNOWN;
1038+
request->request = (int)Request::ReadUnknown;
10391039

10401040
if (source[0] == '\0') {
10411041
return rc;
@@ -1052,7 +1052,7 @@ int generic_request_test(const char* source, RequestData* request)
10521052

10531053
if (is_number((char*)source)) { // Is the source an integer number?
10541054
rc = 1;
1055-
request->request = REQUEST_READ_GENERIC;
1055+
request->request = (int)Request::ReadGeneric;
10561056
strcpy(request->path, ""); // Clean the path
10571057
request->exp_number = (int)strtol(source, nullptr, 10); // Plasma Shot Number
10581058
UDA_LOG(UDA_LOG_DEBUG, "exp number identified, selecting GENERIC plugin.");
@@ -1061,7 +1061,7 @@ int generic_request_test(const char* source, RequestData* request)
10611061
if ((token = strtok(work, "/")) != nullptr) { // Tokenise the remaining string
10621062
if (is_number(token)) { // Is the First token an integer number?
10631063
rc = 1;
1064-
request->request = REQUEST_READ_GENERIC;
1064+
request->request = (int)Request::ReadGeneric;
10651065
strcpy(request->path, ""); // Clean the path
10661066
request->exp_number = (int)strtol(token, nullptr, 10);
10671067
if ((token = strtok(nullptr, "/")) != nullptr) { // Next Token

source/clientserver/make_request_block.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void uda::parse_signal(RequestData& result, const std::string& signal, const std
297297

298298
result.request = find_plugin_id_by_format(plugin, plugin_list);
299299
} else {
300-
result.request = REQUEST_READ_GENERIC;
300+
result.request = (int)Request::ReadGeneric;
301301
}
302302

303303
write_string(result.archive, archive, STRING_LENGTH);
@@ -437,7 +437,7 @@ RequestData make_request_data(const Config& config, const RequestData& request_d
437437
bool is_proxy = config.get("server.is_proxy").as_or_default(false);
438438

439439
if (is_proxy) {
440-
result.request = REQUEST_READ_IDAM;
440+
result.request = (int)Request::ReadUDA;
441441
}
442442

443443
uda::write_string(result.api_delim, delim, MAXNAME);

source/clientserver/parseXML.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,14 +1657,14 @@ void uda::client_server::free_actions(Actions* actions)
16571657
void* cptr;
16581658

16591659
UDA_LOG(UDA_LOG_DEBUG, "freeActions: Enter")
1660-
UDA_LOG(UDA_LOG_DEBUG, "freeDataBlock: Number of Actions = {} ", actions->nactions)
1660+
UDA_LOG(UDA_LOG_DEBUG, "free_data_block: Number of Actions = {} ", actions->nactions)
16611661

16621662
if (actions->nactions == 0) {
16631663
return;
16641664
}
16651665

16661666
for (int i = 0; i < actions->nactions; i++) {
1667-
UDA_LOG(UDA_LOG_DEBUG, "freeDataBlock: freeing action Type = {} ", actions->action[i].actionType)
1667+
UDA_LOG(UDA_LOG_DEBUG, "free_data_block: freeing action Type = {} ", actions->action[i].actionType)
16681668

16691669
switch (actions->action[i].actionType) {
16701670

source/clientserver/socketStructs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct HostData {
2323
//-------------------------------------------------------
2424
// Socket Types
2525

26-
enum class SocketType {
26+
enum class SocketType : int {
2727
Unknown = 0,
2828
UDA = 1,
2929
MDSPLUS = 2,

source/clientserver/udaDefines.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef UDA_CLIENTSERVER_IDAMDEFINES_H
2-
#define UDA_CLIENTSERVER_IDAMDEFINES_H
1+
#pragma once
32

43
//--------------------------------------------------------
54
// Size Definitions
@@ -140,5 +139,3 @@
140139
// QA Status
141140

142141
#define DEFAULT_STATUS 1 // Default Signal and Data_Source Status value
143-
144-
#endif // UDA_CLIENTSERVER_IDAMDEFINES_H

0 commit comments

Comments
 (0)