SRS-control
0.1.4
Loading...
Searching...
No Matches
ValidData.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <concepts>
4
#include <stdexcept>
5
6
namespace
srs
7
{
8
9
template
<std::default_initializable T>
10
class
ValidData
11
{
12
public
:
13
ValidData
() =
default
;
14
15
auto
value
() ->
auto
&
16
{
17
if
(not
is_valid_
)
18
{
19
throw
std::runtime_error(
"Cannot call value(): ValidData value is not valid!"
);
20
}
21
return
resource_
;
22
}
23
24
auto
get
() const -> const auto&
25
{
26
if
(not
is_valid_
)
27
{
28
throw
std::runtime_error(
"Cannot call get(): ValidData value is not valid!"
);
29
}
30
return
resource_
;
31
}
32
33
auto
is_valid
() ->
bool
{
return
is_valid_
; }
34
35
void
invalidate
() {
is_valid_
=
false
; }
36
void
validate
() {
is_valid_
=
true
; }
37
38
auto
operator->
() -> T* {
return
&
resource_
; }
39
40
private
:
41
bool
is_valid_
=
false
;
42
T
resource_
;
43
};
44
45
}
// namespace srs
srs::ValidData::validate
void validate()
Definition
ValidData.hpp:36
srs::ValidData::operator->
auto operator->() -> T *
Definition
ValidData.hpp:38
srs::ValidData::is_valid
auto is_valid() -> bool
Definition
ValidData.hpp:33
srs::ValidData::invalidate
void invalidate()
Definition
ValidData.hpp:35
srs::ValidData::is_valid_
bool is_valid_
Definition
ValidData.hpp:41
srs::ValidData::ValidData
ValidData()=default
srs::ValidData::resource_
T resource_
Definition
ValidData.hpp:42
srs::ValidData::get
auto get() const -> const auto &
Definition
ValidData.hpp:24
srs::ValidData::value
auto value() -> auto &
Definition
ValidData.hpp:15
srs
Definition
Application.cpp:11
backend
srs
utils
ValidData.hpp
Impressum
Datenschutzerklärung
Generated by
1.13.2