CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Selected.hh
Go to the documentation of this file.
1 #ifndef CASM_Selected
2 #define CASM_Selected
3 
7 
8 namespace CASM {
9 
10 namespace DB {
11 
19 template <typename ObjType>
20 class Selected : public BooleanAttribute<ObjType> {
21  public:
23  : BooleanAttribute<ObjType>("selected_in",
24  "Returns true if object is specified in "
25  "given selection (default MASTER). "
26  "Ex: 'selected_in(myselection.txt)'") {}
27 
28  explicit Selected(const Selection<ObjType> &_selection)
29  : BooleanAttribute<ObjType>("selected_in",
30  "Returns true if configuration is specified "
31  "in given selection (default MASTER). "
32  "Ex: 'selected_in(myselection.txt)'"),
33  m_selection(notstd::clone(_selection)) {}
34 
35  explicit Selected(std::unique_ptr<Selection<ObjType> > _selection)
36  : BooleanAttribute<ObjType>("selected_in",
37  "Returns true if configuration is specified "
38  "in given selection (default MASTER). "
39  "Ex: 'selected_in(myselection.txt)'"),
40  m_selection(std::move(_selection)) {}
41 
42  // --- Required implementations -----------
43 
44  std::unique_ptr<Selected> clone() const;
45 
47  bool evaluate(const ObjType &_obj) const override;
48 
49  // --- Specialized implementation -----------
50 
51  bool init(const ObjType &_tmplt) const override;
52 
53  std::string short_header(const ObjType &_config) const override;
54 
55  bool parse_args(const std::string &args) override;
56 
57  private:
59  Selected *_clone() const override;
60 
61  mutable std::string m_selection_name;
63 };
64 } // namespace DB
65 } // namespace CASM
66 
67 #endif
Base class for creating scalar DatumFormatter.
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
std::string m_selection_name
Definition: Selected.hh:61
bool init(const ObjType &_tmplt) const override
Definition: Selected.cc:14
std::string short_header(const ObjType &_config) const override
Definition: Selected.cc:41
notstd::cloneable_ptr< Selection< ObjType > > m_selection
Definition: Selected.hh:62
std::unique_ptr< Selected > clone() const
Definition: Selected.cc:31
Selected(const Selection< ObjType > &_selection)
Definition: Selected.hh:28
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
Selected(std::unique_ptr< Selection< ObjType > > _selection)
Definition: Selected.hh:35
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
Main CASM namespace.
Definition: APICommand.hh:8
Non-std smart pointer classes and functions.
Definition: stream_io.hh:24