-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.ixx
More file actions
64 lines (62 loc) · 1.82 KB
/
database.ixx
File metadata and controls
64 lines (62 loc) · 1.82 KB
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
58
59
60
61
62
63
64
export module database;
import std;
import employee;
namespace Records {
const int FirstEmployeeNumber{ 1'000 };
/**
* The Database stores a collection of employees. It supports
* adding and retrieving employees, and displaying employees
* satisfying certain constraints.
*/
export class Database
{
public:
/**
* Adds an employee with given name to the database.
*
* @param firstName The first name of the employee to add.
* @param lastName The last name of the employee to add.
* @throws vector<Employee> m_employees might throw.
* @return The reference to m_employees.back(), i.e. the last of employees.
*/
Employee& addEmployee(const std::string& firstName,
const std::string& lastName);
/**
* Finds an employee based on an employee number.
*
* @param employeeNumber, int
* @throws logic_error if employeeNumber is not in vector.
* @return Employee& of the employee found.
*/
Employee& getEmployee(int employeeNumber);
/**
* Finds an employee based on a name.
*
* @param firstName The first name of the employee to add.
* @param lastName The last name of the employee to add.
* @throws logic_error if no corresponding firstName and lastName found.
* @return Employee& of the employee found.
*/
Employee& getEmployee(const std::string& firstName,
const std::string& lastName);
/**
* Display all employees employed or former.
* @throws std::format might throw.
*/
void displayAll() const;
/**
* Display current employees.
* @throws std::format might throw.
*/
void displayCurrent() const;
/**
* Display former employees.
* @throws std::format might throw.
*/
void displayFormer() const;
private:
std::vector<Employee> m_employees;
int m_nextEmployeeNumber{ FirstEmployeeNumber };
};
}
export void MyFunc();