CASM  1.1.0
A Clusters Approach to Statistical Mechanics
HierarchyID.hh
Go to the documentation of this file.
1 #ifndef IDHIERARCHY_HH
2 #define IDHIERARCHY_HH
3 
4 #include <iostream>
5 
6 namespace CASM {
7 
8 template <typename Base>
9 class HierarchyID;
10 template <typename Derived, typename Base>
11 class DerivedID;
12 
13 template <typename Base>
14 class HierarchyID {
15  protected:
16  static int new_class_ID() {
17  static int Nclass = 0;
18  Base::extend_hierarchy();
19  // std::cout << "Nclass is " << Nclass << '\n';
20  return Nclass++;
21  };
22 };
23 
24 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 
26 template <typename Derived, typename Base>
27 class DerivedID : protected HierarchyID<Base> {
28  protected:
29  // static bool table_empty;
30  static int get_class_ID() {
31  static int ID_val = HierarchyID<Base>::new_class_ID();
32  static bool table_empty = true;
33  if (table_empty) {
34  table_empty = false;
35  Derived::fill_dispatch_table();
36  }
37  return ID_val;
38  };
39 };
40 
41 /* template< typename Derived, typename Base >
42 bool DerivedID<Derived, Base> :: table_empty(true);
43 */
44 } // namespace CASM
45 #endif
static int get_class_ID()
Definition: HierarchyID.hh:30
static int new_class_ID()
Definition: HierarchyID.hh:16
Main CASM namespace.
Definition: APICommand.hh:8