-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedule.h
57 lines (52 loc) · 1.65 KB
/
schedule.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
#ifndef SCEHDULE_H
#define SCEHDULE_H
#include <stdbool.h>
#include <string>
#include <list>
#include <iostream>
#include "base_event.h"
#include "date_wrap.h"
#include "event_container.h"
namespace mtm
{
class Schedule
{
private:
std::list<BaseEvent*> event_list;
void addEvent(const BaseEvent& event);
BaseEvent* findEventByDateAndName(const mtm::DateWrap& date, const std::string& name) const;
void freeEventPointers();
public:
Schedule();
Schedule(const Schedule& schedule);
~Schedule();
Schedule& operator=(const Schedule& schedule);
void addEvents(const EventContainer& event_container);
void registerToEvent(const mtm::DateWrap& date, const std::string& name, int student);
void unregisterFromEvent(const mtm::DateWrap& date, const std::string& name, int student);
void printAllEvents() const;
void printMonthEvents(int month, int year) const;
template <class Predicate>
void printSomeEvents(Predicate predicate, bool verbose = false) const;
void printEventDetails(const mtm::DateWrap& date, const std::string& name) const;
};
template <class Predicate>
void Schedule::printSomeEvents(Predicate predicate, bool verbose) const
{
for (BaseEvent* event: this->event_list)
{
if(predicate(*event))
{
if(verbose)
{
event->printLong(std::cout) << std::endl;
}
else
{
event->printShort(std::cout) << std::endl;
}
}
}
}
}
#endif