-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuno.cpp
More file actions
65 lines (54 loc) · 1.15 KB
/
Copy pathuno.cpp
File metadata and controls
65 lines (54 loc) · 1.15 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
65
#include <QDebug>
#include <QMutex>
#include <QMutexLocker>
#include "uno.h"
#include "uconfig.h"
#include "urequest.h"
#include "uresponse.h"
#include "udispatcher.h"
Uno::Uno() :
m_dispatcher(0),
m_request(0),
m_response(0)
{
m_request = &uRequest::getInstance();
connect(this, SIGNAL(startup()), m_request, SLOT(parseRequest()));
}
Uno::~Uno()
{
if (m_dispatcher)
{
delete m_dispatcher;
}
}
void Uno::setConfig(const QString &path)
{
(&uConfig::getInstance())->createConfig(path);
}
void Uno::setDispatcher(const uDispatcher *dispatcher)
{
m_dispatcher = const_cast<uDispatcher*>(dispatcher);
}
void Uno::run()
{
if (m_dispatcher == 0)
{
qDebug() << QObject::tr("Uno cannot run without a valid dispatcher.");
return;
}
emit startup();
do {
m_dispatcher->dispatch();
} while (! m_request->dispatched());
m_response = &uResponse::getInstance();
m_response->sendHeaders();
m_response->sendResponse();
emit shutdown();
}
Uno &Uno::getInstance()
{
static QMutex mutex;
QMutexLocker lock(&mutex);
static Uno instance;
return instance;
}