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 ATOM_TOOLS_SETTINGSMANAGER
20 #define ATOM_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 Atom
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  };
58 
60 
61  static BasicProperties& get_basic_properties_()
62  {
63  auto& var = basic_properties_;
64  return var;
65  }
66  static std::string get_properties_file_address() { return properties_file_address_; }
67 
68  static void set_properties_file_address(std::string properties_file_address) { properties_file_address_ = properties_file_address; }
69 
70  static void SetUpProperties_();
71  static void ReadBasicProperties_();
72 
73  protected:
74  static bool VerifyYAMLScalarNode_(YAML::Node& node);
75  static bool VerifyYAMLMapNode_(YAML::Node& node);
76  static void PrintError_(std::string function, std::string variable);
77 
78  private:
79  static std::mutex mutex_;
80  static BasicProperties basic_properties_;
81  static std::string properties_file_address_;
82 };
83 
84 #endif // ATOM_TOOLS_SETTINGSMANAGER
Definition: settings_manager.h:47
Definition: settings_manager.h:50