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; }
124 return new T(keyval);
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();
199 static void list_all_classes();
202 static ClassDesc* name_to_class_desc(
const char*);
204 static ClassDesc *class_desc(
const std::type_info &);
206 const char*
name()
const {
return classname_; }
234 static int load_class(
const char* classname);
254 const char* class_name()
const;
256 int class_version()
const;
258 virtual void print(std::ostream& =
ExEnv::out0())
const;
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",
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",
338 template <
class T,
class A = const Ref<KeyVal> &>
Gives a list of parent classes of a class.
Definition: class.h:86
ClassDesc * class_desc() const
This returns the unique pointer to the ClassDesc corresponding to the given type_info object...
static ClassDesc * class_desc(const std::type_info &)
Given a type_info object return a pointer to the ClassDesc.
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:244
This, together with ForceLink, is used to force code for particular classes to be linked into executa...
Definition: class.h:322
Gives one parent class of a class.
Definition: class.h:67
The base class for all reference counted objects.
Definition: ref.h:194
A template class that maintains references counts.
Definition: ref.h:332
This, together with ForceLinkBase, is used to force code for particular classes to be linked into exe...
Definition: class.h:339
Restores objects that derive from SavableState.
Definition: statein.h:70
Identity gives objects a unique identity and ordering relationship relative to all other objects...
Definition: identity.h:89
This class is used to contain information about classes.
Definition: class.h:158
const char * name() const
Returns the name of the class.
Definition: class.h:206
static std::ostream & out0()
Return an ostream that writes from node 0.
int version() const
Returns the version number of the class.
Definition: class.h:208
The KeyVal class is designed to simplify the process of allowing a user to specify keyword/value asso...
Definition: keyval.h:69