GRPC C++  1.62.0
Public Member Functions
grpc_event_engine::experimental::Extensible Class Reference

#include <extensible.h>

Public Member Functions

virtual void * QueryExtension (absl::string_view)
 A method which allows users to query whether an implementation supports a specified extension. More...
 

Member Function Documentation

◆ QueryExtension()

virtual void* grpc_event_engine::experimental::Extensible::QueryExtension ( absl::string_view  )
inlinevirtual

A method which allows users to query whether an implementation supports a specified extension.

The name of the extension is provided as an input.

An extension could be any type with a unique string id. Each extension may support additional capabilities and if the implementation supports the queried extension, it should return a valid pointer to the extension type.

E.g., use case of an EventEngine::Endpoint supporting a custom extension.

class CustomEndpointExtension { public: static std::string EndpointExtensionName() { return "my.namespace.extension_name"; } virtual void Process() = 0; }

class CustomEndpoint : public EventEngine::Endpoint, public CustomEndpointExtension { public: void* QueryExtension(absl::string_view id) override { if (id == CustomEndpointExtension::EndpointExtensionName()) { return static_cast<CustomEndpointExtension*>(this); } return nullptr; } void Process() override { ... } ... }

auto endpoint = static_cast<CustomEndpointExtension*>(endpoint->QueryExtension( CustomEndpointExtension::EndpointExtensionName())); if (endpoint != nullptr) endpoint->Process();


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