14#ifndef ZYPPNG_PIPELINES_ALGORITHM_H_INCLUDED
15#define ZYPPNG_PIPELINES_ALGORITHM_H_INCLUDED
17#include <zypp-core/zyppng/async/AsyncOp>
28 if ( value )
return true;
36 template <
class Container,
class AsyncResType,
class Transformation,
class Predicate,
class DefaultType >
39 AsyncFirstOfImpl( Container &&inData, Transformation &&transFunc, DefaultType &&defaultVal, Predicate &&predicate )
91 template <
class Transformation,
class Predicate,
class DefaultType >
94 FirstOfHelper( Transformation transFunc, DefaultType defaultVal, Predicate predicate )
99 template <
class Container
103 using InputType =
typename Container::value_type;
104 static_assert( std::is_invocable_v<Transformation, InputType>,
"Transformation function must take the container value type as input " );
105 static_assert( std::is_rvalue_reference_v<decltype(std::forward<Container>(container))>,
"Input container must be a rvalue reference" );
107 using OutputType = std::invoke_result_t<Transformation, InputType>;
113 static_assert( std::is_same_v<AsyncResultType, DefaultType>,
"Default type and transformation result type must match" );
120 static_assert( std::is_same_v<OutputType, DefaultType>,
"Default type and transformation result type must match" );
122 for (
auto &in : std::forward<Container>(container) ) {
148 template <
class Transformation,
class DefaultType,
class Predicate >
155 template <
typename Excpt,
typename ...Rest>
158 if constexpr (
sizeof...(Rest) == 0 ) {
160 std::rethrow_exception ( exceptionPtr );
164 }
catch (
const Excpt &e ) {
186 template <
typename ...Excpt>
207 template <
typename Excpt>
210 std::rethrow_exception ( exceptionPtr );;
211 }
catch (
const Excpt &e ) {
Base class for Exception.
std::enable_if< std::is_member_pointer< typenamestd::decay< Functor >::type >::value, typenamestd::result_of< Functor &&(Args &&...)>::type >::type invoke(Functor &&f, Args &&... args)
Easy-to use interface to the ZYPP dependency resolver.
bool containsOneOfExceptionImpl(const std::exception_ptr &exceptionPtr)
constexpr bool is_async_op_v
std::shared_ptr< AsyncOp< T > > AsyncOpRef
typename remove_smart_ptr< T >::type remove_smart_ptr_t
bool containsOneOfException(const std::exception_ptr &exceptionPtr)
auto firstOf(Transformation &&transformFunc, DefaultType &&def, Predicate &&predicate=detail::ContinueUntilValidPredicate())
bool containsException(const std::exception_ptr &exceptionPtr)
void setReady(value_type &&val)
AsyncOpRef< AsyncResType > _currentPipeline
Container::iterator _currIter
AsyncFirstOfImpl(Container &&inData, Transformation &&transFunc, DefaultType &&defaultVal, Predicate &&predicate)
Transformation _transFunc
void resultReady(AsyncResType &&res)
bool operator()(const Arg &value)
FirstOfHelper(Transformation transFunc, DefaultType defaultVal, Predicate predicate)
Transformation _transFunc
auto operator()(Container &&container)