YPC  0.2.0
configuration.h
1 
2 #pragma once
3 #include "ypc/core/singleton.h"
4 #include <ff/util/ntobject.h>
5 #include <string>
6 
7 define_nt(db_url, std::string);
8 define_nt(db_usr, std::string);
9 define_nt(db_pass, std::string);
10 define_nt(db_dbname, std::string);
11 define_nt(ctrl_net_port, uint16_t);
12 
13 namespace ypc {
14 
15 using db_info_t = ::ff::util::ntobject<db_url, db_usr, db_pass, db_dbname>;
16 using net_info_t = ::ff::util::ntobject<ctrl_net_port>;
17 
18 class configuration : public singleton<configuration> {
19 public:
20  configuration() = default;
21  configuration(const configuration &cf) = delete;
22  configuration &operator=(const configuration &cf) = delete;
23  configuration &operator=(configuration &&cf) = delete;
24  configuration(configuration &&cf) = delete;
25  ~configuration() = default;
26 
27 public:
28  static std::string create_logdir_if_not_exist();
29  static std::string find_db_config_file(const std::string &filename);
30 
31  static db_info_t read_db_config_file(const std::string &filename);
32  static net_info_t read_net_info_from_file(const std::string &conf_file);
33 };
34 
35 } // namespace ypc
ypc::configuration
Definition: configuration.h:18
ypc::singleton
Definition: singleton.h:8