CASM  1.1.0
A Clusters Approach to Statistical Mechanics
DatabaseNameIterator.hh
Go to the documentation of this file.
1 #ifndef CASM_DatabaseNameIterator
2 #define CASM_DatabaseNameIterator
3 
4 #include <memory>
5 #include <set>
6 
7 namespace CASM {
8 
9 namespace DB {
10 
32 template <typename ValueType, typename DatabaseType, typename ObjIterator>
33 class DatabaseNameIterator : public DatabaseIteratorBase<ValueType> {
34  public:
36 
37  std::string name() const override { return m_it->first; }
38 
39  std::unique_ptr<DatabaseIteratorBase<ValueType> > clone() const {
40  return std::unique_ptr<DatabaseIteratorBase<ValueType> >(this->_clone());
41  }
42 
43  private:
44  friend DatabaseType;
45 
46  typedef
47  typename std::map<std::string, ObjIterator>::const_iterator base_iterator;
48 
50 
51  base_iterator base() const { return m_it; }
52 
53  bool equal(const DatabaseIteratorBase<ValueType> &other) const override {
54  return m_it == static_cast<const DatabaseNameIterator &>(other).m_it;
55  }
56 
57  void increment() override { ++m_it; }
58 
59  const ValueType &dereference() const override { return *(m_it->second); }
60 
61  /*
62  long distance_to(const DatabaseIteratorBase<ValueType> &other) const override
63  { return std::distance(m_it, static_cast<const DatabaseNameIterator
64  &>(other).m_it);
65  }
66  */
67 
68  DatabaseNameIterator *_clone() const override {
69  return new DatabaseNameIterator(*this);
70  }
71 
73 };
74 
75 } // namespace DB
76 } // namespace CASM
77 
78 #endif
DatabaseIterator for implementations using std::map<std::string, ObjIterator>
std::map< std::string, ObjIterator >::const_iterator base_iterator
std::unique_ptr< DatabaseIteratorBase< ValueType > > clone() const
DatabaseNameIterator * _clone() const override
std::string name() const override
const ValueType & dereference() const override
bool equal(const DatabaseIteratorBase< ValueType > &other) const override
Main CASM namespace.
Definition: APICommand.hh:8