Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Mix-in to support builder functions to accept optional qualifier terms.
For the classical builder pattern we define a dedicated builder class, which in turn offers explicitly named setter or configuration functions. However, sometimes it is desirable just to offer some builder-like extension on regular constructor syntax, where optional additional parameters may be passed to adapt the basic setup. Unfortunately, a list of optional further argument tends to become hard to read, especially when some dummy arguments must be passed in order to supply a setting further down the list.
This mix-in template instead allows to define qualifier terms, and to pass an arbitrary sequence of such terms to a constructor or builder function. These qualifiers look like "algebraic data types" at invocation site, i.e. they are named terms, optionally even accepting further arguments. Yet for the implementation, these qualifiers return a wrapped functor. When defined as friend function, the generated qualifier functors may even manipulate private internals of the "Builder" or "Strategy" class.
build()
function). qualify()
function accepts the qualifier functors by-reference; thus it is up to the user to either pass them by-value, by reverence or even by perfect forwarding.Definition in file builder-qualifier-support.hpp.
#include <functional>
Classes | |
class | BuilderQualifierSupport< TAR > |
Mix-in to accept and apply an arbitrary sequence of qualifier functors. More... | |
struct | BuilderQualifierSupport< TAR >::Qualifier |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |