ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
rpp::specific_observable< Type, OnSubscribeFn > Class Template Reference

Type-full observable (or typed) that has the notion of Type and upstream observables for C++ compiler. e.g. observable<int, map<bool, ...recursive...>> is different from observable<int, filter<int, ...>>. More...

#include <specific_observable.hpp>

Inheritance diagram for rpp::specific_observable< Type, OnSubscribeFn >:
rpp::interface_observable< Type, specific_observable< Type, OnSubscribeFn > > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::member_overload< Type, SpecificObservable, MemberTag > rpp::details::typed_observable_tag< Type > rpp::grouped_observable< KeyType, Type, OnSubscribeFn >

Public Member Functions

 specific_observable (OnSubscribeFn &&on_subscribe)
 
 specific_observable (const OnSubscribeFn &on_subscribe)
 
 specific_observable (const specific_observable &other)=default
 
 specific_observable (specific_observable &&other) noexcept=default
 
specific_observableoperator= (const specific_observable &other)=default
 
specific_observableoperator= (specific_observable &&other) noexcept=default
 
template<typename... Args>
requires details::is_header_included<details::dynamic_observable_tag, Args...>
auto as_dynamic () const &
 Converts rpp::specific_observable to rpp::dynamic_observable via type-erasure mechanism.
 
template<typename... Args>
requires details::is_header_included<details::dynamic_observable_tag, Args...>
auto as_dynamic () &&
 
- Public Member Functions inherited from rpp::interface_observable< Type, specific_observable< Type, OnSubscribeFn > >
auto op (OperatorFn &&fn) const &
 The apply function to observable which returns observable of another type.
 
auto op (OperatorFn &&fn) &&
 
auto as_blocking () const &
 Converts existing observable to rpp::blocking_observable which has another interface and abilities.
 
auto as_blocking () &&
 

Friends

struct details::member_overload< Type, specific_observable< Type, OnSubscribeFn >, details::subscribe_tag >
 

Detailed Description

template<constraint::decayed_type Type, constraint::on_subscribe_fn< Type > OnSubscribeFn>
class rpp::specific_observable< Type, OnSubscribeFn >

Type-full observable (or typed) that has the notion of Type and upstream observables for C++ compiler. e.g. observable<int, map<bool, ...recursive...>> is different from observable<int, filter<int, ...>>.

This is a C++ technique about de-virtualization. To achieve polymorphic behavior, we could either go for function virtualization or function overload. However, virtualization is more expensive than function overload in both compile time and runtime. Therefore, we go for function overload. Actually, we use more advanced functor paradigm for better performance. As a result it has better performance comparing to rpp::dynamic_observable. Use it if possible. But it has worse usability due to OnSubscribeFn template parameter.

Parameters
Typeis the value type. Observable of type means this source could emit a sequence of items of that "Type".
OnSubscribeFnis the on_subscribe functor that is called when a subscriber subscribes to this observable. specific_observable stores OnSubscribeFn as member variable, so, it is stored on stack (instead of allocating it on heap).

This is a C++ technique about de-virtualization. To achieve polymorphic behavior, we could either go for function virtualization or function overload. However, virtualization is more expensive than function overload in both compile time and runtime. Therefore, we go for function overload. Actually, we use more advanced functor paradigm for better performance. As a result it has better performance comparing to rpp::dynamic_observable. Use it if possible. But it has worse usability due to OnSubscribeFn template parameter.

Parameters
Typeis the value type. Observable of type means this source could emit a sequence of items of that "Type".
OnSubscribeFnis the on_subscribe functor that is called when a subscriber subscribes to this observable. specific_observable stores OnSubscribeFn as member variable, so, it is stored on stack (instead of allocating it on heap).

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