isa_base.h
Go to the documentation of this file.
1 /*
2  @copyright Russell Standish 2000-2013
3  @author Russell Standish
4  This file is part of Classdesc
5 
6  Open source licensed under the MIT license. See LICENSE for details.
7 */
8 
14 #ifndef ISA_H
15 #define ISA_H
16 #include <typeinfo>
17 #include <set>
18 #include "classdesc.h"
19 
20 namespace classdesc
21 {
23  typedef std::set<const std::type_info*> isa_t;
24 }
25 
26 namespace classdesc_access
27 {
28  template <class T> struct access_isa
29  {
30  void operator()(classdesc::isa_t& t,const classdesc::string& d, T& x) {}
31  };
32 }
33 
34 namespace classdesc
35 {
36  template <class T>
37  void isa(classdesc::isa_t& t,const classdesc::string& d,T& x)
38  {
39  /* descend inheritance heirarchy only */
40  if (d.length()==0)
41  {
42  t.insert(&typeid(x));
44  }
45  }
46 
47  template <class T>
48  void isa(classdesc::isa_t& t,const classdesc::string& d, const T& x)
49  {isa(t,d,const_cast<T&>(x));}
50 
51  template <class T, class U>
52  void isa(classdesc::isa_t& t,const classdesc::string& d, const T& x, const U& y) {}
53 
54  template <class T, class U, class V>
55  //void isa(isa_t& t,classdesc::string d,const T& x, const U& y, const V& z) {}
56  void isa(classdesc::isa_t& t,classdesc::string d,const T& x, const U& y, const V& z,...) {}
57 
58  template <class T>
59  void isa_onbase(isa_t& t, const string& d,T& a)
60  {isa(t,d,a);}
61 }
62 using classdesc::isa;
63 using classdesc::isa_onbase;
64 
68 template <class trialT, class baseT>
69 bool isa(const trialT& x,const baseT& y)
70 {
72  isa(db,classdesc::string(),const_cast<trialT&>(x));
73  return db.count(&typeid(y));
74 }
75 
76 #endif
Definition: isa_base.h:28
std::set< const std::type_info * > isa_t
data structure for storing inheritance relationships
Definition: isa_base.h:23
Contains definitions related to classdesc functionality.
Definition: arrays.h:2514
Contains access_* structs, and nothing else. These structs are used to gain access to private members...
Definition: accessor.h:55