0
|
1 /**
|
|
2 * Palantir - A Lightweight, RESTful DICOM Store
|
|
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
|
|
4 * Belgium
|
|
5 *
|
|
6 * This program is free software: you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU General Public License as
|
|
8 * published by the Free Software Foundation, either version 3 of the
|
|
9 * License, or (at your option) any later version.
|
|
10 *
|
|
11 * This program is distributed in the hope that it will be useful, but
|
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 * General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18 **/
|
|
19
|
|
20
|
|
21 #pragma once
|
|
22
|
|
23 #include "HttpHandler.h"
|
|
24
|
|
25 #include <list>
|
|
26 #include <stdint.h>
|
|
27 #include <boost/shared_ptr.hpp>
|
|
28
|
|
29 namespace Palantir
|
|
30 {
|
|
31 class ChunkStore;
|
|
32
|
|
33 class MongooseServer
|
|
34 {
|
|
35 private:
|
|
36 // http://stackoverflow.com/questions/311166/stdauto-ptr-or-boostshared-ptr-for-pimpl-idiom
|
|
37 struct PImpl;
|
|
38 boost::shared_ptr<PImpl> pimpl_;
|
|
39
|
|
40 typedef std::list<HttpHandler*> Handlers;
|
|
41 Handlers handlers_;
|
|
42
|
|
43 uint16_t port_;
|
|
44
|
|
45 bool IsRunning() const;
|
|
46
|
|
47 public:
|
|
48 MongooseServer();
|
|
49
|
|
50 ~MongooseServer();
|
|
51
|
|
52 void SetPort(uint16_t port);
|
|
53
|
|
54 uint16_t GetPort() const
|
|
55 {
|
|
56 return port_;
|
|
57 }
|
|
58
|
|
59 void Start();
|
|
60
|
|
61 void Stop();
|
|
62
|
|
63 void RegisterHandler(HttpHandler* handler); // This takes the ownership
|
|
64
|
|
65 void ClearHandlers();
|
|
66
|
|
67 // Can return NULL if no handler is associated to this URI
|
|
68 HttpHandler* FindHandler(const UriComponents& forUri) const;
|
|
69
|
|
70 ChunkStore& GetChunkStore();
|
|
71 };
|
|
72 }
|