-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
42 lines (31 loc) · 831 Bytes
/
server.h
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
#ifndef SSERVER_SERVER_H_INCLUDED
#define SSERVER_SERVER_H_INCLUDED
#include <boost/scoped_ptr.hpp>
#include <boost/program_options.hpp>
#include <string>
class TCPSocket;
class UDPSocket;
class Config {
public:
explicit Config(const std::string& path);
void reconfigure();
template<typename T>
const T& option(const std::string& name) const {
return config_vm_[name].as<T>();
}
private:
std::string path_;
boost::program_options::variables_map config_vm_;
};
class Server {
public:
explicit Server(const std::string& path);
~Server();
void process();
bool is_daemon() const { return config_.option<bool>("daemon"); }
private:
Config config_;
boost::scoped_ptr<TCPSocket> tcp_;
boost::scoped_ptr<UDPSocket> udp_;
};
#endif // SSERVER_SERVER_H_INCLUDED