-
Notifications
You must be signed in to change notification settings - Fork 0
/
httphandlers.cpp
51 lines (37 loc) · 1.01 KB
/
httphandlers.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
40
41
42
43
44
45
46
47
48
49
50
51
//Copyright Anoop Kumar Narayanan <anoop.kumar.narayanan@gmail.com> , LICENSE - GPLv2 / GPLv3
#include <httphandlers.h>
HttpHandler *HttpHandler::hdlrObj;
HttpHandler::HttpHandler() {
httpHdlrs = new MapHttpHdlr();
}
HttpHandler::~HttpHandler() {
if ( httpHdlrs )
{ httpHdlrs->clear(); }
}
HttpHandler* HttpHandler::createInstance() {
if ( !hdlrObj ) {
hdlrObj = new HttpHandler();
}
return hdlrObj;
}
void* HttpHandler::getHandler ( string name ) {
void *data = NULL;
MapHttpHdlr::iterator i = httpHdlrs->find ( name );
if ( i != httpHdlrs->end() ) {
data = i->second;
}
return data;
}
void HttpHandler::addHandler ( string name, void *data ) {
if ( !data )
{ return; }
httpHdlrs->insert ( pair<string, void*> ( name, data ) );
}
void HttpHandler::delHandler ( string name ) {
MapHttpHdlr::iterator i = httpHdlrs->find ( name );
if ( i != httpHdlrs->end() ) {
if ( i->second != NULL )
{ }
}
httpHdlrs->erase ( i );
}