cgv
Loading...
Searching...
No Matches
web_server.h
1#pragma once
2
3#include "http_request.h"
4#include "thread.h"
5
6#include "lib_begin.h"
7
8namespace cgv {
9 namespace os {
10
12class CGV_API web_server
13{
14protected:
15 unsigned int port;
16 void* user_data;
17 friend class web_server_provider;
18public:
20 web_server(unsigned int _port = 80);
22 virtual void handle_request(http_request& request) = 0;
24 void start();
26 void stop();
28 unsigned int get_port() const;
29};
30
32class CGV_API web_server_thread : public thread, public web_server
33{
34public:
36 web_server_thread(unsigned int _port = 8080);
40 void start();
42 void run();
43};
44
47{
48protected:
49 void*& ref_user_data(web_server* instance) const;
50public:
51 virtual void start_web_server(web_server* instance) = 0;
52 virtual void stop_web_server(web_server* instance) = 0;
53};
54
56extern CGV_API void register_web_server_provider(web_server_provider* wsp);
57
59template <class T>
61{
63 register_web_server_provider(new T());
64 }
65};
66
67 }
68}
69
70#include <cgv/config/lib_end.h>
Thread class implementation that uses pthreads internally.
Definition thread.h:39
interface for a html_server provider
Definition web_server.h:47
web server interface that runs in its own thread
Definition web_server.h:33
simple interface for a web server
Definition web_server.h:13
virtual void handle_request(http_request &request)=0
reimplement to handle requests
the cgv namespace
Definition print.h:11
structure that contains all input and output parameters of a http request
template to facilitate registeration of a web server provider
Definition web_server.h:61