32 #ifndef _util_class_class_h
33 #define _util_class_class_h
45 #include <util/ref/ref.h>
46 #include <util/misc/exenv.h>
50 template <
class T,
class C>
70 enum Access { Private, Protected, Public };
79 int is_virtual()
const;
80 Access access()
const {
return _access; }
97 void init(
const char*);
100 const ParentClass& parent(
int i)
const {
return *_classes[i]; }
101 ParentClass& operator[](
int i) {
return *_classes[i]; }
102 const ParentClass& operator[](
int i)
const {
return *_classes[i]; }
103 int n()
const {
return _n; }
122 DescribedClass* create(
const Ref<KeyVal>& keyval)
124 return new T(keyval);
130 DescribedClass* create(StateIn& statein)
132 return new T(statein);
137 const std::type_info *ti_;
161 static std::map<std::string,ClassDescP> *all_;
162 static std::map<type_info_key,ClassDescP> *type_info_all_;
163 static char * classlib_search_path_;
164 static std::set<std::string> *unresolved_parents_;
169 std::set<std::string> *children_;
173 const std::type_info *ti_;
183 void init(
const char*,
int=1,
const char* p=0,
184 const std::type_info *ti=0,
189 ClassDesc(
const std::type_info&,
const char*,
int=1,
const char* p=0,
195 static std::map<std::string,ClassDescP>& all();
206 const char*
name()
const {
return classname_; }
272 class_desc(DescribedClass *d)
281 require_dynamic_cast(DescribedClass*p,
const char * errmsg,...)
283 T t = dynamic_cast<T>(p);
286 va_start(args,errmsg);
287 fprintf(stderr,
"A required dynamic_cast failed in: ");
288 vfprintf(stderr,errmsg,args);
289 fprintf(stderr,
"\nwanted type \"%s\" but got \"%s\"\n",
290 typeid(T).name(),p->class_desc()->name());
302 require_dynamic_cast(
const DescribedClass*p,
const char * errmsg,...)
304 T t = dynamic_cast<T>(p);
307 va_start(args,errmsg);
308 fprintf(stderr,
"A required dynamic_cast failed in: ");
309 vfprintf(stderr,errmsg,args);
310 fprintf(stderr,
"\nwanted type \"%s\" but got \"%s\"\n",
311 typeid(T).name(),p->class_desc()->name());
338 template <
class T,
class A = const Ref<KeyVal> &>
int version() const
Returns the version number of the class.
Definition: class.h:208
Identity gives objects a unique identity and ordering relationship relative to all other objects.
Definition: identity.h:89
The KeyVal class is designed to simplify the process of allowing a user to specify keyword/value asso...
Definition: keyval.h:69
ClassDesc * class_desc() const
This returns the unique pointer to the ClassDesc corresponding to the given type_info object.
A template class that maintains references counts.
Definition: ref.h:332
Gives a list of parent classes of a class.
Definition: class.h:86
This, together with ForceLinkBase, is used to force code for particular classes to be linked into exe...
Definition: class.h:339
Gives one parent class of a class.
Definition: class.h:67
int class_version() const
Return the version of the class.
static ClassDesc * class_desc(const std::type_info &)
Given a type_info object return a pointer to the ClassDesc.
static ClassDesc * name_to_class_desc(const char *)
Given the name of the class, return a pointer to the class descriptor.
Restores objects that derive from SavableState.
Definition: statein.h:70
const char * name() const
Returns the name of the class.
Definition: class.h:206
This class is used to contain information about classes.
Definition: class.h:158
virtual void print(std::ostream &=ExEnv::out0()) const
Print the object.
static int load_class(const char *classname)
Attempt to dynamically load the shared object file for classname.
virtual DescribedClass * create() const
Create an instance of DescribedClass with exact type equal to the class to which this class descripto...
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:244
static std::ostream & out0()
Return an ostream that writes from node 0.
The base class for all reference counted objects.
Definition: ref.h:194
DescribedClass * create_described_class() const
This member has been replaced by create().
static void list_all_classes()
Writes a list of all of the classes to ExEnv::out0().
const char * class_name() const
Return the name of the object's exact type.
This, together with ForceLink, is used to force code for particular classes to be linked into executa...
Definition: class.h:322
Generated at Sun Jan 26 2020 23:33:03 for MPQC
2.3.1 using the documentation package Doxygen
1.8.16.