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>
49 typedef ClassDesc* ClassDescP;
50 typedef 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",
331 template <
class T,
class A = const Ref<KeyVal> &>
346 std::string::size_type
348 const std::string& str2);
int version() const
Returns the version number of the class.
Definition: class.h:197
A template class that maintains references counts.
Definition: ref.h:361
Gives a list of parent classes of a class.
Definition: class.h:74
This, together with ForceLinkBase, is used to force code for particular classes to be linked into exe...
Definition: class.h:332
Gives one parent class of a class.
Definition: class.h:55
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.
DescribedClass * create()
This is used to pass a function that make void constructor calls to the ClassDesc constructor.
Definition: class.h:102
static ClassDesc * name_to_class_desc(const char *)
Given the name of the class, return a pointer to the class descriptor.
const char * name() const
Returns the name of the class.
Definition: class.h:195
This class is used to contain information about classes.
Definition: class.h:147
std::string::size_type string_distance(const std::string &str1, const std::string &str2)
computes DamerauĞLevenshtein distance between two strings
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.
ClassDesc * class_desc()
Return the ClassDesc corresponding to template argument.
Definition: class.h:257
ClassDesc * class_desc() const MPQC__NOEXCEPT
This returns the unique pointer to the ClassDesc corresponding to the given type_info object.
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:233
static std::ostream & out0()
Return an ostream that writes from node 0.
The base class for all reference counted objects.
Definition: ref.h:192
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().
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.
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
This, together with ForceLink, is used to force code for particular classes to be linked into executa...
Definition: class.h:315
Generated at Sun Jan 26 2020 23:24:01 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.