Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
common
rs-config.h
Go to the documentation of this file.
1
// License: Apache 2.0. See LICENSE file in root directory.
2
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3
4
#pragma once
5
6
#include <map>
7
#include <string>
8
#include <sstream>
9
#include <functional>
10
11
namespace
rs2
12
{
13
class
config_value
14
{
15
public
:
16
template
<
class
T>
17
operator
T
()
18
{
19
std::stringstream ss;
20
ss.str(
_val
);
21
T
res
;
22
ss >>
res
;
23
return
res
;
24
}
25
26
// When converting config_value to string, we can't use >> operator since it reads until first whitespace rather than the whole string;
27
// Therefore we use a different overload for strings
28
operator
std::string
()
29
{
30
return
_val
;
31
}
32
33
config_value
(
std::string
val
) :
_val
(
std
::
move
(val)) {}
34
35
private
:
36
std::string
_val
;
37
};
38
39
class
config_file
40
{
41
public
:
42
config_file
();
43
config_file
(
std::string
filename
);
44
45
void
set_default(
const
char
*
key
,
const
char
* calculate);
46
47
template
<
class
T>
48
void
set_default
(
const
char
* key,
T
val
)
49
{
50
std::stringstream ss;
51
ss <<
val
;
52
set_default(key, ss.str().c_str());
53
}
54
55
bool
operator==
(
const
config_file
& other)
const
;
56
57
config_file
& operator=(
const
config_file
& other);
58
59
void
set
(
const
char
*
key
,
const
char
*
value
);
60
std::string
get
(
const
char
*
key
,
const
char
* def)
const
;
61
62
config_value
get
(
const
char
*
key
)
const
;
63
64
template
<
class
T>
65
T
get_or_default
(
const
char
* key,
T
def)
const
66
{
67
if
(
contains
(key))
return
get
(
key
);
68
return
def;
69
}
70
71
template
<
class
T>
72
void
set
(
const
char
*
key
,
T
val
)
73
{
74
std::stringstream ss;
75
ss <<
val
;
76
set
(
key
, ss.str().c_str());
77
}
78
79
bool
contains
(
const
char
* key)
const
;
80
81
void
save(
const
char
* filename);
82
83
void
reset
();
84
85
static
config_file
& instance();
86
87
private
:
88
std::string
get_default
(
const
char
* key,
const
char
* def)
const
;
89
90
void
save();
91
92
std::map<std::string, std::string>
_values
;
93
std::map<std::string, std::string>
_defaults
;
94
std::string
_filename
;
95
};
96
}
rs2::config_value
Definition:
rs-config.h:13
rs2::operator==
bool operator==(const plane &lhs, const plane &rhs)
Definition:
rendering.h:134
reset
GLboolean reset
Definition:
glad/glad/glad.h:3594
value
GLfloat value
Definition:
glad/glad/glad.h:2100
std
Definition:
android_helpers.h:13
rs2::config_file::set_default
void set_default(const char *key, T val)
Definition:
rs-config.h:48
rs2
Definition:
cah-model.h:10
string
GLsizei const GLchar *const * string
Definition:
glad/glad/glad.h:2862
val
GLuint GLfloat * val
Definition:
glad/glad/glad.h:3412
key
GLuint64 key
Definition:
glext.h:8966
rs2::config_file::get_or_default
T get_or_default(const char *key, T def) const
Definition:
rs-config.h:65
contains
bool contains(const std::shared_ptr< librealsense::device_info > &first, const std::shared_ptr< librealsense::device_info > &second)
Definition:
context.cpp:49
t265_stereo.T
T
Definition:
t265_stereo.py:157
rs2::config_file
Definition:
rs-config.h:39
rs2::config_file::_defaults
std::map< std::string, std::string > _defaults
Definition:
rs-config.h:93
boost::move
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
Definition:
utility_core.hpp:191
rs2::config_file::_values
std::map< std::string, std::string > _values
Definition:
rs-config.h:92
rs2::config_value::_val
std::string _val
Definition:
rs-config.h:36
test-non-realtime.filename
string filename
Definition:
test-non-realtime.py:17
rs2::config_file::_filename
std::string _filename
Definition:
rs-config.h:94
res
GLuint res
Definition:
glext.h:8856
rs2::config_value::config_value
config_value(std::string val)
Definition:
rs-config.h:33
librealsense::get_default
Definition:
l500-options.h:29
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:47:40