CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::DB::ValDatabase< ValueType > Class Template Referenceabstract

#include <Database.hh>

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

Detailed Description

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

Generic interface for database of a particular CASM type.

Currently all ValueType use the same interface, though it is possible to specialization this interface for a particular ValueType.

ValueType must have:

  • std::string ValueType::name() const
    • is unique, is constant, not necessarily deterministic
  • std::string ValueType::alias() const

Derived classes must implement public methods:

Database insert methods by convention do not enforce canonical form or any other logic, they simply insert as is. By convention, a ValueType::insert method shold be implemented to enforce canonical form and any other constraints. But in cases where it is known that ValueType are being generated in the correct form for insertion in the database, the Database insert methods may be used directly. For example, see the method insert_unique_canon_configs.

Definition at line 221 of file Database.hh.

Public Types

typedef DatabaseIterator< ValueType > iterator
 
typedef ValueType value_type
 
typedef Index size_type
 
typedef Base::MostDerived MostDerived
 

Public Member Functions

 ValDatabase (const PrimClex &_primclex)
 
virtual ~ValDatabase ()
 
virtual iterator begin () const =0
 
virtual iterator end () const =0
 
virtual size_type size () const =0
 
bool empty () const
 
std::pair< iterator, bool > set_alias (const std::string &name_or_alias, const std::string &alias)
 For setting an alias. More...
 
std::string name (const std::string &name_or_alias) const
 
std::string alias (const std::string &name_or_alias) const
 Get alias from name_or_alias. More...
 
virtual std::pair< iterator, bool > insert (const ValueType &obj)=0
 
virtual std::pair< iterator, bool > insert (const ValueType &&obj)=0
 
template<typename InputIt >
void insert (InputIt first, InputIt last)
 
virtual iterator erase (iterator pos)=0
 
size_type erase (const std::string &name_or_alias)
 
size_type erase (const ValueType &obj)
 
virtual size_type count (const std::string &name_or_alias) const
 
virtual iterator find (const std::string &name_or_alias) const =0
 
virtual void commit ()=0
 
Selection< ValueType > & master_selection ()
 
const Selection< ValueType > & master_selection () const
 
virtual DatabaseBaseopen ()=0
 
virtual void close ()=0
 
const PrimClexprimclex () const
 
const Structureprim () const
 
double crystallography_tol () const
 

Protected Member Functions

void read_aliases ()
 
void write_aliases ()
 
template<typename _ValueType >
void clear_name (const _ValueType &obj) const
 Only ValDatabase<ValueType> is allowed to do clear_name. More...
 
template<typename _ValueType >
void set_id (const _ValueType &obj, Index id) const
 Only ValDatabase<ValueType> is allowed to do a const id change. More...
 
template<typename _ValueType >
void set_id (const _ValueType &obj, std::string id) const
 Only ValDatabase<ValueType> is allowed to do a const id change. More...
 
MostDerivedderived ()
 
const MostDerivedderived () const
 

Private Attributes

std::map< std::string, std::string > m_name_to_alias
 
std::map< std::string, std::string > m_alias_to_name
 
Selection< ValueType > m_master_selection
 
const PrimClexm_primclex
 

Member Typedef Documentation

◆ iterator

template<typename ValueType >
typedef DatabaseIterator<ValueType> CASM::DB::ValDatabase< ValueType >::iterator

Definition at line 223 of file Database.hh.

◆ MostDerived

typedef Base::MostDerived CASM::HasPrimClex< CRTPBase< DatabaseBase > >::MostDerived
inherited

Definition at line 16 of file HasPrimClex.hh.

◆ size_type

template<typename ValueType >
typedef Index CASM::DB::ValDatabase< ValueType >::size_type

Definition at line 225 of file Database.hh.

◆ value_type

template<typename ValueType >
typedef ValueType CASM::DB::ValDatabase< ValueType >::value_type

Definition at line 224 of file Database.hh.

Constructor & Destructor Documentation

◆ ValDatabase()

template<typename ValueType >
CASM::DB::ValDatabase< ValueType >::ValDatabase ( const PrimClex _primclex)
inline

Definition at line 227 of file Database.hh.

◆ ~ValDatabase()

template<typename ValueType >
virtual CASM::DB::ValDatabase< ValueType >::~ValDatabase ( )
inlinevirtual

Definition at line 229 of file Database.hh.

Member Function Documentation

◆ alias()

template<typename ValueType >
std::string CASM::DB::ValDatabase< ValueType >::alias ( const std::string &  name_or_alias) const

Get alias from name_or_alias.

Get alias from name_or_alias

  • Checks if name_or_alias is a known alias
  • If yes, returns name_or_alias
  • If no, checks if name_or_alias is a name corresponding to a known alias
    • If yes, returns alias
    • If no, (because name_or_alias is an invalid name, or because name_or_alias is a valid name without an alias), returns empty string

Definition at line 83 of file Database_impl.hh.

◆ begin()

template<typename ValueType >
virtual iterator CASM::DB::ValDatabase< ValueType >::begin ( ) const
pure virtual

◆ clear_name()

template<typename ValueType >
template<typename _ValueType >
void CASM::DB::ValDatabase< ValueType >::clear_name ( const _ValueType &  obj) const
inlineprotected

Only ValDatabase<ValueType> is allowed to do clear_name.

Definition at line 298 of file Database.hh.

◆ close()

virtual void CASM::DB::DatabaseBase::close ( )
pure virtualinherited

◆ commit()

template<typename ValueType >
virtual void CASM::DB::ValDatabase< ValueType >::commit ( )
pure virtual

◆ count()

template<typename ValueType >
virtual size_type CASM::DB::ValDatabase< ValueType >::count ( const std::string &  name_or_alias) const
inlinevirtual

Definition at line 268 of file Database.hh.

◆ crystallography_tol()

double CASM::HasPrimClex< CRTPBase< DatabaseBase > >::crystallography_tol
inherited

Definition at line 21 of file HasPrimClex_impl.hh.

◆ derived() [1/2]

template<typename _MostDerived >
MostDerived& notstd::CRTPBase< _MostDerived >::derived ( )
inlineprotectedinherited

Definition at line 13 of file CRTPBase.hh.

◆ derived() [2/2]

template<typename _MostDerived >
const MostDerived& notstd::CRTPBase< _MostDerived >::derived ( ) const
inlineprotectedinherited

Definition at line 15 of file CRTPBase.hh.

◆ empty()

template<typename ValueType >
bool CASM::DB::ValDatabase< ValueType >::empty ( ) const
inline

Definition at line 236 of file Database.hh.

◆ end()

template<typename ValueType >
virtual iterator CASM::DB::ValDatabase< ValueType >::end ( ) const
pure virtual

◆ erase() [1/3]

template<typename ValueType >
size_type CASM::DB::ValDatabase< ValueType >::erase ( const std::string &  name_or_alias)
inline

Definition at line 262 of file Database.hh.

◆ erase() [2/3]

template<typename ValueType >
size_type CASM::DB::ValDatabase< ValueType >::erase ( const ValueType &  obj)
inline

Definition at line 266 of file Database.hh.

◆ erase() [3/3]

template<typename ValueType >
virtual iterator CASM::DB::ValDatabase< ValueType >::erase ( iterator  pos)
pure virtual

◆ find()

template<typename ValueType >
virtual iterator CASM::DB::ValDatabase< ValueType >::find ( const std::string &  name_or_alias) const
pure virtual

◆ insert() [1/3]

template<typename ValueType >
virtual std::pair<iterator, bool> CASM::DB::ValDatabase< ValueType >::insert ( const ValueType &&  obj)
pure virtual

◆ insert() [2/3]

template<typename ValueType >
virtual std::pair<iterator, bool> CASM::DB::ValDatabase< ValueType >::insert ( const ValueType &  obj)
pure virtual

◆ insert() [3/3]

template<typename ValueType >
template<typename InputIt >
void CASM::DB::ValDatabase< ValueType >::insert ( InputIt  first,
InputIt  last 
)
inline

Definition at line 256 of file Database.hh.

◆ master_selection() [1/2]

template<typename ValueType >
Selection<ValueType>& CASM::DB::ValDatabase< ValueType >::master_selection ( )
inline

Definition at line 285 of file Database.hh.

◆ master_selection() [2/2]

template<typename ValueType >
const Selection<ValueType>& CASM::DB::ValDatabase< ValueType >::master_selection ( ) const
inline

Definition at line 287 of file Database.hh.

◆ name()

template<typename ValueType >
std::string CASM::DB::ValDatabase< ValueType >::name ( const std::string &  name_or_alias) const

Get name from name_or_alias

  • Checks if name_or_alias is a known alias
  • If known alias, returns associated name
  • If not known alias, assumed to be a name and returns name_or_alias

Definition at line 65 of file Database_impl.hh.

◆ open()

virtual DatabaseBase& CASM::DB::DatabaseBase::open ( )
pure virtualinherited

◆ prim()

const Structure & CASM::HasPrimClex< CRTPBase< DatabaseBase > >::prim
inherited

Definition at line 19 of file HasPrimClex_impl.hh.

◆ primclex()

const PrimClex& CASM::DB::DatabaseBase::primclex ( ) const
inlineinherited

Definition at line 35 of file Database.hh.

◆ read_aliases()

template<typename ValueType >
void CASM::DB::ValDatabase< ValueType >::read_aliases
protected

Definition at line 106 of file Database_impl.hh.

◆ set_alias()

template<typename ValueType >
std::pair< typename ValDatabase< ValueType >::iterator, bool > CASM::DB::ValDatabase< ValueType >::set_alias ( const std::string &  name_or_alias,
const std::string &  alias 
)

For setting an alias.

Definition at line 17 of file Database_impl.hh.

◆ set_id() [1/2]

template<typename ValueType >
template<typename _ValueType >
void CASM::DB::ValDatabase< ValueType >::set_id ( const _ValueType &  obj,
Index  id 
) const
inlineprotected

Only ValDatabase<ValueType> is allowed to do a const id change.

Definition at line 304 of file Database.hh.

◆ set_id() [2/2]

template<typename ValueType >
template<typename _ValueType >
void CASM::DB::ValDatabase< ValueType >::set_id ( const _ValueType &  obj,
std::string  id 
) const
inlineprotected

Only ValDatabase<ValueType> is allowed to do a const id change.

Definition at line 310 of file Database.hh.

◆ size()

template<typename ValueType >
virtual size_type CASM::DB::ValDatabase< ValueType >::size ( ) const
pure virtual

◆ write_aliases()

template<typename ValueType >
void CASM::DB::ValDatabase< ValueType >::write_aliases
protected

Definition at line 121 of file Database_impl.hh.

Member Data Documentation

◆ m_alias_to_name

template<typename ValueType >
std::map<std::string, std::string> CASM::DB::ValDatabase< ValueType >::m_alias_to_name
private

Definition at line 319 of file Database.hh.

◆ m_master_selection

template<typename ValueType >
Selection<ValueType> CASM::DB::ValDatabase< ValueType >::m_master_selection
private

Definition at line 322 of file Database.hh.

◆ m_name_to_alias

template<typename ValueType >
std::map<std::string, std::string> CASM::DB::ValDatabase< ValueType >::m_name_to_alias
private

Definition at line 316 of file Database.hh.

◆ m_primclex

const PrimClex* CASM::DB::DatabaseBase::m_primclex
privateinherited

Definition at line 38 of file Database.hh.


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