1 #ifndef CASM_DatabaseHandler_impl
2 #define CASM_DatabaseHandler_impl
17 std::unique_ptr<DatabaseBase> &&value) {
24 std::string db_name, std::string calc_type,
25 std::unique_ptr<PropertiesDatabase> &&value) {
75 std::string calc_type)
const {
82 std::string calc_type) {
89 auto res = _find<T>(db_name);
96 auto res = _find<T>(db_name);
101 template <
typename T>
103 auto res = _find<T>(db_name);
108 template <
typename T>
110 auto res = _find<T>(db_name);
111 return static_cast<Database<T> &
>(res->second->open());
115 template <
typename T>
117 auto res = _find<T>(db_name);
118 return static_cast<Database<T> &
>(res->second->open());
122 template <
typename T>
124 auto res = _find<T>(db_name);
125 return static_cast<Database<T> &
>(res->second->open());
129 template <
typename T>
131 std::string calc_type) {
132 auto res = _find_props<T>(db_name, calc_type);
137 template <
typename T>
139 std::string db_name, std::string calc_type)
const {
140 auto res = _find_props<T>(db_name, calc_type);
145 template <
typename T>
147 std::string db_name, std::string calc_type) {
148 auto res = _find_props<T>(db_name, calc_type);
152 template <
typename T>
154 std::string db_name)
const {
156 auto res =
m_db.find(key);
157 if (res ==
m_db.end()) {
158 _no_database_error<T>(db_name);
163 template <
typename T>
165 std::string db_name, std::string calc_type)
const {
169 _no_props_database_error<T>(db_name, calc_type);
174 template <
typename T>
176 std::stringstream ss;
178 ss <<
" Database: " << db_name;
179 throw std::runtime_error(
"Requested database not found: " + ss.str());
182 template <
typename T>
184 std::string calc_type)
const {
185 std::stringstream ss;
187 ss <<
" Database: " << db_name;
188 ss <<
" CalcType: " << calc_type;
189 throw std::runtime_error(
"Requested properties database not found: " +
const ValDatabase< T > & const_generic_db()
Access default Database<T>
PropertiesDatabase & db_props(std::string calc_type)
Access default PropertiesDatabase.
props_map_type m_db_props
map_type::iterator _find(std::string db_name) const
std::string m_default_db_name
void insert_props(std::string db_name, std::string calc_type, std::unique_ptr< PropertiesDatabase > &&value)
Insert a PropertiesDatabase.
ValDatabase< T > & generic_db()
Access default Database<T>
Database< T > & db()
Access default Database<T>
void insert(std::string db_name, std::unique_ptr< DatabaseBase > &&value)
Insert a Database.
const Database< T > & const_db()
Access default Database<T>
const PropertiesDatabase & const_db_props(std::string calc_type)
Access default PropertiesDatabase.
void _no_props_database_error(std::string db_name, std::string calc_type) const
void _no_database_error(std::string db_name) const
props_map_type::iterator _find_props(std::string db_name, std::string calc_type) const
Generic interface for database of a particular CASM type.