bmv2
Designing your own switch target with bmv2
Public Member Functions | Private Member Functions | List of all members
bm::Context Class Referencefinal

Public Member Functions

template<typename T >
bool add_component (std::shared_ptr< T > ptr)
 
template<typename T >
std::shared_ptr< T > get_component ()
 
Pipelineget_pipeline (const std::string &name)
 
Parserget_parser (const std::string &name)
 
Deparserget_deparser (const std::string &name)
 
FieldListget_field_list (const p4object_id_t field_list_id)
 
ExternSafeAccess get_extern_instance (const std::string &name)
 

Private Member Functions

ConfigOptionMap get_config_options () const
 
ErrorCodeMap get_error_codes () const
 

Detailed Description

Implements a switch within a switch.

See context.h description for more information.

Member Function Documentation

◆ add_component()

template<typename T >
bool bm::Context::add_component ( std::shared_ptr< T >  ptr)
inline

Add a component to this Context. Each Context maintains a map T -> shared_ptr<T>, which maps a type (using typeid) to a shared pointer to an object of the same type. The pointer can be retrieved at a later time by using get_component().

◆ get_component()

template<typename T >
std::shared_ptr<T> bm::Context::get_component ( )
inline

Retrieve the shared pointer to an object of type T previously added to the Context using add_component().

◆ get_config_options()

ConfigOptionMap bm::Context::get_config_options ( ) const
private

Return string-to-string map of the target-specific options included in the input config JSON for this context.

◆ get_deparser()

Deparser* bm::Context::get_deparser ( const std::string &  name)
inline

Get a raw, non-owning pointer to the Deparser object with P4 name name. Return a nullptr if there is no deparser with this name.

◆ get_error_codes()

ErrorCodeMap bm::Context::get_error_codes ( ) const
private

Return a copy of the error codes map (a bi-directional map between an error code's integral value and its name / description).

◆ get_extern_instance()

ExternSafeAccess bm::Context::get_extern_instance ( const std::string &  name)

Obtain a pointer to an extern instance, wrapped inside an ExternSafeAccess object. The wrapper holds a shared mutex, to make sure that accessing the extern is safe (in the case where a P4 swap occurs).

◆ get_field_list()

FieldList* bm::Context::get_field_list ( const p4object_id_t  field_list_id)
inline

Get a raw, non-owning pointer to the FieldList object with id field_list_id

◆ get_parser()

Parser* bm::Context::get_parser ( const std::string &  name)
inline

Get a raw, non-owning pointer to the Parser object with P4 name name. Return a nullptr if there is no parser with this name.

◆ get_pipeline()

Pipeline* bm::Context::get_pipeline ( const std::string &  name)
inline

Get a raw, non-owning pointer to the Pipeline object with P4 name name. Return a nullptr if there is no pipeline with this name.


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