CoolProp
6.6.1dev
An open-source fluid property and humid air property database
include
CachedElement.h
Go to the documentation of this file.
1
/*
2
* CachedElement.h
3
*
4
* Created on: 21 Dec 2013
5
* Author: jowr
6
*/
7
8
#ifndef CACHEDELEMENT_H_
9
#define CACHEDELEMENT_H_
10
11
#include "
CoolPropTools.h
"
12
#include "
DataStructures.h
"
13
14
namespace
CoolProp
{
15
32
class
CachedElement
33
{
34
35
private
:
36
bool
is_cached;
37
CoolPropDbl
value;
38
39
public
:
41
CachedElement
() {
42
this->
clear
();
43
};
44
46
void
_do_cache
(
double
value) {
47
this->value = value;
48
this->is_cached =
true
;
49
}
50
52
void
operator=
(
const
double
& value) {
53
_do_cache
(value);
54
};
55
57
operator
bool() {
58
return
is_cached;
59
};
60
62
operator
double() {
63
if
(is_cached) {
64
return
static_cast<
double
>
(value);
65
}
else
{
66
throw
std::exception();
67
}
68
}
69
#ifndef COOLPROPDBL_MAPS_TO_DOUBLE
70
operator
CoolPropDbl
() {
71
if
(is_cached) {
72
return
value;
73
}
else
{
74
throw
std::exception();
75
}
76
}
77
#endif
79
void
clear
() {
80
is_cached =
false
;
81
this->value = _HUGE;
82
};
83
CoolPropDbl
&
pt
() {
84
return
this->value;
85
}
86
};
87
88
}
/* namespace CoolProp */
89
#endif
/* CACHEDELEMENT_H_ */
Generated on Fri Oct 4 2024 09:06:32 for CoolProp by
1.9.1