CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Import.hh
Go to the documentation of this file.
1 #ifndef CASM_DB_Import
2 #define CASM_DB_Import
3 
5 
6 namespace CASM {
7 namespace Completer {
8 class ImportOption;
9 }
10 } // namespace CASM
11 
12 // To be specialized for calculable 'ConfigType' classes:
13 // StructureMap<ConfigType>::map(fs::path, DatabaseIterator<ConfigType> hint,
14 // inserter result) Import<ConfigType>::desc Import<ConfigType>::run
15 // Import<ConfigType>::_import_formatter
16 // Update<ConfigType>::desc
17 // Update<ConfigType>::run
18 // Update<ConfigType>::_update_formatter
19 // Remove<ConfigType>::desc
20 // Remove<ConfigType>::run
21 
22 namespace CASM {
23 namespace DB {
24 
26 template <typename OutputIterator>
27 std::pair<OutputIterator, int> construct_pos_paths(
28  const PrimClex &primclex, const Completer::ImportOption &import_opt,
29  OutputIterator result);
30 
35  ImportSettings(bool _import = false, bool _copy_files = false,
36  bool _additional_files = false, bool _overwrite = false)
37  : import(_import),
38  copy_files(_copy_files),
39  additional_files(_additional_files),
40  overwrite(_overwrite) {}
41 
42  void set_default() { *this = ImportSettings(); }
43 
44  // attempt to import calculation results into database, else just insert
45  // configurations w/out data
46  bool import;
47 
48  // attempt to copy properties.calc.json file to training directory of best
49  // configuration else just import data
50  bool copy_files;
51 
52  // attempt to copy extra files from the directory where the structure is
53  // being imported from to the training_data directory
55 
56  // Allow overwriting of existing data by 'casm import'
57  bool overwrite;
58 };
59 
60 jsonParser &to_json(ImportSettings const &_set, jsonParser &_json);
61 
62 jsonParser const &from_json(ImportSettings &_set, jsonParser const &_json);
63 
65 template <typename _ConfigType>
66 class ImportT : protected ConfigData {
67  public:
68  using ConfigType = _ConfigType;
69 
71  ImportT(const PrimClex &primclex, const StructureMap<ConfigType> &mapper,
72  ImportSettings const &_set, std::string report_dir);
73 
74  template <typename PathIterator>
75  void import(PathIterator begin, PathIterator end);
76 
77  ImportSettings const &settings() const { return m_set; }
78 
79  protected:
82 
83  private:
84  void _import_report(std::vector<ConfigIO::Result> &results) const;
85 
86  // Copies file for each element of results that corresponds to a succesful
87  // optimal mapping
88  void _copy_files(std::vector<ConfigIO::Result> &results) const;
89 
91 
93 
94  std::string m_report_dir;
95 };
96 
97 // To be specialized for ConfigType (no default implemenation exists)
98 template <typename ConfigType>
99 class Import; // : public ImportT<ConfigType>;
100 /*{
101 public:
102  static const std::string desc;
103  int run(const PrimClex &, const jsonParser &input, const
104 Completer::ImportOption &opt);
105 
106 private:
107  // Allow ConfigType to specialize the report formatting for 'import'
108  DataFormatter<ConfigIO::Result> _import_formatter() const override;
109  };*/
110 
111 } // namespace DB
112 } // namespace CASM
113 
114 #endif
const PrimClex & primclex() const
Definition: ConfigData.hh:152
Generic ConfigType-dependent part of Import.
Definition: Import.hh:66
void _copy_files(std::vector< ConfigIO::Result > &results) const
Definition: Import_impl.hh:185
_ConfigType ConfigType
Definition: Import.hh:68
std::string m_report_dir
Definition: Import.hh:94
ImportT(const PrimClex &primclex, const StructureMap< ConfigType > &mapper, ImportSettings const &_set, std::string report_dir)
Constructor.
Definition: Import_impl.hh:86
virtual DataFormatter< ConfigIO::Result > _import_formatter() const =0
Allow ConfigType to specialize the report formatting for 'import'.
ImportSettings m_set
Definition: Import.hh:92
ImportSettings const & settings() const
Definition: Import.hh:77
void _import_report(std::vector< ConfigIO::Result > &results) const
Definition: Import_impl.hh:223
const StructureMap< ConfigType > & m_structure_mapper
Definition: Import.hh:90
Extract data from objects of 'DataObject' class.
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
jsonParser & to_json(ImportSettings const &_set, jsonParser &_json)
Definition: Import.cc:10
jsonParser const & from_json(ImportSettings &_set, jsonParser const &_json)
Definition: Import.cc:18
std::pair< OutputIterator, int > construct_pos_paths(const PrimClex &primclex, const Completer::ImportOption &import_opt, OutputIterator result)
Construct pos_paths from input args –pos && –batch.
Definition: Import_impl.hh:22
Main CASM namespace.
Definition: APICommand.hh:8
PrimClex * primclex
Definition: settings.cc:135
Struct with optional parameters for Config/Data Import Specifies default parameters for all values,...
Definition: Import.hh:34
ImportSettings(bool _import=false, bool _copy_files=false, bool _additional_files=false, bool _overwrite=false)
Definition: Import.hh:35