settings_manager.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2023 Jose F Rivas C <email>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef NAF_TOOLS_SETTINGSMANAGER
20 #define NAF_TOOLS_SETTINGSMANAGER
21 
22 
23 #include <iostream>
24 #include <memory>
25 #include <string>
26 #include <mutex>
27 
28 #include "yaml-cpp/node/detail/iterator_fwd.h"
29 #include "yaml-cpp/node/node.h"
30 #include "yaml-cpp/yaml.h"
31 #include "Poco/Exception.h"
32 
33 #include "tools/output_logger.h"
34 
35 namespace NAF
36 {
37  namespace Tools
38  {
39  class SettingsManager;
40  }
41 }
42 
43 using namespace Poco;
44 
45 
47 {
48  public:
50  {
51  int port, max_queued, max_threads, session_max_age;
52  float max_file_size;
53  std::string db_host, db_port, db_name, db_user, db_password;
54  std::string directory_base, directory_for_uploaded_files, directory_for_temp_files;
55  std::string certificate, key, rootcert;
56  std::string logger_output_file;
57  bool debug;
58  };
59 
61 
62  static BasicProperties& get_basic_properties_()
63  {
64  auto& var = basic_properties_;
65  return var;
66  }
67  static std::string get_properties_file_address() { return properties_file_address_; }
68 
69  static void set_properties_file_address(std::string properties_file_address) { properties_file_address_ = properties_file_address; }
70 
71  static void SetUpProperties_();
72  static void ReadBasicProperties_();
73 
74  protected:
75  static bool VerifyYAMLScalarNode_(YAML::Node& node);
76  static bool VerifyYAMLMapNode_(YAML::Node& node);
77  static void PrintError_(std::string function, std::string variable);
78 
79  private:
80  static std::mutex mutex_;
81  static BasicProperties basic_properties_;
82  static std::string properties_file_address_;
83 };
84 
85 #endif // NAF_TOOLS_SETTINGSMANAGER
Definition: settings_manager.h:47
Definition: settings_manager.h:50