LIBINT  2.1.0-stable
class_registry.h
1 /*
2  * This file is a part of Libint.
3  * Copyright (C) 2004-2014 Edward F. Valeev
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see http://www.gnu.org/licenses/.
17  *
18  */
19 
20 #ifndef _libint2_src_bin_libint_classregistry_h_
21 #define _libint2_src_bin_libint_classregistry_h_
22 
23 #include <key.h>
24 
25 namespace libint2 {
26 
28  class ClassRegistry {
29  public:
30  typedef KeyTypes::ClassID ClassID;
31  static ClassRegistry& Instance();
32  ClassID next_id() { return nclasses_++; }
33 
34  private:
35  ClassRegistry();
36  static ClassRegistry* registry_;
37  ClassID nclasses_;
38  };
39 
43  template <typename T> class ClassInfo {
44  public:
45  typedef ClassRegistry::ClassID ClassID;
46 
47  static ClassInfo& Instance()
48  {
49  if (!info_)
50  info_ = new ClassInfo;
51  return *info_;
52  }
53 
54  ~ClassInfo()
55  {
56  }
57 
58  ClassID id() const { return id_; }
59 
60  private:
61  ClassInfo() :
62  id_(ClassRegistry::Instance().next_id())
63  {
64  }
65 
66  static ClassInfo* info_;
67  ClassID id_;
68  };
69 
70  template <typename T>
73 
74 };
75 
76 #endif
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
unsigned int ClassID
distinct classes have unique ClassID&#39;s
Definition: key.h:78
Objects of this type provide limited information about the class at runtime.
Definition: class_registry.h:43
This is a unique registry of classes.
Definition: class_registry.h:28