P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::ControlPlaneAPI::P4InfoMaps Class Reference

#include <p4info_map.h>

Public Member Functions

 P4InfoMaps (const p4::config::v1::P4Info &p4Info)
 
std::optional< cstringlookUpControlPlaneName (uint64_t id) const
 
std::optional< uint64_t > lookUpP4RuntimeId (cstring controlPlaneName) const
 

Protected Member Functions

virtual void buildP4InfoMaps (const p4::config::v1::P4Info &p4Info)
 Iterate over the P4Info object and build a mapping from P4 control plane names to their ids.
 

Protected Attributes

P4RuntimeIdToControlPlaneNameMap idToNameMap
 Maps P4Runtime IDs to control plane names.
 
ControlPlaneNameToP4RuntimeIdMap nameToIdMap
 Maps control plane names to P4Runtime IDs.
 

Detailed Description

This object maps P4 control plane names to their P4Runtime IDs and vice versa. It uses the P4Info object to populate the maps. Since ids for action parameters and table keys are not unique, we use a pairing function to compute a unique identifier. This pairing function uses the id of the parent object (e.g., a table or action) and combines it with the id of the parameter or key element to create a unique identifier.

Member Function Documentation

◆ lookUpControlPlaneName()

std::optional< cstring > P4::ControlPlaneAPI::P4InfoMaps::lookUpControlPlaneName ( uint64_t id) const
nodiscard

Looks up the control plane name for the given P4Runtime id in the pre-computed P4Runtime-ID map.

Returns
std::nullopt if the id is not in the map.

◆ lookUpP4RuntimeId()

std::optional< uint64_t > P4::ControlPlaneAPI::P4InfoMaps::lookUpP4RuntimeId ( cstring controlPlaneName) const
nodiscard

Looks up the P4Runtime id for the given control plane name in the pre-computed P4Runtime-ID map.

Returns
std::nullopt if the name is not in the map.