CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ScelDatabase.hh
Go to the documentation of this file.
1 #ifndef CASM_ScelDatabase
2 #define CASM_ScelDatabase
3 
4 #include <map>
5 #include <set>
6 
7 #include "casm/clex/Supercell.hh"
10 
11 namespace CASM {
12 
13 namespace DB {
14 
31 template <>
32 class Database<Supercell> : public ValDatabase<Supercell> {
33  public:
34  Database(const PrimClex &_primclex) : ValDatabase<Supercell>(_primclex) {}
35 
36  virtual ~Database() {}
37 
38  iterator begin() const override;
39 
40  iterator end() const override;
41 
42  size_type size() const override;
43 
44  std::pair<iterator, bool> insert(const Supercell &obj) override;
45  std::pair<iterator, bool> insert(const Supercell &&obj) override;
47 
48  template <typename... Args>
49  std::pair<iterator, bool> emplace(Args &&... args) {
50  return _on_insert_or_emplace(
51  m_scel_list.emplace(std::forward<Args>(args)...));
52  }
53 
55  iterator erase(iterator pos) override;
56 
57  iterator find(const std::string &name_or_alias) const override;
59 
60  protected:
61  typedef std::set<Supercell>::iterator base_iterator;
62 
63  std::pair<iterator, bool> _on_insert_or_emplace(
64  const std::pair<base_iterator, bool> &result);
65 
66  void clear();
67 
68  iterator _iterator(base_iterator base_it) const;
69 
70  std::map<std::string, base_iterator> m_name_to_scel;
71  std::set<Supercell> m_scel_list;
72 };
73 
74 } // namespace DB
75 } // namespace CASM
76 
77 #endif
std::pair< iterator, bool > emplace(Args &&... args)
Definition: ScelDatabase.hh:49
std::map< std::string, base_iterator > m_name_to_scel
Definition: ScelDatabase.hh:70
std::set< Supercell >::iterator base_iterator
Definition: ScelDatabase.hh:61
std::set< Supercell > m_scel_list
Definition: ScelDatabase.hh:71
Database(const PrimClex &_primclex)
Definition: ScelDatabase.hh:34
Generic interface for database of a particular CASM type.
Definition: Database.hh:221
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
Main CASM namespace.
Definition: APICommand.hh:8
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
Definition: algorithm.hh:16