5 #include <boost/iterator/iterator_facade.hpp>
21 template <
typename ObjType>
41 template <
typename ValueType>
80 template <
typename ValueType>
91 virtual std::string
name()
const = 0;
93 std::unique_ptr<DatabaseIteratorBase>
clone()
const {
94 return std::unique_ptr<DatabaseIteratorBase>(this->
_clone());
146 template <
typename ValueType>
149 public boost::iterator_facade<DatabaseIterator<ValueType>, ValueType,
150 std::forward_iterator_tag, const ValueType &,
165 friend boost::iterator_core_access;
220 template <
typename ValueType>
239 std::pair<iterator, bool>
set_alias(
const std::string &name_or_alias,
240 const std::string &
alias);
247 std::string
name(
const std::string &name_or_alias)
const;
250 std::string
alias(
const std::string &name_or_alias)
const;
252 virtual std::pair<iterator, bool>
insert(
const ValueType &obj) = 0;
253 virtual std::pair<iterator, bool>
insert(
const ValueType &&obj) = 0;
255 template <
typename InputIt>
256 void insert(InputIt first, InputIt last) {
257 std::for_each(first, last,
258 [&](
const ValueType &obj) { this->
insert(obj); });
269 if (this->
find(name_or_alias) != this->
end()) {
275 virtual iterator
find(
const std::string &name_or_alias)
const = 0;
297 template <
typename _ValueType>
303 template <
typename _ValueType>
309 template <
typename _ValueType>
310 void set_id(
const _ValueType &obj, std::string
id)
const {
325 template <
typename ValueType>
Fully generic database interface for use by DatabaseHandler.
DatabaseBase(const PrimClex &_primclex)
const PrimClex & primclex() const
const PrimClex * m_primclex
virtual DatabaseBase & open()=0
std::unique_ptr< DatabaseIteratorBase > clone() const
virtual ~DatabaseIteratorBase()
virtual DatabaseIteratorBase * _clone() const =0
virtual std::string name() const =0
virtual void increment()=0
virtual bool equal(const DatabaseIteratorBase< ValueType > &other) const =0
const value_type & reference
virtual reference dereference() const =0
Wrapper class for specializations DatabaseIteratorBase.
const ValueType & dereference() const
boost::iterator_facade implementation
bool equal(const DatabaseIterator &B) const
boost::iterator_facade implementation
notstd::cloneable_ptr< DatabaseIteratorBase< ValueType > > m_ptr
void increment()
boost::iterator_facade implementation
DatabaseIterator(const DatabaseIteratorBase< ValueType > &it)
Construct iterator.
DatabaseIteratorBase< ValueType > * get() const
DatabaseIterator()
Default constructor.
Generic interface for database of a particular CASM type.
virtual iterator end() const =0
virtual size_type size() const =0
size_type erase(const std::string &name_or_alias)
std::string name(const std::string &name_or_alias) const
void set_id(const _ValueType &obj, std::string id) const
Only ValDatabase<ValueType> is allowed to do a const id change.
virtual iterator begin() const =0
std::string alias(const std::string &name_or_alias) const
Get alias from name_or_alias.
std::map< std::string, std::string > m_alias_to_name
std::map< std::string, std::string > m_name_to_alias
std::pair< iterator, bool > set_alias(const std::string &name_or_alias, const std::string &alias)
For setting an alias.
void set_id(const _ValueType &obj, Index id) const
Only ValDatabase<ValueType> is allowed to do a const id change.
Selection< ValueType > & master_selection()
Selection< ValueType > m_master_selection
void clear_name(const _ValueType &obj) const
Only ValDatabase<ValueType> is allowed to do clear_name.
const Selection< ValueType > & master_selection() const
size_type erase(const ValueType &obj)
virtual iterator find(const std::string &name_or_alias) const =0
DatabaseIterator< ValueType > iterator
virtual std::pair< iterator, bool > insert(const ValueType &obj)=0
virtual iterator erase(iterator pos)=0
ValDatabase(const PrimClex &_primclex)
virtual size_type count(const std::string &name_or_alias) const
virtual std::pair< iterator, bool > insert(const ValueType &&obj)=0
void insert(InputIt first, InputIt last)
Implements PrimClex dependent functions.
PrimClex is the top-level data structure for a CASM project.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
INDEX_TYPE Index
For long integer indexing:
Non-std smart pointer classes and functions.
std::unique_ptr< T > clone(const T &obj)