bmv2
Designing your own switch target with bmv2
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
bm::StackIface Class Referenceabstract
Inheritance diagram for bm::StackIface:
Inheritance graph
[legend]

Public Member Functions

virtual size_t pop_front ()=0
 
virtual size_t pop_front (size_t num)=0
 
virtual size_t push_front ()=0
 
virtual size_t push_front (size_t num)=0
 
virtual size_t get_depth () const =0
 Returns the maximum capacity of the stack. More...
 
virtual size_t get_count () const =0
 Returns the current occupancy of the stack. More...
 
virtual bool is_full () const =0
 Returns true if the header stack is full. More...
 

Detailed Description

Interface to a P4 stack (of headers or header unions). A StackIface reference can be used in an action primitive. For example:

struct pop : public ActionPrimitive<StackIface &, const Data &> {
void operator ()(StackIface &stack, const Data &num) {
stack.pop_front(num.get<size_t>());
};

Member Function Documentation

◆ get_count()

virtual size_t bm::StackIface::get_count ( ) const
pure virtual

Returns the current occupancy of the stack.

Implemented in bm::Stack< T, ShiftImpl >.

◆ get_depth()

virtual size_t bm::StackIface::get_depth ( ) const
pure virtual

Returns the maximum capacity of the stack.

Implemented in bm::Stack< T, ShiftImpl >.

◆ is_full()

virtual bool bm::StackIface::is_full ( ) const
pure virtual

Returns true if the header stack is full.

Implemented in bm::Stack< T, ShiftImpl >.

◆ pop_front() [1/2]

virtual size_t bm::StackIface::pop_front ( )
pure virtual

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...

Implemented in bm::Stack< T, ShiftImpl >, bm::Stack< T, StackP4_16< T > >, and bm::Stack< T, StackLegacy< T > >.

◆ pop_front() [2/2]

virtual size_t bm::StackIface::pop_front ( size_t  num)
pure virtual

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.

Implemented in bm::Stack< T, ShiftImpl >, bm::Stack< T, StackP4_16< T > >, and bm::Stack< T, StackLegacy< T > >.

◆ push_front() [1/2]

virtual size_t bm::StackIface::push_front ( )
pure virtual

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).

Implemented in bm::Stack< T, ShiftImpl >, bm::Stack< T, StackP4_16< T > >, and bm::Stack< T, StackLegacy< T > >.

◆ push_front() [2/2]

virtual size_t bm::StackIface::push_front ( size_t  num)
pure virtual

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.

Implemented in bm::Stack< T, ShiftImpl >, bm::Stack< T, StackP4_16< T > >, and bm::Stack< T, StackLegacy< T > >.


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