Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Services / HallService.cpp
blob: 20c7a0f20f00f79ec685a5f86640bbf066a23159 (plain) (blame)
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
#include "HallService.h"
#include <fstream>

HallService::HallService(const Hall* halls, unsigned hallCount) {
	this->halls = OrderedList<Hall>(halls, hallCount);
}

const OrderedList<Hall>& HallService::get_halls() const {
	return halls;
}

/*!
 * Looks for file named "hallsDatabse.fmits", which is just a binary file, and then reads it with the "read" function in events List.
 *
 * \return E_FileCouldNotBeOpened \b if The files couldn't be opened/Doesn't exist
 * \return Success \b otherwise
 */
StatusCode HallService::load() {
	std::ifstream inFile("hallsDatabase.fmits");
	if (!inFile.is_open())
		return E_FileCouldNotBeOpened;

	halls.read(inFile);
	inFile.close();
	return Success;
}

/*!
 * Looks for file named "hallsDatabse.fmits", which is just a binary file, and then writes to it with the "write" function in events List.
 *
 * \return E_FileCouldNotBeOpened \b if The files couldn't be opened
 * \return Success \b otherwise
 */
StatusCode HallService::save() {
	std::ofstream outFile("hallsDatabase.fmits");
	if (!outFile.is_open())
		return E_FileCouldNotBeOpened;

	halls.write(outFile);
	outFile.close();
	return Success;
}