-
Notifications
You must be signed in to change notification settings - Fork 0
/
memhandler.cpp
39 lines (33 loc) · 898 Bytes
/
memhandler.cpp
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
#include <avatarspirit.h>
#include <gamcs/CSOSAgent.h>
#include <gamcs/Sqlite.h>
#include <QDebug>
#include "memhandler.h"
using namespace gamcs;
MemHandler::MemHandler(AvatarSpirit *avspt, gamcs::CSOSAgent *agent, const QString &storage, int op) :
_avspt(avspt), _agent(agent), _storage(storage), _operation(op)
{
}
MemHandler::~MemHandler()
{
}
void MemHandler::run()
{
// put avatar to sleep while loading/saving
bool status = _avspt->isAwake();
_avspt->setAwake(false);
Sqlite db(_storage.toStdString());
if (_operation == 0) // loading
{
qDebug() << "+++ loading memory...";
_agent->loadMemoryFromStorage(&db);
}
else if (_operation == 1) // saving
{
qDebug() << "+++ saving memory...";
_agent->dumpMemoryToStorage(&db);
}
// restore
_avspt->setAwake(status);
qDebug() << "--- memory done!";
}