20 #ifndef GRPPI_COMMON_FARM_PATTERN_H 21 #define GRPPI_COMMON_FARM_PATTERN_H 23 #include <type_traits> 32 template <
typename Transformer>
43 farm_t(
int n, Transformer && t) noexcept :
44 cardinality_{n}, transformer_{t}
67 return transformer_(std::forward<I>(item));
72 Transformer transformer_;
static constexpr bool is_farm
Definition: farm_pattern.h:86
Definition: callable_traits.h:26
auto operator()(I &&item) const
Invokes the trasnformer of the farm over a data item.
Definition: farm_pattern.h:66
Definition: farm_pattern.h:78
int cardinality() const noexcept
Farm's cardinality or number of replicas.
Definition: farm_pattern.h:51
Representation of farm pattern. Represents a farm of n replicas from a transformer.
Definition: farm_pattern.h:33
Transformer transformer_type
Definition: farm_pattern.h:36
farm_t(int n, Transformer &&t) noexcept
Constructs a farm with a cardinality and a transformer.
Definition: farm_pattern.h:43
typename std::enable_if_t< is_farm< T >, int > requires_farm
Definition: farm_pattern.h:89
Transformer & transformer()
Return the transformer function stored in the farm pattern.
Definition: farm_pattern.h:59