CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 
9  template< typename Base>
10  class HierarchyID;
11  template< typename Derived, typename Base >
12  class DerivedID;
13 
14  template< typename Base >
15  class HierarchyID {
16  protected:
17  static int new_class_ID() {
18  static int Nclass = 0;
19  Base::extend_hierarchy();
20  //std::cout << "Nclass is " << Nclass << '\n';
21  return Nclass++;
22 
23  };
24  };
25 
26  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 
28  template< typename Derived, typename Base >
29  class DerivedID : protected HierarchyID<Base> {
30  protected:
31  //static bool table_empty;
32  static int get_class_ID() {
33  static int ID_val = HierarchyID<Base>:: new_class_ID();
34  static bool table_empty = true;
35  if(table_empty) {
36  table_empty = false;
37  Derived::fill_dispatch_table();
38  }
39  return ID_val;
40  };
41  };
42 
43  /* template< typename Derived, typename Base >
44  bool DerivedID<Derived, Base> :: table_empty(true);
45  */
46 }
47 #endif
static int get_class_ID()
Definition: HierarchyID.hh:32
Main CASM namespace.
Definition: complete.cpp:8
static int new_class_ID()
Definition: HierarchyID.hh:17