Audacity 3.2.0
Public Types | Public Member Functions | Private Member Functions | List of all members
Composite::Builder< Base, Derived, BaseArgs > Struct Template Reference

#include <Composite.h>

Inheritance diagram for Composite::Builder< Base, Derived, BaseArgs >:
[legend]
Collaboration diagram for Composite::Builder< Base, Derived, BaseArgs >:
[legend]

Public Types

using BaseType = Base
 
- Public Types inherited from Composite::Base< Component, ComponentPointer, ComponentArgs >
using value_type = ComponentPointer
 
using Items = std::vector< value_type >
 

Public Member Functions

template<typename Arg >
auto push_back (Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >
 
void push_back (typename Base::value_type arg)
 
template<typename... Items>
 Builder (BaseArgs... args, Items &&... items)
 Variadic constructor. More...
 
template<typename InputIterator , typename Arg = decltype(*std::declval<InputIterator>()), typename ItemBuilder = decltype(Traits<Base, Derived>::ItemBuilder), typename sfinae = std::enable_if_t<std::is_invocable_v<ItemBuilder, Arg>>>
 Builder (BaseArgs... args, InputIterator begin, InputIterator end)
 Iterator range constructor, with default transformer. More...
 
template<typename InputIterator , typename Transformer , typename Arg = decltype(*std::declval<InputIterator>()), typename ItemBuilder = decltype(Traits<Base, Derived>::ItemBuilder), typename sfinae = std::enable_if_t<std::is_invocable_v< ItemBuilder, std::invoke_result_t<Transformer, Arg>>>>
 Builder (BaseArgs... args, InputIterator begin, InputIterator end, Transformer transformer)
 Iterator range constructor, with explicit transformer. More...
 
- Public Member Functions inherited from Composite::Base< Component, ComponentPointer, ComponentArgs >
 Base (ComponentArgs... args)
 
 Base (const Base &)=delete
 
Baseoperator= (const Base &)=delete
 
auto begin () const
 
auto end () const
 
auto cbegin () const
 
auto cend () const
 
auto rbegin () const
 
auto rend () const
 
auto crbegin () const
 
auto crend () const
 
void push_back (value_type ptr)
 
bool empty () const
 

Private Member Functions

void push_back (value_type ptr)
 

Additional Inherited Members

- Protected Attributes inherited from Composite::Base< Component, ComponentPointer, ComponentArgs >
Items items
 

Detailed Description

template<typename Base, typename Derived, typename... BaseArgs>
struct Composite::Builder< Base, Derived, BaseArgs >

Specialization of Traits can wrap the push_back of the base class with a type-erasing gate-keeper, which can also do other value transformations

This class comes between Base and Derived in the inheritance graph

Definition at line 98 of file Composite.h.

Member Typedef Documentation

◆ BaseType

template<typename Base , typename Derived , typename... BaseArgs>
using Composite::Builder< Base, Derived, BaseArgs >::BaseType = Base

Definition at line 100 of file Composite.h.

Constructor & Destructor Documentation

◆ Builder() [1/3]

template<typename Base , typename Derived , typename... BaseArgs>
template<typename... Items>
Composite::Builder< Base, Derived, BaseArgs >::Builder ( BaseArgs...  args,
Items &&...  items 
)
inline

Variadic constructor.

Definition at line 132 of file Composite.h.

133 : Base{ std::forward<BaseArgs>(args)... }
134 {
135 (..., push_back(std::forward<Items>(items)));
136 }
Base(ComponentArgs... args)
Definition: Composite.h:44
auto push_back(Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >
Definition: Composite.h:104

References forward, Composite::Base< Component, ComponentPointer, ComponentArgs >::items, and Composite::Builder< Base, Derived, BaseArgs >::push_back().

Here is the call graph for this function:

◆ Builder() [2/3]

template<typename Base , typename Derived , typename... BaseArgs>
template<typename InputIterator , typename Arg = decltype(*std::declval<InputIterator>()), typename ItemBuilder = decltype(Traits<Base, Derived>::ItemBuilder), typename sfinae = std::enable_if_t<std::is_invocable_v<ItemBuilder, Arg>>>
Composite::Builder< Base, Derived, BaseArgs >::Builder ( BaseArgs...  args,
InputIterator  begin,
InputIterator  end 
)
inline

Iterator range constructor, with default transformer.

Definition at line 143 of file Composite.h.

144 : Builder{
145 std::forward<BaseArgs>(args)..., begin, end,
146 [](Arg &&arg) -> decltype(auto) { return std::forward<Arg>(arg); }
147 }
148 {}
auto begin() const
Definition: Composite.h:53
auto end() const
Definition: Composite.h:54
Builder(BaseArgs... args, Items &&... items)
Variadic constructor.
Definition: Composite.h:132

References forward.

◆ Builder() [3/3]

template<typename Base , typename Derived , typename... BaseArgs>
template<typename InputIterator , typename Transformer , typename Arg = decltype(*std::declval<InputIterator>()), typename ItemBuilder = decltype(Traits<Base, Derived>::ItemBuilder), typename sfinae = std::enable_if_t<std::is_invocable_v< ItemBuilder, std::invoke_result_t<Transformer, Arg>>>>
Composite::Builder< Base, Derived, BaseArgs >::Builder ( BaseArgs...  args,
InputIterator  begin,
InputIterator  end,
Transformer  transformer 
)
inline

Iterator range constructor, with explicit transformer.

Definition at line 156 of file Composite.h.

158 : Base{ std::forward<BaseArgs>(args)... } {
159 std::for_each(begin, end,
160 [this, &transformer](Arg &&arg){ push_back(transformer(arg)); });
161 }

References PackedArray::begin(), PackedArray::end(), and forward.

Here is the call graph for this function:

Member Function Documentation

◆ push_back() [1/3]

template<typename Base , typename Derived , typename... BaseArgs>
template<typename Arg >
auto Composite::Builder< Base, Derived, BaseArgs >::push_back ( Arg &&  arg) -> std::enable_if_t<Traits<Base, Derived> ::template enables_item_type_v<Arg>, void >
inline

Define a push_back, which makes this work also with back_inserter Traits can determine whether to enable the overloads

Definition at line 104 of file Composite.h.

109 {
110 static constexpr auto ItemBuilder = Traits<Base, Derived>::ItemBuilder;
111 Base::push_back(ItemBuilder(std::forward<Arg>(arg)));
112 }
void push_back(value_type ptr)
Definition: Composite.h:62
static constexpr auto ItemBuilder
Definition: Composite.h:79

References Composite::Base< Component, ComponentPointer, ComponentArgs >::push_back().

Referenced by anonymous_namespace{MenuHelper.cpp}::AddEffectMenuItemGroup(), anonymous_namespace{MenuHelper.cpp}::AddGroupedEffectMenuItems(), Composite::Builder< Base, Derived, BaseArgs >::Builder(), anonymous_namespace{MenuHelper.cpp}::MakeAddGroupItems(), and anonymous_namespace{BatchProcessDialog.cpp}::PopulateMacrosMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_back() [2/3]

template<typename Base , typename Derived , typename... BaseArgs>
void Composite::Builder< Base, Derived, BaseArgs >::push_back ( typename Base::value_type  arg)
inline

This non-template overload is also needed so overload resolution does not select the private inherited function

Definition at line 115 of file Composite.h.

115 {
116 constexpr auto enable = Traits<Base, Derived>
117 ::template enables_item_type_v<typename Base::value_type>;
118 // We can't sfinae this overload away when traits want to disable it, but
119 // we can make a deprecation
120 static const detail::This<!enable> deprecator;
121 if constexpr(!enable) {
122 assert(false);
123 }
124 else {
125 static constexpr auto ItemBuilder = Traits<Base, Derived>::ItemBuilder;
126 Base::push_back(ItemBuilder(move(arg)));
127 }
128 }

References Composite::Base< Component, ComponentPointer, ComponentArgs >::push_back().

Here is the call graph for this function:

◆ push_back() [3/3]

template<typename Base , typename Derived , typename... BaseArgs>
void Composite::Base< Component, ComponentPointer, ComponentArgs >::push_back ( value_type  ptr)
inlineprivate

Definition at line 62 of file Composite.h.

62{ items.push_back(move(ptr)); }

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