CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Calculable.hh
Go to the documentation of this file.
1 #ifndef CASM_Calculable
2 #define CASM_Calculable
3 
4 #include <string>
5 #include <vector>
6 
8 #include "casm/database/Cache.hh"
9 #include "casm/database/Named.hh"
10 
11 namespace CASM {
12 
13 class jsonParser;
14 
22 template <typename _Base>
23 class Calculable : public DB::Cache, public DB::Indexed<_Base> {
24  public:
25  typedef typename DB::Indexed<_Base> Base;
26  typedef typename Base::MostDerived MostDerived;
27  using Base::derived;
28 
30  MappedProperties const &calc_properties(std::string calctype = "") const;
31 
32  void set_calc_properties(const MappedProperties &_prop,
33  std::string calctype = "");
34 
37  void refresh_calc_properties(std::string calctype = "");
38 
39  const jsonParser &source() const;
40 
41  void set_source(const jsonParser &source);
42 
43  void push_back_source(const jsonParser &source);
44 
45  std::map<std::string, MappedProperties> calc_properties_map() const {
46  return m_calc_properties_map;
47  }
48 
49  protected:
51  void _modify_dof();
52 
55  void _refresh_calc_properties(std::string calctype = "") const;
56 
57  private:
58  mutable std::map<std::string, MappedProperties> m_calc_properties_map;
60 };
61 
64 template <typename ConfigType>
65 bool is_calculated(const ConfigType &config, std::string calctype = "");
66 
67 template <typename ConfigType>
68 void reset_properties(ConfigType &config);
69 
71 template <typename ConfigType>
72 std::string calc_status(const ConfigType &_config, std::string calctype = "");
73 
74 // \brief Reason for calculation failure.
75 template <typename ConfigType>
76 std::string failure_type(const ConfigType &config, std::string calctype = "");
77 
78 template <typename ConfigType>
79 bool has_calc_status(const ConfigType &config, std::string calctype = "");
80 
81 template <typename ConfigType>
82 bool has_failure_type(const ConfigType &config, std::string calctype = "");
83 
84 template <typename ConfigType>
85 std::string calc_properties_path(const ConfigType &config,
86  std::string calctype = "");
87 
88 template <typename ConfigType>
89 std::string pos_path(const ConfigType &config, std::string calctype = "");
90 
91 template <typename ConfigType>
92 std::string calc_status_path(const ConfigType &config,
93  std::string calctype = "");
94 
96 bool is_calculated(const MappedProperties &calc_properties,
97  const std::vector<std::string> &required_properties);
98 
99 std::string calc_properties_path(const PrimClex &primclex,
100  const std::string &configname,
101  std::string calctype = "");
102 
103 std::string pos_path(const PrimClex &primclex, const std::string &configname);
104 
105 std::string calc_status_path(const PrimClex &primclex,
106  const std::string &configname,
107  std::string calctype = "");
108 
109 } // namespace CASM
110 
111 #endif
DB::Indexed< _Base > Base
Definition: Calculable.hh:25
void set_calc_properties(const MappedProperties &_prop, std::string calctype="")
Definition: Calculable.cc:32
MappedProperties const & calc_properties(std::string calctype="") const
Return MappedProperties for requested calctype.
Definition: Calculable.cc:17
void _modify_dof()
Call in MostDerived any time DoF may be modified.
Definition: Calculable.cc:104
Base::MostDerived MostDerived
Definition: Calculable.hh:26
void set_source(const jsonParser &source)
Definition: Calculable.cc:56
void _refresh_calc_properties(std::string calctype="") const
grabs properties from the indicated calctype and adds info to calc_properties_map
Definition: Calculable.cc:116
void push_back_source(const jsonParser &source)
Definition: Calculable.cc:68
jsonParser m_source
Definition: Calculable.hh:59
std::map< std::string, MappedProperties > m_calc_properties_map
Definition: Calculable.hh:58
std::map< std::string, MappedProperties > calc_properties_map() const
Definition: Calculable.hh:45
void refresh_calc_properties(std::string calctype="")
grabs properties from the indicated calctype and adds info to calc_properties_map
Definition: Calculable.cc:45
const jsonParser & source() const
Definition: Calculable.cc:51
Store data in JSON.
Definition: Cache.hh:13
Base::MostDerived MostDerived
Definition: Named.hh:60
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:563
Main CASM namespace.
Definition: APICommand.hh:8
std::string calc_properties_path(const ConfigType &config, std::string calctype="")
Definition: Calculable.cc:197
bool is_calculated(const ConfigType &config, std::string calctype="")
Return true if all required properties have been been calculated for the configuration.
Definition: Calculable.cc:137
std::string pos_path(const ConfigType &config, std::string calctype="")
void reset_properties(ConfigType &config)
Definition: Calculable.cc:147
std::string calc_status_path(const ConfigType &config, std::string calctype="")
Definition: Calculable.cc:211
std::string failure_type(const ConfigType &config, std::string calctype="")
Definition: Calculable.cc:167
std::string calc_status(const ConfigType &_config, std::string calctype="")
Status of calculation.
Definition: Calculable.cc:153
bool has_calc_status(const ConfigType &config, std::string calctype="")
Definition: Calculable.cc:181
bool has_failure_type(const ConfigType &config, std::string calctype="")
Definition: Calculable.cc:189
PrimClex * primclex
Definition: settings.cc:135
pair_type calctype
Definition: settings.cc:143