-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeakingtimebase.cpp
More file actions
55 lines (46 loc) · 1.42 KB
/
Copy pathspeakingtimebase.cpp
File metadata and controls
55 lines (46 loc) · 1.42 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
#include "speakingtimebase.h"
#include "participant.h"
#include "participantsregister.h"
#include "meeting.h"
#include "meetingsregister.h"
using namespace std;
SpeakingTimeBase::SpeakingTimeBase(QObject *parent) :
QObject(parent)
{}
SpeakingTimeBase::~SpeakingTimeBase()
{
m_participantsRegister.reset();
m_meetingsRegister.reset();
}
void SpeakingTimeBase::initRegisters()
{
static bool trigger = true;
if (trigger) {
m_participantsRegister = make_unique<ParticipantsRegister>();
m_meetingsRegister = make_unique<MeetingsRegister>();
trigger ^= true;
}
}
void SpeakingTimeBase::moveRegistersTo(SpeakingTimeBase & stb)
{
moveRegisters(*this, stb);
}
void SpeakingTimeBase::moveRegistersFrom(SpeakingTimeBase &stb)
{
moveRegisters(stb, *this);
}
ParticipantsRegister &SpeakingTimeBase::participantsRegister()
{
return getRegister<ParticipantsRegister>(m_participantsRegister);
}
MeetingsRegister &SpeakingTimeBase::meetingsRegister()
{
return getRegister<MeetingsRegister>(m_meetingsRegister);
}
void SpeakingTimeBase::moveRegisters(SpeakingTimeBase &from, SpeakingTimeBase &to)
{
if (from.m_participantsRegister == nullptr || from.m_meetingsRegister == nullptr)
throw std::runtime_error("invalid attempt to move an unowned register");
to.m_participantsRegister = move(from.m_participantsRegister);
to.m_meetingsRegister = move(from.m_meetingsRegister);
}