void PHV::push_back_header(const std::string &header_name, header_id_t header_index, const HeaderType &header_type, const std::set<int> &arith_offsets, const bool metadata) { assert(header_index < static_cast<int>(capacity)); assert(header_index == static_cast<int>(headers.size())); // cannot call push_back here, as the Header constructor passes "this" to the // Field constructor (i.e. Header cannot be moved or the pointer would be // invalid); this is not a very robust design headers.emplace_back( header_name, header_index, header_type, arith_offsets, metadata); headers.back().set_packet_id(&packet_id); headers_map.emplace(header_name, get_header(header_index)); for (int i = 0; i < header_type.get_num_fields(); i++) { const std::string name = header_name + "." + header_type.get_field_name(i); // std::cout << header_index << " " << i << " " << name << std::endl; fields_map.emplace(name, get_field(header_index, i)); } if (header_type.is_VL_header()) { headers.back().VL_expr = header_type.resolve_VL_expr(header_index); if (headers.back().VL_expr != nullptr) { for (const int offset : header_type.get_VL_input_offsets()) headers.back()[offset].set_arith(true); } } }