bmv2
Designing your own switch target with bmv2
Public Member Functions | List of all members
bm::Stack< T, ShiftImpl > Class Template Reference
Inheritance diagram for bm::Stack< T, ShiftImpl >:
Inheritance graph
[legend]

Public Member Functions

size_t pop_front () override
 
size_t pop_front (size_t num) override
 
size_t push_front () override
 
size_t push_front (size_t num) override
 
size_t get_depth () const override
 Returns the maximum capacity of the stack. More...
 
size_t get_count () const override
 Returns the current occupancy of the stack. More...
 
bool is_full () const override
 Returns true if the header stack is full. 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

template<typename T, typename ShiftImpl>
class bm::Stack< T, ShiftImpl >

Stack is used to represent header and union stacks in P4. The Stack class itself does not store any union / header / field data itself, but stores references to the HeaderUnion / Header instances which constitute the stack, as well as the stack's internal state (e.g. number of valid headers in the stack).

Member Function Documentation

◆ get_count()

template<typename T , typename ShiftImpl >
size_t bm::Stack< T, ShiftImpl >::get_count ( ) const
overridevirtual

Returns the current occupancy of the stack.

Implements bm::StackIface.

◆ get_depth()

template<typename T , typename ShiftImpl >
size_t bm::Stack< T, ShiftImpl >::get_depth ( ) const
overridevirtual

Returns the maximum capacity of the stack.

Implements bm::StackIface.

◆ is_full()

template<typename T , typename ShiftImpl >
bool bm::Stack< T, ShiftImpl >::is_full ( ) const
overridevirtual

Returns true if the header stack is full.

Implements bm::StackIface.

◆ pop_front() [1/2]

template<typename T , typename ShiftImpl >
size_t bm::Stack< T, ShiftImpl >::pop_front ( )
overridevirtual

Removes the first element of the stack. Returns the number of elements removed. The second element of the stack becomes the first element, and so on...

Implements bm::StackIface.

◆ pop_front() [2/2]

template<typename T , typename ShiftImpl >
size_t bm::Stack< T, ShiftImpl >::pop_front ( size_t  num)
overridevirtual

Removes the first num element of the stack. Returns the number of elements removed. Calling this function is more efficient than calling pop_front() multiple times.

Implements bm::StackIface.

◆ push_front() [1/2]

template<typename T , typename ShiftImpl >
size_t bm::Stack< T, ShiftImpl >::push_front ( )
overridevirtual

Pushes an element to the front of the stack. If the stack is already full, the last element of the stack will be discarded. This function returns the number of elements pushed, which is guaranteed to be always 1. The first element of the stack is marked valid (note that it was already valid if the stack was not empty).

Implements bm::StackIface.

◆ push_front() [2/2]

template<typename T , typename ShiftImpl >
size_t bm::Stack< T, ShiftImpl >::push_front ( size_t  num)
overridevirtual

Pushes num elements to the front of the stack. If the stack becomes full, the extra elements at the bottom of the stack will be discarded. This function returns the number of elements pushed, which is guaranteed to be min(get_depth(), num)`. All inserted elements are guaranteed to be marked valid. Calling this function is more efficient that calling push_front() multiple times.

Implements bm::StackIface.


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