CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::DB::Selection< ObjType > Class Template Reference

#include <Selection.hh>

Detailed Description

template<typename ObjType>
class CASM::DB::Selection< ObjType >

Provides a means of selecting and iterating over a subset of objects in a database

  • Stores a std::map of ObjType name_or_alias -> bool (true if selected)
  • Provides iterators over either all objects in list, or only selected objects
  • All iterators provide const references to ObjType
  • ObjType must have:

Definition at line 113 of file Selection.hh.

Classes

struct  Compare
 

Public Types

typedef std::map< std::string, bool, Comparemap_type
 
typedef map_type::iterator base_iterator
 
typedef map_type::const_iterator base_const_iterator
 
typedef SelectionIterator< ObjType, base_iteratoriterator
 
typedef SelectionIterator< ObjType, base_const_iteratorconst_iterator
 
typedef Index size_type
 

Public Member Functions

 Selection ()
 Default construct into invalid state. More...
 
 Selection (const PrimClex &_primclex, fs::path selection_path="MASTER")
 Use default ObjType database. More...
 
 Selection (Database< ObjType > &_db, fs::path selection_path="MASTER")
 Use specified ObjType database. More...
 
const PrimClexprimclex () const
 
Database< ObjType > & db () const
 
boost::iterator_range< iteratorall ()
 
boost::iterator_range< const_iteratorall () const
 
boost::iterator_range< iteratorselected ()
 
boost::iterator_range< const_iteratorselected () const
 
map_typedata ()
 
const map_typedata () const
 
Index size () const
 
Index selected_size () const
 
const std::vector< std::string > & col_headers () const
 
const std::string & name () const
 
bool is_selected (const std::string &name_or_alias) const
 True if obj is in Selection and is selected; false otherwise. More...
 
void set (const DataFormatterDictionary< ObjType > &dict, const std::string &criteria)
 Set selected objects to value of criteria. More...
 
void set (const DataFormatterDictionary< ObjType > &dict, const std::string &criteria, bool selected)
 Set selected objects to value, if criteria true. More...
 
void read (std::istream &_input)
 Read csv selection from stream. More...
 
void print (const DataFormatterDictionary< ObjType > &_dict, std::ostream &_out, bool only_selected=false) const
 Print csv selection to stream. More...
 
const jsonParserfrom_json (const jsonParser &_json)
 Read selection from JSON. More...
 
jsonParserto_json (const DataFormatterDictionary< ObjType > &_dict, jsonParser &_json, bool only_selected=false) const
 Write selection to JSON. More...
 
void write (const DataFormatterDictionary< ObjType > &dict, const fs::path &out_path, bool write_json, bool only_selected) const
 Write selection to file – will overwrite. More...
 

Private Attributes

Database< ObjType > * m_db
 
const PrimClexm_primclex
 
map_type m_data
 
std::vector< std::string > m_col_headers
 
std::string m_name
 

Member Typedef Documentation

◆ base_const_iterator

template<typename ObjType >
typedef map_type::const_iterator CASM::DB::Selection< ObjType >::base_const_iterator

Definition at line 123 of file Selection.hh.

◆ base_iterator

template<typename ObjType >
typedef map_type::iterator CASM::DB::Selection< ObjType >::base_iterator

Definition at line 122 of file Selection.hh.

◆ const_iterator

template<typename ObjType >
typedef SelectionIterator<ObjType, base_const_iterator> CASM::DB::Selection< ObjType >::const_iterator

Definition at line 125 of file Selection.hh.

◆ iterator

template<typename ObjType >
typedef SelectionIterator<ObjType, base_iterator> CASM::DB::Selection< ObjType >::iterator

Definition at line 124 of file Selection.hh.

◆ map_type

template<typename ObjType >
typedef std::map<std::string, bool, Compare> CASM::DB::Selection< ObjType >::map_type

Definition at line 121 of file Selection.hh.

◆ size_type

template<typename ObjType >
typedef Index CASM::DB::Selection< ObjType >::size_type

Definition at line 126 of file Selection.hh.

Constructor & Destructor Documentation

◆ Selection() [1/3]

template<typename ObjType >
CASM::DB::Selection< ObjType >::Selection

Default construct into invalid state.

Definition at line 139 of file Selection.cc.

◆ Selection() [2/3]

template<typename ObjType >
CASM::DB::Selection< ObjType >::Selection ( const PrimClex _primclex,
fs::path  selection_path = "MASTER" 
)

Use default ObjType database.

Definition at line 143 of file Selection.cc.

◆ Selection() [3/3]

template<typename ObjType >
CASM::DB::Selection< ObjType >::Selection ( Database< ObjType > &  _db,
fs::path  selection_path = "MASTER" 
)

Use specified ObjType database.

Definition at line 148 of file Selection.cc.

Member Function Documentation

◆ all() [1/2]

template<typename ObjType >
boost::iterator_range< typename Selection< ObjType >::iterator > CASM::DB::Selection< ObjType >::all

Definition at line 222 of file Selection.cc.

◆ all() [2/2]

template<typename ObjType >
boost::iterator_range< typename Selection< ObjType >::const_iterator > CASM::DB::Selection< ObjType >::all

Definition at line 229 of file Selection.cc.

◆ col_headers()

template<typename ObjType >
const std::vector< std::string > & CASM::DB::Selection< ObjType >::col_headers

Definition at line 265 of file Selection.cc.

◆ data() [1/2]

template<typename ObjType >
Selection< ObjType >::map_type & CASM::DB::Selection< ObjType >::data

Definition at line 250 of file Selection.cc.

◆ data() [2/2]

template<typename ObjType >
const Selection< ObjType >::map_type & CASM::DB::Selection< ObjType >::data

Definition at line 255 of file Selection.cc.

◆ db()

template<typename ObjType >
Database< ObjType > & CASM::DB::Selection< ObjType >::db

Definition at line 212 of file Selection.cc.

◆ from_json()

template<typename ObjType >
const jsonParser & CASM::DB::Selection< ObjType >::from_json ( const jsonParser _json)

Read selection from JSON.

Definition at line 393 of file Selection.cc.

◆ is_selected()

template<typename ObjType >
bool CASM::DB::Selection< ObjType >::is_selected ( const std::string &  name_or_alias) const

True if obj is in Selection and is selected; false otherwise.

Definition at line 281 of file Selection.cc.

◆ name()

template<typename ObjType >
const std::string & CASM::DB::Selection< ObjType >::name

Definition at line 270 of file Selection.cc.

◆ primclex()

template<typename ObjType >
const PrimClex & CASM::DB::Selection< ObjType >::primclex

Definition at line 207 of file Selection.cc.

◆ print()

template<typename ObjType >
void CASM::DB::Selection< ObjType >::print ( const DataFormatterDictionary< ObjType > &  _dict,
std::ostream &  _out,
bool  only_selected = false 
) const

Print csv selection to stream.

Definition at line 470 of file Selection.cc.

◆ read()

template<typename ObjType >
void CASM::DB::Selection< ObjType >::read ( std::istream &  _input)

Read csv selection from stream.

Definition at line 365 of file Selection.cc.

◆ selected() [1/2]

template<typename ObjType >
boost::iterator_range< typename Selection< ObjType >::iterator > CASM::DB::Selection< ObjType >::selected

Definition at line 237 of file Selection.cc.

◆ selected() [2/2]

template<typename ObjType >
boost::iterator_range< typename Selection< ObjType >::const_iterator > CASM::DB::Selection< ObjType >::selected

Definition at line 244 of file Selection.cc.

◆ selected_size()

template<typename ObjType >
Index CASM::DB::Selection< ObjType >::selected_size

Definition at line 275 of file Selection.cc.

◆ set() [1/2]

template<typename ObjType >
void CASM::DB::Selection< ObjType >::set ( const DataFormatterDictionary< ObjType > &  dict,
const std::string &  criteria 
)

Set selected objects to value of criteria.

Definition at line 291 of file Selection.cc.

◆ set() [2/2]

template<typename ObjType >
void CASM::DB::Selection< ObjType >::set ( const DataFormatterDictionary< ObjType > &  dict,
const std::string &  criteria,
bool  selected 
)

Set selected objects to value, if criteria true.

Definition at line 322 of file Selection.cc.

◆ size()

template<typename ObjType >
Index CASM::DB::Selection< ObjType >::size

Definition at line 260 of file Selection.cc.

◆ to_json()

template<typename ObjType >
jsonParser & CASM::DB::Selection< ObjType >::to_json ( const DataFormatterDictionary< ObjType > &  _dict,
jsonParser _json,
bool  only_selected = false 
) const

Write selection to JSON.

Definition at line 448 of file Selection.cc.

◆ write()

template<typename ObjType >
void CASM::DB::Selection< ObjType >::write ( const DataFormatterDictionary< ObjType > &  dict,
const fs::path &  out_path,
bool  write_json,
bool  only_selected 
) const

Write selection to file – will overwrite.

Definition at line 487 of file Selection.cc.

Member Data Documentation

◆ m_col_headers

template<typename ObjType >
std::vector<std::string> CASM::DB::Selection< ObjType >::m_col_headers
private

Definition at line 194 of file Selection.hh.

◆ m_data

template<typename ObjType >
map_type CASM::DB::Selection< ObjType >::m_data
private

Definition at line 192 of file Selection.hh.

◆ m_db

template<typename ObjType >
Database<ObjType>* CASM::DB::Selection< ObjType >::m_db
private

Definition at line 187 of file Selection.hh.

◆ m_name

template<typename ObjType >
std::string CASM::DB::Selection< ObjType >::m_name
private

Definition at line 195 of file Selection.hh.

◆ m_primclex

template<typename ObjType >
const PrimClex* CASM::DB::Selection< ObjType >::m_primclex
private

Definition at line 188 of file Selection.hh.


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