CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Selected.cc
Go to the documentation of this file.
6 
7 // explicit template instantiations
8 #define INST_Selected(r, data, type) template class Selected<type>;
9 
10 namespace CASM {
11 namespace DB {
12 
13 template <typename ObjType>
14 bool Selected<ObjType>::init(const ObjType &_tmplt) const {
15  if (!m_selection) {
16  if (m_selection_name.empty()) {
17  m_selection_name = "MASTER";
18  }
19  m_selection = notstd::make_cloneable<Selection<ObjType> >(
20  _tmplt.primclex().template db<ObjType>(), m_selection_name);
21  } else if (m_selection_name.empty()) {
22  m_selection_name = m_selection->name();
23  if (m_selection_name.empty()) {
24  m_selection_name = "unknown";
25  }
26  }
27  return true;
28 }
29 
30 template <typename ObjType>
31 std::unique_ptr<Selected<ObjType> > Selected<ObjType>::clone() const {
32  return std::unique_ptr<Selected>(this->_clone());
33 }
34 
35 template <typename ObjType>
37  return new Selected(*this);
38 }
39 
40 template <typename ObjType>
41 std::string Selected<ObjType>::short_header(const ObjType &_obj) const {
42  return this->name() + "(" + m_selection_name + ")";
43 }
44 
45 template <typename ObjType>
46 bool Selected<ObjType>::evaluate(const ObjType &_obj) const {
47  if (_obj.name().find("equiv") != std::string::npos) {
48  return false;
49  }
50  return m_selection->is_selected(_obj.name());
51 }
52 
53 template <typename ObjType>
54 bool Selected<ObjType>::parse_args(const std::string &args) {
55  if ((m_selection && m_selection->data().size()) || m_selection_name.size()) {
56  return false;
57  }
58 
59  m_selection_name = args;
60  return true;
61 }
62 
63 BOOST_PP_SEQ_FOR_EACH(INST_Selected, _, CASM_DB_TYPES)
64 } // namespace DB
65 } // namespace CASM
#define CASM_DB_TYPES
#define INST_Selected(r, data, type)
Definition: Selected.cc:8
Returns true if configuration is specified in given selection (default: MASTER)
Definition: Selected.hh:20
bool parse_args(const std::string &args) override
Definition: Selected.cc:54
bool init(const ObjType &_tmplt) const override
Definition: Selected.cc:14
std::string short_header(const ObjType &_config) const override
Definition: Selected.cc:41
std::unique_ptr< Selected > clone() const
Definition: Selected.cc:31
Selected * _clone() const override
Clone.
Definition: Selected.cc:36
bool evaluate(const ObjType &_obj) const override
True if obj is in Selection and it is selected.
Definition: Selected.cc:46
Main CASM namespace.
Definition: APICommand.hh:8
GenericDatumFormatter< std::string, DataObject > name()