-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathCalculable.hh
More file actions
114 lines (84 loc) · 3.75 KB
/
Calculable.hh
File metadata and controls
114 lines (84 loc) · 3.75 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef CASM_Calculable
#define CASM_Calculable
#include <string>
#include <vector>
#include "casm/clex/MappedProperties.hh"
#include "casm/database/Cache.hh"
#include "casm/database/Named.hh"
namespace CASM {
class jsonParser;
///
/// - name and calculated properties should be invalidated whenever the
/// ConfigType DoF are modified. Can do this by calling _modify_dof(). This
/// means all DoF should be accessed via functions.
/// - cache should only be used for DoF-dependent properties, not
/// calctype-dependent properties
///
template <typename _Base>
class Calculable : public DB::Cache, public DB::Indexed<_Base> {
public:
typedef typename DB::Indexed<_Base> Base;
typedef typename Base::MostDerived MostDerived;
using Base::derived;
/// \brief Return MappedProperties for requested calctype
MappedProperties const &calc_properties(std::string calctype = "") const;
void set_calc_properties(const MappedProperties &_prop,
std::string calctype = "");
/// \brief grabs properties from the indicated calctype and adds info to
/// calc_properties_map
void refresh_calc_properties(std::string calctype = "");
const jsonParser &source() const;
void set_source(const jsonParser &source);
void push_back_source(const jsonParser &source);
std::map<std::string, MappedProperties> calc_properties_map() const {
return m_calc_properties_map;
}
protected:
/// Call in MostDerived any time DoF may be modified
void _modify_dof();
/// \brief grabs properties from the indicated calctype and adds info to
/// calc_properties_map
void _refresh_calc_properties(std::string calctype = "") const;
private:
mutable std::map<std::string, MappedProperties> m_calc_properties_map;
jsonParser m_source;
};
/// \brief Return true if all required properties have been been calculated for
/// the configuration
template <typename ConfigType>
bool is_calculated(const ConfigType &config, std::string calctype = "");
template <typename ConfigType>
void reset_properties(ConfigType &config);
/// \brief Status of calculation
/// A calculation that has been run successfully will be marked 'complete'.
/// Mapped or imported configurations may have 'is_calculated = 1' without
/// 'calc_status = complete'.
template <typename ConfigType>
std::string calc_status(const ConfigType &_config, std::string calctype = "");
// \brief Reason for calculation failure.
template <typename ConfigType>
std::string failure_type(const ConfigType &config, std::string calctype = "");
template <typename ConfigType>
bool has_calc_status(const ConfigType &config, std::string calctype = "");
template <typename ConfigType>
bool has_failure_type(const ConfigType &config, std::string calctype = "");
template <typename ConfigType>
std::string calc_properties_path(const ConfigType &config,
std::string calctype = "");
template <typename ConfigType>
std::string pos_path(const ConfigType &config, std::string calctype = "");
template <typename ConfigType>
std::string calc_status_path(const ConfigType &config,
std::string calctype = "");
/// \brief Return true if all required properties are included in the JSON
bool is_calculated(const MappedProperties &calc_properties,
const std::vector<std::string> &required_properties);
std::string calc_properties_path(const PrimClex &primclex,
const std::string &configname,
std::string calctype = "");
std::string pos_path(const PrimClex &primclex, const std::string &configname);
std::string calc_status_path(const PrimClex &primclex,
const std::string &configname,
std::string calctype = "");
} // namespace CASM
#endif