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)
 
auto size () const noexcept
 
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 99 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 101 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 133 of file Composite.h.

134 : Base{ std::forward<BaseArgs>(args)... }
135 {
136 (..., push_back(std::forward<Items>(items)));
137 }
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:105

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 144 of file Composite.h.

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

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 157 of file Composite.h.

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

References details::begin(), details::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 105 of file Composite.h.

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

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(), MenuHelper::PopulateEffectsMenu(), 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 116 of file Composite.h.

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

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: