28#ifndef _util_class_class_h
29#define _util_class_class_h
41#include <util/ref/ref.h>
42#include <util/misc/exenv.h>
43#include <util/misc/exception.h>
49typedef ClassDesc* ClassDescP;
50typedef const ClassDesc* CClassDescP;
58 enum Access { Private, Protected, Public };
67 int is_virtual()
const;
68 Access access()
const {
return _access; }
85 void init(
const char*);
88 const ParentClass& parent(
int i)
const {
return *_classes[i]; }
89 ParentClass& operator[](
int i) {
return *_classes[i]; }
90 const ParentClass& operator[](
int i)
const {
return *_classes[i]; }
91 int n()
const {
return _n; }
112 return new T(keyval);
120 return new T(statein);
125 const std::type_info *ti_;
133 const std::type_info* type_info()
const {
return ti_; }
150 static std::map<std::string,ClassDescP> *all_;
151 static std::map<type_info_key,ClassDescP> *type_info_all_;
152 static char * classlib_search_path_;
153 static std::set<std::string> *unresolved_parents_;
158 std::set<std::string> *children_;
162 const std::type_info *ti_;
172 void init(
const char*,
int=1,
const char* p=0,
173 const std::type_info *ti=0,
178 ClassDesc(
const std::type_info&,
const char*,
int=1,
const char* p=0,
184 static std::map<std::string,ClassDescP>& all();
195 const char*
name()
const {
return classname_; }
276 T t =
dynamic_cast<T
>(p);
279 va_start(args,errmsg);
280 fprintf(stderr,
"A required dynamic_cast failed in: ");
281 vfprintf(stderr,errmsg,args);
282 fprintf(stderr,
"\nwanted type \"%s\" but got \"%s\"\n",
297 T t =
dynamic_cast<T
>(p);
300 va_start(args,errmsg);
301 fprintf(stderr,
"A required dynamic_cast failed in: ");
302 vfprintf(stderr,errmsg,args);
303 fprintf(stderr,
"\nwanted type \"%s\" but got \"%s\"\n",
331template <
class T,
class A = const Ref<KeyVal> &>
346std::string::size_type
348 const std::string& str2);
This class is used to contain information about classes.
Definition class.h:147
int version() const
Returns the version number of the class.
Definition class.h:197
static int load_class(const char *classname)
Attempt to dynamically load the shared object file for classname.
static ClassDesc * name_to_class_desc(const char *)
Given the name of the class, return a pointer to the class descriptor.
virtual DescribedClass * create() const
Create an instance of DescribedClass with exact type equal to the class to which this class descripto...
const char * name() const
Returns the name of the class.
Definition class.h:195
static void list_all_classes()
Writes a list of all of the classes to ExEnv::out0().
virtual DescribedClass * create(StateIn &) const
Create an instance of DescribedClass with exact type equal to the class to which this class descripto...
static ClassDesc * class_desc(const std::type_info &)
Given a type_info object return a pointer to the ClassDesc.
DescribedClass * create_described_class() const
This member has been replaced by create().
virtual DescribedClass * create(const Ref< KeyVal > &) 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:233
ClassDesc * class_desc() const MPQC__NOEXCEPT
This returns the unique pointer to the ClassDesc corresponding to the given type_info object.
Ref< DescribedClass > ref()
Return this object wrapped up in a Ref smart pointer.
Definition class.h:251
const char * class_name() const
Return the name of the object's exact type.
int class_version() const
Return the version of the class.
virtual void print(std::ostream &=ExEnv::out0()) const
Print the object.
The ExEnv class is used to find out about how the program is being run.
Definition exenv.h:46
This, together with ForceLink, is used to force code for particular classes to be linked into executa...
Definition class.h:315
This, together with ForceLinkBase, is used to force code for particular classes to be linked into exe...
Definition class.h:332
The KeyVal class is designed to simplify the process of allowing a user to specify keyword/value asso...
Definition keyval.h:69
Gives one parent class of a class.
Definition class.h:56
Gives a list of parent classes of a class.
Definition class.h:75
The base class for all reference counted objects.
Definition ref.h:192
A template class that maintains references counts.
Definition ref.h:361
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
T require_dynamic_cast(DescribedClass *p, const char *errmsg,...)
Attempt to cast a DescribedClass pointer to a DescribedClass descendent.
Definition class.h:274
std::string::size_type string_distance(const std::string &str1, const std::string &str2)
computes DamerauĞLevenshtein distance between two strings
ClassDesc * class_desc()
Return the ClassDesc corresponding to template argument.
Definition class.h:257
DescribedClass * create()
This is used to pass a function that make void constructor calls to the ClassDesc constructor.
Definition class.h:102