-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spreadsheet.h
57 lines (46 loc) · 1.32 KB
/
Spreadsheet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by Frederik Desmet on 29/04/2022.
//
#pragma once
#include <cstddef>
#include "ISpreadsheet.h"
#include "SpreadsheetCell.h"
class ISpreadsheet::Spreadsheet
{
public:
Spreadsheet(const SpreadsheetApplication& theApp, size_t width, size_t height);
Spreadsheet(const Spreadsheet& source);
~Spreadsheet();
Spreadsheet& operator=(const Spreadsheet& rhs);
/**
* Sets the value of the specified cell.
* @param x horizontal axis.
* @param y vertical axis.
* @param cell cell object, containing the value to be inserted.
*/
void setCellAt(size_t x, size_t y, const SpreadsheetCell& cell);
/**
* Gets the cell object of the specified cell.
* @param x horizontal axis.
* @param y vertical axis.
* @return SpreadsheetCell object reference.
*/
SpreadsheetCell& getCellAt(size_t x, size_t y);
/**
* Gets the Id of the spreadsheet.
* @return size_t the id of the spreadsheet.
*/
[[nodiscard]]size_t getId() const;
private:
/**
* Checks if the passed coordinates are within the bounds of the sheet.
* @param x horizontal axis.
* @param y vertical axis.
*/
void verifyCoordinates(size_t x, size_t y) const;
void swap(Spreadsheet& other) noexcept;
size_t _width, _height, _id{ 0 };
static inline size_t _counter{ 0 };
SpreadsheetCell** _cells{ nullptr };
const SpreadsheetApplication& _theApp;
};