Skip to content

Commit ac872f4

Browse files
committed
treewide: switch uses of inhouse optional implementation for std::optional
1 parent 162836b commit ac872f4

File tree

428 files changed

+3595
-3520
lines changed

Some content is hidden

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

428 files changed

+3595
-3520
lines changed

apps/gnb/adapters/e2ap_adapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class e2ap_network_adapter : public e2_message_notifier,
6666
///
6767
/// In case the gateway was configured to listen on port 0, i.e. the operating system shall pick a random free port,
6868
/// this function can be used to get the actual port number.
69-
optional<uint16_t> get_listen_port()
69+
std::optional<uint16_t> get_listen_port()
7070
{
7171
if (gateway == nullptr) {
7272
return {};

apps/gnb/gnb_appconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct buffer_pool_appconfig {
104104
/// CPU affinities configuration for the gNB app.
105105
struct cpu_affinities_appconfig {
106106
/// CPUs isolation.
107-
optional<os_sched_affinity_bitmask> isolated_cpus;
107+
std::optional<os_sched_affinity_bitmask> isolated_cpus;
108108
/// Low priority workers CPU affinity mask.
109109
os_sched_affinity_config low_priority_cpu_cfg = {sched_affinity_mask_types::low_priority,
110110
{},
@@ -156,7 +156,7 @@ struct gnb_appconfig {
156156
/// Expert configuration.
157157
expert_execution_appconfig expert_execution_cfg;
158158
/// HAL configuration.
159-
optional<hal_appconfig> hal_config;
159+
std::optional<hal_appconfig> hal_config;
160160
};
161161

162162
} // namespace srsran

apps/gnb/gnb_appconfig_cli11_schema.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void configure_cli11_buffer_pool_args(CLI::App& app, buffer_pool_appconfi
164164
->capture_default_str();
165165
}
166166

167-
static void configure_cli11_hal_args(CLI::App& app, optional<hal_appconfig>& config)
167+
static void configure_cli11_hal_args(CLI::App& app, std::optional<hal_appconfig>& config)
168168
{
169169
config.emplace();
170170

@@ -270,9 +270,9 @@ static void configure_cli11_non_rt_threads_args(CLI::App& app, non_rt_threads_ap
270270

271271
static void configure_cli11_cpu_affinities_args(CLI::App& app, cpu_affinities_appconfig& config)
272272
{
273-
auto parsing_isolated_cpus_fcn = [](optional<os_sched_affinity_bitmask>& isolated_cpu_cfg,
274-
const std::string& value,
275-
const std::string& property_name) {
273+
auto parsing_isolated_cpus_fcn = [](std::optional<os_sched_affinity_bitmask>& isolated_cpu_cfg,
274+
const std::string& value,
275+
const std::string& property_name) {
276276
isolated_cpu_cfg.emplace();
277277
parse_affinity_mask(*isolated_cpu_cfg, value, property_name);
278278

apps/gnb/gnb_appconfig_translators.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ std::vector<du_cell_config> srsran::generate_du_cell_config(const du_high_unit_c
641641
const unsigned nof_crbs = band_helper::get_n_rbs_from_bw(
642642
base_cell.channel_bw_mhz, param.scs_common, band_helper::get_freq_range(*param.band));
643643

644-
optional<band_helper::ssb_coreset0_freq_location> ssb_freq_loc;
644+
std::optional<band_helper::ssb_coreset0_freq_location> ssb_freq_loc;
645645
if (base_cell.pdcch_cfg.common.coreset0_index.has_value()) {
646646
ssb_freq_loc =
647647
band_helper::get_ssb_coreset0_freq_location_for_cset0_idx(base_cell.dl_arfcn,
@@ -882,12 +882,13 @@ std::vector<du_cell_config> srsran::generate_du_cell_config(const du_high_unit_c
882882
// PDSCH-Config - Update PDSCH time domain resource allocations based on partial slot and/or dedicated PDCCH
883883
// configuration.
884884
out_cell.dl_cfg_common.init_dl_bwp.pdsch_common.pdsch_td_alloc_list =
885-
config_helpers::make_pdsch_time_domain_resource(
886-
param.search_space0_index,
887-
out_cell.dl_cfg_common.init_dl_bwp.pdcch_common,
888-
out_cell.ue_ded_serv_cell_cfg.init_dl_bwp.pdcch_cfg,
889-
band_helper::get_duplex_mode(param.band.value()) == duplex_mode::TDD ? out_cell.tdd_ul_dl_cfg_common.value()
890-
: optional<tdd_ul_dl_config_common>{});
885+
config_helpers::make_pdsch_time_domain_resource(param.search_space0_index,
886+
out_cell.dl_cfg_common.init_dl_bwp.pdcch_common,
887+
out_cell.ue_ded_serv_cell_cfg.init_dl_bwp.pdcch_cfg,
888+
band_helper::get_duplex_mode(param.band.value()) ==
889+
duplex_mode::TDD
890+
? out_cell.tdd_ul_dl_cfg_common.value()
891+
: std::optional<tdd_ul_dl_config_common>{});
891892

892893
out_cell.ue_ded_serv_cell_cfg.pdsch_serv_cell_cfg->nof_harq_proc =
893894
(pdsch_serving_cell_config::nof_harq_proc_for_pdsch)config.cells_cfg.front().cell.pdsch_cfg.nof_harqs;
@@ -987,11 +988,12 @@ std::vector<du_cell_config> srsran::generate_du_cell_config(const du_high_unit_c
987988
base_cell.pucch_cfg.sr_period_msec);
988989

989990
// If any dependent parameter needs to be updated, this is the place.
990-
config_helpers::compute_nof_sr_csi_pucch_res(
991-
du_pucch_cfg,
992-
base_cell.ul_common_cfg.max_pucchs_per_slot,
993-
base_cell.pucch_cfg.sr_period_msec,
994-
base_cell.csi_cfg.csi_rs_enabled ? optional<unsigned>{base_cell.csi_cfg.csi_rs_period_msec} : nullopt);
991+
config_helpers::compute_nof_sr_csi_pucch_res(du_pucch_cfg,
992+
base_cell.ul_common_cfg.max_pucchs_per_slot,
993+
base_cell.pucch_cfg.sr_period_msec,
994+
base_cell.csi_cfg.csi_rs_enabled
995+
? std::optional<unsigned>{base_cell.csi_cfg.csi_rs_period_msec}
996+
: std::nullopt);
995997
if (update_msg1_frequency_start) {
996998
rach_cfg.rach_cfg_generic.msg1_frequency_start = config_helpers::compute_prach_frequency_start(
997999
du_pucch_cfg, out_cell.ul_cfg_common.init_ul_bwp.generic_params.crbs.length(), is_long_prach);

apps/gnb/gnb_appconfig_validators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static bool validate_log_appconfig(const log_appconfig& config)
2727
return true;
2828
}
2929

30-
static bool validate_hal_config(const optional<hal_appconfig>& config)
30+
static bool validate_hal_config(const std::optional<hal_appconfig>& config)
3131
{
3232
#ifdef DPDK_FOUND
3333
if (config && config->eal_args.empty()) {

apps/services/console_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class console_helper : public app_state_notifier
7272
metrics_plotter_stdout metrics_plotter;
7373
metrics_plotter_json metrics_json;
7474
std::vector<du_cell_config> cells;
75-
optional<ru_controller*> radio_controller;
75+
std::optional<ru_controller*> radio_controller;
7676
srs_cu_cp::cu_cp_command_handler& cu_cp;
7777
bool autostart_stdout_metrics = false;
7878

apps/services/worker_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void worker_manager::create_prio_worker(const std::string&
119119
using namespace execution_config_helper;
120120

121121
const single_worker worker_desc{
122-
name, {concurrent_queue_policy::locking_mpsc, queue_size}, execs, nullopt, prio, mask};
122+
name, {concurrent_queue_policy::locking_mpsc, queue_size}, execs, std::nullopt, prio, mask};
123123
if (not exec_mng.add_execution_context(create_execution_context(worker_desc))) {
124124
report_fatal_error("Failed to instantiate {} execution context", worker_desc.name);
125125
}
@@ -237,7 +237,7 @@ void worker_manager::create_du_executors(bool is_blocking_m
237237

238238
slot_workers[cell_id].executors.emplace_back("cell_exec#" + cell_id_str, task_priority::max - 1);
239239
slot_workers[cell_id].executors.push_back(
240-
{"slot_exec#" + cell_id_str, task_priority::max, {}, nullopt, is_blocking_mode_active});
240+
{"slot_exec#" + cell_id_str, task_priority::max, {}, std::nullopt, is_blocking_mode_active});
241241

242242
if (not exec_mng.add_execution_context(create_execution_context(slot_workers[cell_id]))) {
243243
report_fatal_error("Failed to instantiate {} execution context", slot_workers[cell_id].name);

apps/units/cu_cp/cu_cp_unit_config.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ namespace srsran {
2323

2424
/// Report configuration, for now only supporting the A3 event.
2525
struct cu_cp_unit_report_config {
26-
unsigned report_cfg_id;
27-
std::string report_type;
28-
optional<unsigned> report_interval_ms;
29-
std::string a3_report_type;
26+
unsigned report_cfg_id;
27+
std::string report_type;
28+
std::optional<unsigned> report_interval_ms;
29+
std::string a3_report_type;
3030
/// [-30..30] Note the actual value is field value * 0.5 dB. E.g. putting a value of -6 here results in -3dB offset.
31-
optional<int> a3_offset_db;
32-
optional<unsigned> a3_hysteresis_db;
33-
optional<unsigned> a3_time_to_trigger_ms;
31+
std::optional<int> a3_offset_db;
32+
std::optional<unsigned> a3_hysteresis_db;
33+
std::optional<unsigned> a3_time_to_trigger_ms;
3434
};
3535

3636
struct cu_cp_unit_neighbor_cell_config_item {
@@ -43,26 +43,26 @@ struct cu_cp_unit_neighbor_cell_config_item {
4343
/// Each item describes the relationship between one cell to all other cells.
4444
struct cu_cp_unit_cell_config_item {
4545
/// Cell id.
46-
uint64_t nr_cell_id;
47-
optional<unsigned> periodic_report_cfg_id;
46+
uint64_t nr_cell_id;
47+
std::optional<unsigned> periodic_report_cfg_id;
4848

4949
// These parameters must only be set for external cells
5050
/// gNodeB identifier bit length.
51-
optional<unsigned> gnb_id_bit_length;
51+
std::optional<unsigned> gnb_id_bit_length;
5252
/// PCI.
53-
optional<pci_t> pci;
53+
std::optional<pci_t> pci;
5454
/// NR band.
55-
optional<nr_band> band;
55+
std::optional<nr_band> band;
5656
/// SSB ARFCN.
57-
optional<unsigned> ssb_arfcn;
57+
std::optional<unsigned> ssb_arfcn;
5858
/// SSB subcarrier spacing.
59-
optional<unsigned> ssb_scs;
59+
std::optional<unsigned> ssb_scs;
6060
/// SSB period.
61-
optional<unsigned> ssb_period;
61+
std::optional<unsigned> ssb_period;
6262
/// SSB offset.
63-
optional<unsigned> ssb_offset;
63+
std::optional<unsigned> ssb_offset;
6464
/// SSB duration.
65-
optional<unsigned> ssb_duration;
65+
std::optional<unsigned> ssb_duration;
6666
/// Vector of cells that are a neighbor of this cell.
6767
std::vector<cu_cp_unit_neighbor_cell_config_item> ncells;
6868
// TODO: Add optional SSB parameters.

apps/units/flexible_du/du_high/du_high_config.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct du_high_unit_ssb_config {
6565
/// Common uplink parameters of a cell.
6666
struct du_high_unit_ul_common_config {
6767
/// Maximum transmit power allowed in this serving cell. Values: {-30,...,33}dBm.
68-
optional<int> p_max;
68+
std::optional<int> p_max;
6969
/// Maximum number of PUCCH grants per slot.
7070
unsigned max_pucchs_per_slot = 31U;
7171
/// Maximum number of PUSCH + PUCCH grants per slot.
@@ -236,7 +236,7 @@ struct du_high_unit_pucch_config {
236236
unsigned f2_max_nof_rbs = 1;
237237
/// \brief Maximum payload in bits that can be carried by PUCCH Format 2. Values {-1,...,11}.
238238
/// Value -1 to unset. If this is set, \ref f2_max_nof_rbs is ignored.
239-
optional<unsigned> max_payload_bits;
239+
std::optional<unsigned> max_payload_bits;
240240
/// Set true for PUCCH Format 2 intra-slot frequency hopping. This field is ignored if f2_nof_symbols == 1.
241241
bool f2_intraslot_freq_hopping = false;
242242
/// Max code rate.
@@ -254,7 +254,7 @@ struct du_high_unit_pucch_config {
254254
struct du_high_unit_phy_cell_group_config {
255255
/// \brief \c p-NR-FR1, part of \c PhysicalCellGroupConfig, TS 38.331. Values: {-30,...,33}.
256256
/// The maximum total TX power to be used by the UE in this NR cell group across all serving cells in FR1.
257-
optional<int> p_nr_fr1;
257+
std::optional<int> p_nr_fr1;
258258
};
259259

260260
/// TDD pattern configuration. See TS 38.331, \c TDD-UL-DL-Pattern.
@@ -273,8 +273,8 @@ struct tdd_ul_dl_pattern_unit_config {
273273

274274
/// TDD configuration. See TS 38.331, \c TDD-UL-DL-ConfigCommon.
275275
struct du_high_unit_tdd_ul_dl_config {
276-
tdd_ul_dl_pattern_unit_config pattern1;
277-
optional<tdd_ul_dl_pattern_unit_config> pattern2;
276+
tdd_ul_dl_pattern_unit_config pattern1;
277+
std::optional<tdd_ul_dl_pattern_unit_config> pattern2;
278278
};
279279

280280
/// Paging related configuration. See TS 38.331, PCCH-Config.
@@ -294,24 +294,24 @@ struct du_high_unit_paging_config {
294294
/// PDCCH Common configuration.
295295
struct pdcch_common_unit_config {
296296
/// CORESET#0 index as per tables in TS 38.213, clause 13.
297-
optional<unsigned> coreset0_index;
297+
std::optional<unsigned> coreset0_index;
298298
/// Number of PDCCH candidates per aggregation level for SearchSpace#1. The aggregation level for the array element
299299
/// with index "x" is L=1U << x. The possible values for each element are {0, 1, 2, 3, 4, 5, 6, 8}.
300300
std::array<uint8_t, 5> ss1_n_candidates = {0, 0, 1, 0, 0};
301301
/// SearchSpace#0 index as per tables in TS 38.213, clause 13.
302302
unsigned ss0_index = 0;
303303
/// Maximum CORESET#0 duration in OFDM symbols to consider when deriving CORESET#0 index.
304-
optional<uint8_t> max_coreset0_duration;
304+
std::optional<uint8_t> max_coreset0_duration;
305305
};
306306

307307
/// PDCCH Dedicated configuration.
308308
struct pdcch_dedicated_unit_config {
309309
/// Starting Common Resource Block (CRB) number for CORESET 1 relative to CRB 0.
310-
optional<unsigned> coreset1_rb_start;
310+
std::optional<unsigned> coreset1_rb_start;
311311
/// Length of CORESET 1 in number of CRBs.
312-
optional<unsigned> coreset1_l_crb;
312+
std::optional<unsigned> coreset1_l_crb;
313313
/// Duration of CORESET 1 in number of OFDM symbols.
314-
optional<unsigned> coreset1_duration;
314+
std::optional<unsigned> coreset1_duration;
315315
/// Number of PDCCH candidates per aggregation level for SearchSpace#2. The aggregation level for the array element
316316
/// with index "x" is L=1U << x. The possible values for each element are {0, 1, 2, 3, 4, 5, 6, 8}.
317317
/// NOTE: A value of {0, 0, 0, 0, 0} lets the gNB decide nof. candidates for SearchSpace#2.
@@ -382,13 +382,13 @@ struct du_high_unit_csi_config {
382382
unsigned csi_rs_period_msec = 20;
383383
/// \brief Slot offset for measurement CSI-RS resources. If not set, it is automatically derived to avoid collisions
384384
/// with SSB and SIB1.
385-
optional<unsigned> meas_csi_slot_offset;
385+
std::optional<unsigned> meas_csi_slot_offset;
386386
/// \brief Slot offset of the first CSI-RS resource used for tracking. If not set, it is automatically derived to
387387
/// avoid collisions with SSB and SIB1.
388-
optional<unsigned> tracking_csi_slot_offset;
388+
std::optional<unsigned> tracking_csi_slot_offset;
389389
/// \brief Slot offset for the zp-CSI-RS resources. If not set, it is automatically derived to avoid collisions with
390390
/// SSB and SIB1.
391-
optional<unsigned> zp_csi_slot_offset;
391+
std::optional<unsigned> zp_csi_slot_offset;
392392
/// \brief \c powerControlOffset, part of \c NZP-CSI-RS-Resource, as per TS 38.331.
393393
/// Power offset of PDSCH RE to NZP CSI-RS RE. Value in dB {-8,...,15}.
394394
int pwr_ctrl_offset = 0;
@@ -404,7 +404,7 @@ struct mac_bsr_unit_config {
404404
/// 2560, 5120, 10240}.
405405
unsigned retx_bsr_timer = 80;
406406
/// Logical Channel SR delay timer in nof. subframes. Values {20, 40, 64, 128, 512, 1024, 2560}.
407-
optional<unsigned> lc_sr_delay_timer;
407+
std::optional<unsigned> lc_sr_delay_timer;
408408
};
409409

410410
/// MAC Power Headroom Reporting configuration.
@@ -418,7 +418,7 @@ struct mac_phr_unit_config {
418418
struct mac_sr_unit_config {
419419
/// \brief \c sr-ProhibitTimer, or timer for SR transmission on PUCCH.
420420
/// Values are in ms. Values: {1, 2, 4, 8, 16, 32, 64, 128}. When the field is absent, the UE applies the value 0.
421-
optional<unsigned> sr_prohibit_timer;
421+
std::optional<unsigned> sr_prohibit_timer;
422422
/// \brief \c sr-TransMax possible values, or maximum number of SR transmissions.
423423
/// Values: {4, 8, 16, 32, 64}.
424424
unsigned sr_trans_max = 64;
@@ -437,7 +437,7 @@ struct du_high_unit_mac_cell_group_config {
437437
/// PRACH application configuration.
438438
struct du_high_unit_prach_config {
439439
/// PRACH configuration index. If not specified, it is automatically derived to fit in an UL slot.
440-
optional<unsigned> prach_config_index;
440+
std::optional<unsigned> prach_config_index;
441441
/// PRACH root sequence index.
442442
unsigned prach_root_sequence_index = 1;
443443
/// Zero correlation zone
@@ -448,11 +448,11 @@ struct du_high_unit_prach_config {
448448
/// valid.
449449
int preamble_rx_target_pw = -100;
450450
/// Total number of PRACH preambles used for contention based and contention free 4-step or 2-step random access.
451-
optional<unsigned> total_nof_ra_preambles;
451+
std::optional<unsigned> total_nof_ra_preambles;
452452
/// Offset of lowest PRACH transmission occasion in frequency domain respective to PRB 0. To minimize interference
453453
/// with the PUCCH, the user should leave some guardband between the PUCCH CRBs and the PRACH PRBs.
454454
/// Possible values: {0,...,MAX_NOF_PRB - 1}.
455-
optional<unsigned> prach_frequency_start;
455+
std::optional<unsigned> prach_frequency_start;
456456
/// Max number of RA preamble transmissions performed before declaring a failure. Values {3, 4, 5, 6, 7, 8, 10, 20,
457457
/// 50, 100, 200}.
458458
uint8_t preamble_trans_max = 7;
@@ -479,7 +479,7 @@ struct du_high_unit_base_cell_config {
479479
/// Common subcarrier spacing for the entire resource grid. It must be supported by the band SS raster.
480480
subcarrier_spacing common_scs = subcarrier_spacing::kHz15;
481481
/// NR band.
482-
optional<nr_band> band;
482+
std::optional<nr_band> band;
483483
/// Channel bandwidth in MHz.
484484
bs_channel_bandwidth_fr1 channel_bw_mhz = bs_channel_bandwidth_fr1::MHz20;
485485
/// Number of antennas in downlink.
@@ -515,7 +515,7 @@ struct du_high_unit_base_cell_config {
515515
/// MAC Cell Gropup parameters.
516516
du_high_unit_mac_cell_group_config mcg_cfg;
517517
/// TDD slot configuration.
518-
optional<du_high_unit_tdd_ul_dl_config> tdd_ul_dl_cfg;
518+
std::optional<du_high_unit_tdd_ul_dl_config> tdd_ul_dl_cfg;
519519
/// Paging configuration.
520520
du_high_unit_paging_config paging_cfg;
521521
/// CSI configuration.
@@ -530,7 +530,7 @@ struct du_high_unit_test_mode_ue_config {
530530
/// \brief Delay, in slots, before the MAC test mode auto-generates the UCI/CRC indication to pass to the scheduler.
531531
/// This feature should be avoided if the OFH/UL PHY are operational, otherwise the auto-generated indications
532532
/// may interfere with the UL PHY HARQ handling.
533-
optional<unsigned> auto_ack_indication_delay;
533+
std::optional<unsigned> auto_ack_indication_delay;
534534
/// Whether PDSCH grants are automatically assigned to the test UE.
535535
bool pdsch_active = true;
536536
/// Whether PUSCH grants are automatically assigned to the test UE.
@@ -729,7 +729,7 @@ struct du_high_unit_config {
729729
/// Configuration for testing purposes.
730730
du_high_unit_test_mode_config test_mode_cfg = {};
731731
/// NTN configuration.
732-
optional<ntn_config> ntn_cfg;
732+
std::optional<ntn_config> ntn_cfg;
733733
/// \brief Cell configuration.
734734
///
735735
/// \note Add one cell by default.

apps/units/flexible_du/du_high/du_high_config_cli11_schema.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,11 +1285,11 @@ static void configure_cli11_ephemeris_info_orbital(CLI::App& app, orbital_coordi
12851285
->capture_default_str();
12861286
}
12871287

1288-
static void configure_cli11_ntn_args(CLI::App& app,
1289-
optional<ntn_config>& ntn,
1290-
epoch_time_t& epoch_time,
1291-
orbital_coordinates_t& orbital_coordinates,
1292-
ecef_coordinates_t& ecef_coordinates)
1288+
static void configure_cli11_ntn_args(CLI::App& app,
1289+
std::optional<ntn_config>& ntn,
1290+
epoch_time_t& epoch_time,
1291+
orbital_coordinates_t& orbital_coordinates,
1292+
ecef_coordinates_t& ecef_coordinates)
12931293
{
12941294
ntn_config& config = ntn.emplace();
12951295

0 commit comments

Comments
 (0)