Poplar and PopLibs
poplar::StreamCallbackHandle Class Reference

Wrapper for StreamCallback instances. More...

#include <StreamCallback.hpp>

Public Member Functions

template<class CallbackImpl , typename = typename std::enable_if< std::is_base_of<StreamCallback, CallbackImpl>::value || std::is_base_of<StreamCallbackWithMetadata, CallbackImpl>::value>::type>
 StreamCallbackHandle (std::unique_ptr< CallbackImpl > f)
 Constructs a handle from an instance of a stream callback implementation. More...
 
template<class F , typename = typename std::enable_if< traits::is_callback<F>::value>::type>
 StreamCallbackHandle (F &&f)
 Constructs a handle from a callable instance. More...
 
 operator std::unique_ptr< StreamCallbackBase > () &&
 Extracts the callback implementation from the handle.
 
 operator std::unique_ptr< StreamCallback > () &&
 Extract callback implementation after casting to StreamCallback. More...
 
 operator std::unique_ptr< StreamCallbackWithMetadata > () &&
 Extract callback implementation after casting to StreamCallbackWithMetadata. More...
 

Detailed Description

Wrapper for StreamCallback instances.

Provides backwards compatibility with C++ lambda expressions and std::function instances.

Constructor & Destructor Documentation

◆ StreamCallbackHandle() [1/2]

template<class CallbackImpl , typename = typename std::enable_if< std::is_base_of<StreamCallback, CallbackImpl>::value || std::is_base_of<StreamCallbackWithMetadata, CallbackImpl>::value>::type>
poplar::StreamCallbackHandle::StreamCallbackHandle ( std::unique_ptr< CallbackImpl >  f)
inline

Constructs a handle from an instance of a stream callback implementation.

This constructor only participates in overload resolution if CallbackImpl is derived from either poplar::StreamCallback or poplar::StreamCallbackWithMetadata (in other words, it is an implementation of the callback interface).

◆ StreamCallbackHandle() [2/2]

template<class F , typename = typename std::enable_if< traits::is_callback<F>::value>::type>
poplar::StreamCallbackHandle::StreamCallbackHandle ( F &&  f)
inline

Constructs a handle from a callable instance.

This constructor only participates in overload resolution if F satisfies the requirements of a Function Object. It transforms f into a LegacyStreamCallback implementation.

See also
https://en.cppreference.com/w/cpp/named_req/FunctionObject

Member Function Documentation

◆ operator std::unique_ptr< StreamCallback >()

poplar::StreamCallbackHandle::operator std::unique_ptr< StreamCallback > ( ) &&

Extract callback implementation after casting to StreamCallback.

This function will return the callback only if the pointer matches StreamCallback and does not match StreamCallbackWithMetadata. Otherwise nullptr is returned.

◆ operator std::unique_ptr< StreamCallbackWithMetadata >()

poplar::StreamCallbackHandle::operator std::unique_ptr< StreamCallbackWithMetadata > ( ) &&

Extract callback implementation after casting to StreamCallbackWithMetadata.

This function will return the callback only if the pointer matches StreamCallbackWithMetadata. Otherwise nullptr is returned.


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