Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
mazes::cell Class Referencefinal

Cell class with links to other cells. More...

#include <cell.h>

Public Types

using cell_area = std::pair<std::uint8_t, std::uint8_t>
using cell_map = std::unordered_map<std::weak_ptr<cell>, bool, weak_ptr_hash, weak_ptr_equal>

Public Member Functions

 cell (std::pair< std::uint8_t, std::uint8_t > index=std::pair< std::uint8_t, std::uint8_t >{1u, 1u})
 Constructs a cell object with an optional index.
 ~cell ()
 Destroys the cell object and releases any associated resources.
 cell (const cell &other)
 Copy constructor for the cell class.
cell & operator= (const cell &other)
 Assigns the value of another cell to this cell.
 cell (cell &&other) noexcept
 Move constructor for the cell class.
cell & operator= (cell &&other) noexcept
 Move assignment operator for the cell class.
void add_link (const std::shared_ptr< cell > &other) noexcept
 Add a link to another cell (passage between cells).
void remove_link (const std::shared_ptr< cell > &other) noexcept
 Remove a link to another cell.
void clear_links () noexcept
 Remove all links so the cell can be reused.
bool is_linked (const std::shared_ptr< cell > &c) const noexcept
 Checks if a cell is linked.
cell_area get_area () const noexcept
 Retrieves the area of the current cell.
void set_area (cell_area new_area) noexcept
 Sets the area to the specified value.

Detailed Description

Cell class with links to other cells.

Constructor & Destructor Documentation

◆ cell() [1/3]

mazes::cell::cell ( std::pair< std::uint8_t, std::uint8_t > index = std::pair< std::uint8_t, std::uint8_t >{1u, 1u})
explicit

Constructs a cell object with an optional index.

Parameters
indexThe area (row, column per convention) to initialize the cell with.

◆ cell() [2/3]

mazes::cell::cell ( const cell & other)

Copy constructor for the cell class.

Parameters
otherThe cell object to copy from.

◆ cell() [3/3]

mazes::cell::cell ( cell && other)
noexcept

Move constructor for the cell class.

Parameters
otherThe cell object to move from.

Member Function Documentation

◆ add_link()

void mazes::cell::add_link ( const std::shared_ptr< cell > & other)
noexcept

Add a link to another cell (passage between cells).

Parameters
otherThe cell to link to

◆ get_area()

cell_area mazes::cell::get_area ( ) const
noexcept

Retrieves the area of the current cell.

Returns
The area of the current cell.

◆ is_linked()

bool mazes::cell::is_linked ( const std::shared_ptr< cell > & c) const
noexcept

Checks if a cell is linked.

Parameters
cA shared pointer to the cell to check.
Returns
True if the cell is linked, false otherwise.

◆ operator=() [1/2]

cell & mazes::cell::operator= ( cell && other)
noexcept

Move assignment operator for the cell class.

Parameters
otherThe cell object to move from.
Returns
A reference to the assigned cell object (*this).

◆ operator=() [2/2]

cell & mazes::cell::operator= ( const cell & other)

Assigns the value of another cell to this cell.

Parameters
otherThe cell whose value will be assigned to this cell.
Returns
A reference to this cell after assignment.

◆ remove_link()

void mazes::cell::remove_link ( const std::shared_ptr< cell > & other)
noexcept

Remove a link to another cell.

Parameters
otherThe cell to unlink from

◆ set_area()

void mazes::cell::set_area ( cell_area new_area)
noexcept

Sets the area to the specified value.

Parameters
new_areaThe new area value to set.

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