CASM  1.1.0
A Clusters Approach to Statistical Mechanics
DatabaseTypes.hh
Go to the documentation of this file.
1 #ifndef CASM_DatabaseTypes
2 #define CASM_DatabaseTypes
3 
4 #include <boost/preprocessor/seq/enum.hpp>
5 #include <boost/preprocessor/seq/for_each.hpp>
6 #include <set>
7 
10 #include "casm/misc/CASM_TMP.hh"
11 
12 // 1) add Database types here
13 #define CASM_DB_NONCONFIG_TYPES (Supercell)
14 #define CASM_DB_CONFIG_TYPES (Configuration)
15 
16 // 2) add #include locations as appropriate to:
17 // DatabaseTypeDefs.hh, DatabaseTypeTraits.hh,
18 // ConfigTypeDefs.hh, ConfigTypeTraits.hh
19 
20 // --- the rest works based on ^ -----------------------------------------------
21 
22 #define CASM_DB_TYPES CASM_DB_NONCONFIG_TYPES CASM_DB_CONFIG_TYPES
23 
24 namespace CASM {
25 
26 class PrimClex;
27 
28 namespace DB {
29 
30 // List of all types stored in a Database
31 typedef std::tuple<BOOST_PP_SEQ_ENUM(CASM_DB_TYPES)> DataObjectTypeTuple;
32 
33 // List of all configtypes which have calculations stored in a
34 // PropertiesDatabase
35 typedef std::tuple<BOOST_PP_SEQ_ENUM(CASM_DB_CONFIG_TYPES)> ConfigTypeTuple;
36 
37 // -- SFINAE helper --
38 
39 template <typename T>
40 using IfConfigType =
41  std::enable_if<CASM_TMP::has_type<T, ConfigTypeTuple>::value, T>;
42 
43 template <typename T>
45  std::enable_if<!CASM_TMP::has_type<T, ConfigTypeTuple>::value, T>;
46 
47 // -- List of Database DataObject and ConfigType --
48 
49 template <typename F>
50 void for_each_type(F f) {
51  return CASM_TMP::for_each_type<DataObjectTypeTuple, F>(f);
52 }
53 
54 template <typename F>
55 void for_type(std::string name, F f) {
56  return CASM_TMP::for_type<DataObjectTypeTuple, F>(name, f);
57 }
58 
59 template <typename F>
60 void for_type_short(std::string short_name, F f) {
61  return CASM_TMP::for_type_short<DataObjectTypeTuple, F>(short_name, f);
62 }
63 
65 const std::set<std::string> &types();
66 
68 const std::set<std::string> &types_short();
69 
70 template <typename F>
72  return CASM_TMP::for_each_type<ConfigTypeTuple, F>(f);
73 }
74 
75 template <typename F>
76 void for_config_type(std::string name, F f) {
77  return CASM_TMP::for_type<ConfigTypeTuple, F>(name, f);
78 }
79 
80 template <typename F>
81 void for_config_type_short(std::string short_name, F f) {
82  return CASM_TMP::for_type_short<ConfigTypeTuple, F>(short_name, f);
83 }
84 
86 const std::set<std::string> &config_types();
87 
89 const std::set<std::string> &config_types_short();
90 
92 Index config_count(std::string scelname, const PrimClex &primclex);
93 
95 Index config_count(std::string configtype, std::string scelname,
96  const PrimClex &primclex);
97 
100 
102 Index config_calculated_count(std::string configtype, std::string scelname,
103  const PrimClex &primclex);
104 
106 Index config_data_count(std::string scelname, const PrimClex &primclex);
107 
109 Index config_data_count(std::string configtype, std::string scelname,
110  const PrimClex &primclex);
111 
112 } // namespace DB
113 } // namespace CASM
114 
115 #endif
#define CASM_DB_TYPES
#define CASM_DB_CONFIG_TYPES
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
std::string scelname(const Structure &prim, const Lattice &superlat)
Make supercell name name [deprecated].
Definition: Supercell.cc:497
std::tuple< BOOST_PP_SEQ_ENUM(CASM_DB_TYPES)> DataObjectTypeTuple
void for_type_short(std::string short_name, F f)
std::enable_if<!CASM_TMP::has_type< T, ConfigTypeTuple >::value, T > IfNotConfigType
Index config_count(std::string scelname, const PrimClex &primclex)
Total number of configs of all types in a supercell.
const std::set< std::string > & types()
std::set of all QueryTraits<DataObject>::name
Index config_data_count(std::string scelname, const PrimClex &primclex)
Total number of configs w/ data or files of all types in a supercell.
std::tuple< BOOST_PP_SEQ_ENUM(CASM_DB_CONFIG_TYPES)> ConfigTypeTuple
const std::set< std::string > & config_types()
std::set of all QueryTraits<ConfigType>::name
void for_config_type_short(std::string short_name, F f)
void for_each_type(F f)
const std::set< std::string > & types_short()
std::set of all QueryTraits<DataObject>::short_name
void for_config_type(std::string name, F f)
void for_type(std::string name, F f)
const std::set< std::string > & config_types_short()
std::set of all QueryTraits<ConfigType>::short_name
std::enable_if< CASM_TMP::has_type< T, ConfigTypeTuple >::value, T > IfConfigType
void for_each_config_type(F f)
Index config_calculated_count(std::string scelname, const PrimClex &primclex)
Total number of calculated configs of all types in a supercell.
Main CASM namespace.
Definition: APICommand.hh:8
GenericDatumFormatter< std::string, DataObject > name()
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
PrimClex * primclex
Definition: settings.cc:135