30#ifndef WXMAXIMA_CELLLIST_H
31#define WXMAXIMA_CELLLIST_H
40 std::unique_ptr<Cell> m_head;
42 Cell *m_lastAppended = {};
60 static Cell *DynamicCast(
Cell *cell) {
return dynamic_cast<T *
>(cell); }
66 explicit operator bool()
const {
return static_cast<bool>(m_head); }
69 operator std::unique_ptr<T>() && {
return TakeHead(); }
80 T *ptr =
dynamic_cast<T *
>(m_head.get());
82 (void) m_head.release();
88 wxASSERT(!m_head && !m_tail && !m_lastAppended);
97 auto retval = dynamic_unique_ptr_cast<T>(std::move(m_head));
99 wxASSERT(!m_tail && !m_lastAppended);
104 T *
GetTail()
const {
return dynamic_cast<T*
>(m_tail); }
129 return static_cast<T *
>(
144 auto *
const retval = cells.get();
164 static std::unique_ptr<Cell>
SetNext(
Cell *cell, std::unique_ptr<Cell> &&next);
179 template <
typename T>
180 static void AppendCell(
const std::unique_ptr<T> &cell, std::unique_ptr<Cell> &&tail)
Implementation of an observing weak Cell pointer.
Definition: CellList.h:38
void ClearLastAppended()
Clears the pointer to the last appended cell. Useful when tree building.
Definition: CellList.h:54
Cell * base_DynamicAppend(std::unique_ptr< Cell > &&cells, Cell *(*caster)(Cell *))
Appends one or more cells if they are of the correct type, otherwise deletes them.
Definition: CellList.cpp:40
void base_Append(std::unique_ptr< Cell > &&cells)
Appends one or more cells.
Definition: CellList.cpp:26
Manages building a list of cells, keeping the head and tail of the list.
Definition: CellList.h:59
T * DynamicAppend(std::unique_ptr< Cell > &&cells)
Appends one or more cells if they are all of the correct type, otherwise deletes them.
Definition: CellList.h:136
T * GetLastAppended() const
Provides the most cell passed to the most recent Append call.
Definition: CellList.h:107
T * DynamicAppend(Cell *cells)
Appends one or more cells if they are all of the correct type, otherwise deletes them.
Definition: CellList.h:127
T * Append(T *cells)
Appends one or more cells.
Definition: CellList.h:111
T * Append(std::unique_ptr< T > &&cells)
Appends one or more cells.
Definition: CellList.h:142
T * GetTail() const
Provides the last cell in the list (if any).
Definition: CellList.h:104
T * ReleaseHead()
Releases the ownership of the list head of the list to the caller.
Definition: CellList.h:78
std::unique_ptr< T > TakeHead()
Passes on the ownership of the list head.
Definition: CellList.h:93
Definition: CellList.h:151
static void DeleteList(Cell *afterMe)
Deletes the list of cells anchored at the given cell.
Definition: CellList.cpp:84
static void AppendCell(Cell *cell, std::unique_ptr< Cell > &&tail)
Appends a cell to the end of the cell list that starts with a given cell.
Definition: CellList.cpp:92
static SplicedIn SpliceInAfter(Cell *where, std::unique_ptr< Cell > &&head, Cell *last=nullptr)
Splices a given list of cells after the given cell.
Definition: CellList.cpp:121
static TornOut TearOut(Cell *first, Cell *last)
Tears out a cell range and returns the list thus formed.
Definition: CellList.cpp:154
static std::unique_ptr< Cell > SetNext(Cell *cell, std::unique_ptr< Cell > &&next)
Replaces the successor of a given cell, and returns the old one (if any).
Definition: CellList.cpp:61
static void Check(const Cell *cell)
Checks the integrity of the list pointers of the given cell in relation to its neighbors.
Definition: CellList.cpp:52
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:480
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
Definition: CellList.h:184
Cell * lastSpliced
The last cell in the in the list of spliced-in cells - copied from the last parameter,...
Definition: CellList.h:187
Definition: CellList.h:200
CellPtr< Cell > cell
The first in the torn-out list of cells, or null if the tearing out had failed.
Definition: CellList.h:202
std::unique_ptr< Cell > tailOwner
The owner of the tail beyond the last cell, or null if the cell did have a predecessor in the list.
Definition: CellList.h:208
std::unique_ptr< Cell > cellOwner
The owner of the torn-out cell list, or null if the cell had no predecessor in the list.
Definition: CellList.h:205