Audacity 3.2.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ToolBarConfiguration::Iterator Class Reference

#include <ToolDock.h>

Inheritance diagram for ToolBarConfiguration::Iterator:
[legend]
Collaboration diagram for ToolBarConfiguration::Iterator:
[legend]

Classes

struct  Triple
 

Public Member Functions

const Placeoperator* () const
 
const Placeoperator-> () const
 
Iteratoroperator++ ()
 
std::vector< int > GetPath () const
 

Private Types

using FIter = Forest::iterator
 

Private Member Functions

 Iterator ()
 
 Iterator (ToolBarConfiguration &conf)
 

Private Attributes

friend ToolBarConfiguration
 
Place mPlace
 
std::vector< TriplemIters
 

Friends

bool operator== (const Iterator &lhs, const Iterator &rhs)
 
bool operator!= (const Iterator &lhs, const Iterator &rhs)
 

Additional Inherited Members

- Public Types inherited from ValueIterator< Place >
using iterator_category = std::forward_iterator_tag
 
using value_type = Place
 
using difference_type = ptrdiff_t
 
using pointer = void
 
using reference = const Place
 

Detailed Description

Definition at line 116 of file ToolDock.h.

Member Typedef Documentation

◆ FIter

using ToolBarConfiguration::Iterator::FIter = Forest::iterator
private

Definition at line 208 of file ToolDock.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

ToolBarConfiguration::Iterator::Iterator ( )
inlineprivate

Definition at line 195 of file ToolDock.h.

195{}

◆ Iterator() [2/2]

ToolBarConfiguration::Iterator::Iterator ( ToolBarConfiguration conf)
inlineexplicitprivate

Definition at line 196 of file ToolDock.h.

197 {
198 auto &forest = conf.mForest;
199 if (!forest.empty()) {
200 auto b = forest.begin();
201 mIters.push_back( Triple { b, b, forest.end() } );
202 mPlace.pTree = &*b;
203 }
204 }
std::vector< Triple > mIters
Definition: ToolDock.h:226

References ToolBarConfiguration::Iterator::Triple::end, ToolBarConfiguration::mForest, mIters, mPlace, and ToolBarConfiguration::Place::pTree.

Member Function Documentation

◆ GetPath()

std::vector< int > ToolBarConfiguration::Iterator::GetPath ( ) const
inline

Definition at line 169 of file ToolDock.h.

170 {
171 std::vector<int> path;
172 path.reserve(mIters.size());
173 for (const auto &triple : mIters)
174 path.push_back(triple.current - triple.begin);
175 return path;
176 }

References mIters.

Referenced by ToolBarConfiguration::Write().

Here is the caller graph for this function:

◆ operator*()

const Place & ToolBarConfiguration::Iterator::operator* ( ) const
inline

Definition at line 120 of file ToolDock.h.

120{ return mPlace; }

References mPlace.

◆ operator++()

Iterator & ToolBarConfiguration::Iterator::operator++ ( )
inline

Definition at line 122 of file ToolDock.h.

123 {
124 // This is a feature: advance position even at the end
126 Position{ mPlace.pTree ? mPlace.pTree->pBar : nullptr };
127
128 if (!mIters.empty())
129 {
130 auto triple = &mIters.back();
131 auto &children = triple->current->children;
132 if (children.empty()) {
133 while (++triple->current == triple->end) {
134 mIters.pop_back();
135 if (mIters.empty())
136 break;
137 triple = &mIters.back();
138 }
139 }
140 else {
141 auto b = children.begin();
142 mIters.push_back( Triple { b, b, children.end() } );
143 }
144 }
145
146 if (mIters.empty()) {
147 mPlace.pTree = nullptr;
148 // Leave mPlace.position as above
149 }
150 else {
151 const auto &triple = mIters.back();
152 mPlace.pTree = &*triple.current;
153
154 if (mIters.size() == 1)
155 mPlace.position.rightOf = nullptr;
156 else
157 mPlace.position.rightOf = (mIters.rbegin() + 1)->current->pBar;
158
159 if (triple.begin == triple.current)
160 mPlace.position.below = nullptr;
161 else
162 mPlace.position.below = (triple.current - 1)->pBar;
163 }
164
165 return *this;
166 }

References ToolBarConfiguration::Position::below, ToolBarConfiguration::Iterator::Triple::end, mIters, mPlace, ToolBarConfiguration::Tree::pBar, ToolBarConfiguration::Place::position, ToolBarConfiguration::Place::pTree, and ToolBarConfiguration::Position::rightOf.

◆ operator->()

const Place * ToolBarConfiguration::Iterator::operator-> ( ) const
inline

Definition at line 121 of file ToolDock.h.

121{ return &**this; }

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Iterator lhs,
const Iterator rhs 
)
friend

Definition at line 187 of file ToolDock.h.

189 {
190 return !(lhs == rhs);
191 }

◆ operator==

bool operator== ( const Iterator lhs,
const Iterator rhs 
)
friend

Definition at line 178 of file ToolDock.h.

180 {
181 const auto &li = lhs.mIters;
182 const auto &ri = rhs.mIters;
183 return li.size() == ri.size() &&
184 std::equal(li.begin(), li.end(), ri.begin());
185 }

Member Data Documentation

◆ mIters

std::vector<Triple> ToolBarConfiguration::Iterator::mIters
private

Definition at line 226 of file ToolDock.h.

Referenced by GetPath(), Iterator(), and operator++().

◆ mPlace

Place ToolBarConfiguration::Iterator::mPlace
private

Definition at line 206 of file ToolDock.h.

Referenced by Iterator(), operator*(), and operator++().

◆ ToolBarConfiguration

friend ToolBarConfiguration::Iterator::ToolBarConfiguration
private

Definition at line 194 of file ToolDock.h.


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