bmv2
Designing your own switch target with bmv2
Public Member Functions | List of all members
bm::HeaderUnion Class Reference
Inheritance diagram for bm::HeaderUnion:
Inheritance graph
[legend]

Public Member Functions

Headerget_valid_header () const
 
size_t get_num_headers () const
 Returns the number of headers included in the union. More...
 
Headerat (size_t idx)
 
const Headerat (size_t idx) const
 
bool is_valid () const
 Returns true if one of the headers in the union is valid. More...
 
- Public Member Functions inherited from bm::NamedP4Object
const std::string & get_name () const
 Get the name of the P4 instance. More...
 
p4object_id_t get_id () const
 Get the compiler-provided id. More...
 
 NamedP4Object (const NamedP4Object &other)=delete
 Deleted copy constructor. More...
 
NamedP4Objectoperator= (const NamedP4Object &other)=delete
 Deleted copy assignment operator. More...
 
 NamedP4Object (NamedP4Object &&other)=default
 Default move constructor. More...
 
NamedP4Objectoperator= (NamedP4Object &&other)=default
 Default assignment operator. More...
 

Detailed Description

Used to represent P4 header union instances. It stores references to the Header instances included in the union and ensures that at most one of these instances is valid at any given time.

A HeaderUnion reference can be used in an action primitive. For example:

class my_primitive : public ActionPrimitive<HeaderUnion &, const Data &> {
void operator ()(HeaderUnion &header_union) {
// ...
}
};

Member Function Documentation

◆ at() [1/2]

Header& bm::HeaderUnion::at ( size_t  idx)
inline

Access the Header at index idx in the union. If the index is invalid, an std::out_of_range exception will be thrown.

◆ at() [2/2]

const Header& bm::HeaderUnion::at ( size_t  idx) const
inline

Access the Header at index idx in the union. If the index is invalid, an std::out_of_range exception will be thrown.

◆ get_num_headers()

size_t bm::HeaderUnion::get_num_headers ( ) const
inline

Returns the number of headers included in the union.

◆ get_valid_header()

Header* bm::HeaderUnion::get_valid_header ( ) const
inline

Returns a pointer to the valid Header instance in the union, or nullptr if no header is valid.

◆ is_valid()

bool bm::HeaderUnion::is_valid ( ) const
inline

Returns true if one of the headers in the union is valid.


The documentation for this class was generated from the following file: