CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::DB::DatabaseIterator< ValueType > Class Template Reference

#include <Database.hh>

+ Inheritance diagram for CASM::DB::DatabaseIterator< ValueType >:

Detailed Description

template<typename ValueType>
class CASM::DB::DatabaseIterator< ValueType >

Wrapper class for specializations DatabaseIteratorBase.

Dereferencing DatabaseIterator only provides const references, whether the underlying resource is persistent (Supercell) or temporary (other types). Changing database entries must be done via copy then insert, or update.

DatabaseIterator should always be dereferenceable (except end or when default constructed), though the reference may be invalidated when a second DatabaseIterator is dereferenced, dereferencing the first again should be valid (though it may require re-allocation):

DatabaseIterator<ValueType> A = primclex.db<ValueType>().find(A_name);
const ValueType& A_ref1 = *A; // ok
A_ref1.method(); // ok
A->method(); // ok
DatabaseIterator<ValueType> B = primclex.db<ValueType>().find(B_name);
const ValueType& B_ref = *B; // ok, but now A_ref1 may be invalidated
A_ref1.method(); // maybe not ok
A->method(); // ok
B->method(); // ok
const ValueType& A_ref2 = *A; // ok, but now B_ref may be invalidated
A_ref1.method(); // maybe not ok
A_ref2.method(); // ok
B_ref.method(); // maybe not ok
A->method(); // ok
B->method(); // ok
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
PrimClex * primclex
Definition: settings.cc:135

Definition at line 147 of file Database.hh.

Public Member Functions

 DatabaseIterator ()
 Default constructor. More...
 
 DatabaseIterator (const DatabaseIteratorBase< ValueType > &it)
 Construct iterator. More...
 
std::string name () const
 
DatabaseIteratorBase< ValueType > * get () const
 

Private Member Functions

void increment ()
 boost::iterator_facade implementation More...
 
const ValueType & dereference () const
 boost::iterator_facade implementation More...
 
bool equal (const DatabaseIterator &B) const
 boost::iterator_facade implementation More...
 

Private Attributes

notstd::cloneable_ptr< DatabaseIteratorBase< ValueType > > m_ptr
 

Constructor & Destructor Documentation

◆ DatabaseIterator() [1/2]

template<typename ValueType >
CASM::DB::DatabaseIterator< ValueType >::DatabaseIterator ( )
inline

Default constructor.

Definition at line 154 of file Database.hh.

◆ DatabaseIterator() [2/2]

template<typename ValueType >
CASM::DB::DatabaseIterator< ValueType >::DatabaseIterator ( const DatabaseIteratorBase< ValueType > &  it)
inline

Construct iterator.

Definition at line 157 of file Database.hh.

Member Function Documentation

◆ dereference()

template<typename ValueType >
const ValueType& CASM::DB::DatabaseIterator< ValueType >::dereference ( ) const
inlineprivate

boost::iterator_facade implementation

Definition at line 171 of file Database.hh.

◆ equal()

template<typename ValueType >
bool CASM::DB::DatabaseIterator< ValueType >::equal ( const DatabaseIterator< ValueType > &  B) const
inlineprivate

boost::iterator_facade implementation

Definition at line 174 of file Database.hh.

◆ get()

template<typename ValueType >
DatabaseIteratorBase<ValueType>* CASM::DB::DatabaseIterator< ValueType >::get ( ) const
inline

Definition at line 162 of file Database.hh.

◆ increment()

template<typename ValueType >
void CASM::DB::DatabaseIterator< ValueType >::increment ( )
inlineprivate

boost::iterator_facade implementation

Definition at line 168 of file Database.hh.

◆ name()

template<typename ValueType >
std::string CASM::DB::DatabaseIterator< ValueType >::name ( ) const
inline

Definition at line 160 of file Database.hh.

Member Data Documentation

◆ m_ptr

template<typename ValueType >
notstd::cloneable_ptr<DatabaseIteratorBase<ValueType> > CASM::DB::DatabaseIterator< ValueType >::m_ptr
private

Definition at line 185 of file Database.hh.


The documentation for this class was generated from the following files: