CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymGroupRepID.hh
Go to the documentation of this file.
1 #ifndef SYMGROUPREPID_HH
2 #define SYMGROUPREPID_HH
3 
4 #include <iostream>
5 #include <stdexcept>
6 
8 
9 namespace CASM {
10 
11 class jsonParser;
12 
19 
26  public:
31  SymGroupRepID(Index _group_index, Index _rep_index)
32  : m_group_index(_group_index), m_rep_index(_rep_index) {
33  if (!(valid_index(_group_index) && valid_index(_rep_index))) {
34  throw std::runtime_error(std::string(
35  "SymGroupRepID initialized with out-of-bounds values!\n"));
36  }
37  }
38 
42  SymGroupRepID() : SymGroupRepID(-1, -1, true) {}
43 
47  return SymGroupRepID(-2, dim, true);
48  }
49 
53  Index group_index() const { return m_group_index; }
54 
57  Index rep_index() const { return m_rep_index; }
58 
61  bool is_identity() const { return group_index() == Index(-2); }
62 
65  bool empty() const {
66  return group_index() == Index(-1) || rep_index() == Index(-1);
67  }
68 
70  jsonParser const &from_json(jsonParser const &json);
71 
72  private:
75  SymGroupRepID(Index _group_index, Index _rep_index, bool override)
76  : m_group_index(_group_index), m_rep_index(_rep_index) {}
77 
80 };
81 
83 inline bool operator==(SymGroupRepID const &a, SymGroupRepID const &b) {
84  return a.group_index() == b.group_index() && a.rep_index() == b.rep_index();
85 }
86 
88 inline bool operator!=(SymGroupRepID const &a, SymGroupRepID const &b) {
89  return !(a == b);
90 }
91 
93 inline bool operator<(SymGroupRepID const &a, SymGroupRepID const &b) {
94  return (a.group_index() < b.group_index()) ||
95  (a.group_index() == b.group_index() && a.rep_index() < b.rep_index());
96 }
97 
98 jsonParser &to_json(SymGroupRepID const &_id, jsonParser &json);
99 
100 jsonParser const &from_json(SymGroupRepID &_id, jsonParser const &json);
101 
102 inline std::ostream &operator<<(std::ostream &out, SymGroupRepID const &_id) {
103  out << "{group_index = " << _id.group_index()
104  << ", rep_index = " << _id.rep_index() << "}";
105  return out;
106 }
107 
109 } // namespace CASM
110 #endif
Type-safe ID object for communicating and accessing Symmetry representation info.
Index rep_index() const
Index of SymGroupRep within the master group Used internally to MasterSymGroup to access the correct ...
static SymGroupRepID identity(Index dim)
Static function to construct an ID for identity representations.
Index group_index() const
Index of master group in which the corresponding SymGroupRep is stored Used internally to MasterSymGr...
bool empty() const
Returns true if SymGroupRepID has not been initialized with valid group_index or rep_index.
jsonParser const & from_json(jsonParser const &json)
Output internal state to JSON.
Definition: SymGroupRepID.cc:8
SymGroupRepID(Index _group_index, Index _rep_index)
Construct from group index (i.e., MasterSymGroup::group_index()) and representation index This constr...
bool is_identity() const
Returns true if SymGroupRepID corresponds to an Identity representation.
SymGroupRepID(Index _group_index, Index _rep_index, bool override)
SymGroupRepID()
Default constructor initializes group_index and rep_index as out-of-bounds SymGroupRepID::empty() ret...
Main CASM namespace.
Definition: APICommand.hh:8
std::ostream & operator<<(std::ostream &_stream, const FormattedPrintable &_formatted)
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
bool operator!=(DoFSet const &A, DoFSet const &B)
Definition: DoFSet.hh:320
bool operator<(const ClexDescription &A, const ClexDescription &B)
Compare using name strings: A.name < B.name.
void from_json(ClexDescription &desc, const jsonParser &json)
bool operator==(DoFSet const &A, DoFSet const &B)
Definition: DoFSet.hh:314
bool valid_index(Index i)
Definition: definitions.cc:5
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39