CASM  1.1.0
A Clusters Approach to Statistical Mechanics
DBInterface_impl.hh
Go to the documentation of this file.
1 #ifndef CASM_DBInterface_impl
2 #define CASM_DBInterface_impl
3 
7 #include "casm/app/query.hh"
8 #include "casm/app/select.hh"
10 #include "casm/clex/PrimClex.hh"
12 
13 namespace CASM {
14 namespace DB {
15 
16 template <typename DataObject>
18  // set 'selected' column
19  if (cmd.in_project() && cmd.vm().count("selection")) {
20  m_sel.resize(1);
21  m_sel[0].reset(new Selection<DataObject>(cmd.primclex().db<DataObject>(),
22  cmd.opt().selection_path()));
23  m_ss << cmd.opt().selection_path();
24  cmd.primclex().settings().query_handler<DataObject>().set_selected(sel(0));
25  }
26  _make_dict(cmd);
27 }
28 
29 template <typename DataObject>
31  // set 'selected' column
32  if (cmd.in_project() && cmd.vm().count("selections")) {
33  m_sel.resize(cmd.opt().selection_paths().size());
34  for (int i = 0; i < cmd.opt().selection_paths().size(); ++i) {
35  if (i != 0) {
36  m_ss << ", ";
37  }
38  m_ss << cmd.opt().selection_paths()[i];
39  m_sel[i].reset(new Selection<DataObject>(cmd.primclex().db<DataObject>(),
40  cmd.opt().selection_paths()[i]));
41  }
42 
43  cmd.primclex().settings().query_handler<DataObject>().set_selected(sel(0));
44  }
45  _make_dict(cmd);
46 }
47 
48 template <typename DataObject>
50  // set 'selected' column
51  if (cmd.in_project()) {
52  m_dict = &cmd.primclex().settings().query_handler<DataObject>().dict();
53  } else {
54  m_standard_dict.reset(new DataFormatterDictionary<DataObject>());
55  *m_standard_dict = make_dictionary<DataObject>();
56  m_dict = m_standard_dict.get();
57  }
58 }
59 
60 } // namespace DB
61 } // namespace CASM
62 
63 #endif
PrimClex & primclex() const
Definition: APICommand.cc:17
bool in_project() const
Definition: APICommand.cc:15
const OptionType & opt() const
Definition: APICommand.hh:61
const po::variables_map & vm() const
Definition: APICommand.hh:59
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:338
const std::vector< fs::path > & selection_paths() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:342
void _make_dict(const APICommandBase &cmd)
InterfaceData(const QueryCommand &cmd)
QueryHandler< DataObject > & query_handler()
DB::Database< T > & db() const
Definition: PrimClex.cc:302
ProjectSettings & settings()
Definition: PrimClex.cc:224
Main CASM namespace.
Definition: APICommand.hh:8