forked from edman007/chiton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chiton_config.hpp
59 lines (50 loc) · 2.16 KB
/
chiton_config.hpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef __CHITON_CONFIG_HPP__
#define __CHITON_CONFIG_HPP__
/**************************************************************************
*
* This file is part of Chiton.
*
* Chiton is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Chiton is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Chiton. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright 2020 Ed Martin <[email protected]>
*
**************************************************************************
*/
//we like new stuff
#define _XOPEN_SOURCE 700
#include <string>
#include <map>
/* Autoconf parameters */
#include "config_build.hpp"
#include "database.hpp"
//we have to have valid values for these, these are the defaults when the user sets a bad value
const long DEFAULT_SECONDS_PER_SEGMENT = 6;//Apple recommends 6 seconds per file to make live streaming reasonable
const long DEFAULT_MIN_FREE_SPACE = 1073741824;//1G in bytes
const std::string EXPORT_EXT = ".mp4";
class Config {
public:
Config();
bool load_config(const std::string& path);//load the config from the path
bool load_camera_config(int camera, Database &db);//load the config from the database for a specific camera
const std::string& get_value(const std::string& key);
int get_value_int(const std::string& key);//returns the value as an int
long get_value_long(const std::string& key);//returns the value as a long
double get_value_double(const std::string& key);//returns the value as an double
void set_value(const std::string& key, const std::string& value);
private:
std::map<std::string,std::string> cfg_db;
const std::string EMPTY_STR = "";
const std::string & get_default_value(const std::string& key);
};
#endif