Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_sg_bcbk 5 #define tools_sg_bcbk 6 7 // "cbk" is for callback. Base class to handle 8 9 #ifdef TOOLS_MEM 10 #include "../mem" 11 #endif 12 13 #include "../scast" 14 #include "../S_STRING" 15 16 #include <string> 17 18 namespace tools { 19 namespace sg { 20 21 enum return_action { 22 return_none, 23 return_to_render 24 }; 25 26 class bcbk { 27 public: 28 TOOLS_SCLASS(tools::sg::bcbk) 29 public: 30 virtual void* cast(const std::string& a_clas 31 if(void* p = cmp_cast<bcbk>(this,a_class)) 32 return 0; 33 } 34 virtual const std::string& s_cls() const {re 35 public: 36 virtual return_action action() = 0; 37 virtual bcbk* copy() const = 0; 38 //virtual bool equal(const bcbk&) const = 0; 39 public: 40 virtual ~bcbk(){ 41 #ifdef TOOLS_MEM 42 mem::decrement(s_class().c_str()); 43 #endif 44 } 45 protected: 46 bcbk() 47 :m_single_shoot(false) 48 ,m_is_valid(true) 49 { 50 #ifdef TOOLS_MEM 51 mem::increment(s_class().c_str()); 52 #endif 53 } 54 bcbk(const bcbk& a_from) 55 :m_single_shoot(a_from.m_single_shoot) 56 ,m_is_valid(a_from.m_is_valid) 57 { 58 #ifdef TOOLS_MEM 59 mem::increment(s_class().c_str()); 60 #endif 61 } 62 bcbk& operator=(const bcbk& a_from){ 63 m_single_shoot = a_from.m_single_shoot; 64 m_is_valid = a_from.m_is_valid; 65 return *this; 66 } 67 public: 68 void set_single_shoot(bool a_value) {m_singl 69 bool is_single_shoot() const {return m_singl 70 71 bool is_valid() const {return m_is_valid;} 72 void invalidate() {m_is_valid = false;} 73 protected: 74 bool m_single_shoot; 75 bool m_is_valid; 76 }; 77 78 }} 79 80 #define TOOLS_CBK(a__class,a__sclass,a__parent 81 private:\ 82 typedef a__parent parent;\ 83 public:\ 84 TOOLS_SCLASS(a__sclass)\ 85 public:\ 86 virtual void* cast(const std::string& a_clas 87 if(void* p = tools::cmp_cast<a__class>(thi 88 return parent::cast(a_class);\ 89 }\ 90 virtual const std::string& s_cls() const {re 91 virtual tools::sg::bcbk* copy() const {retur 92 93 #define TOOLS_T_CBK(a__T,a__class,a__sclass,a_ 94 private:\ 95 typedef a__parent parent;\ 96 public:\ 97 TOOLS_T_SCLASS(a__T,a__sclass)\ 98 public:\ 99 virtual void* cast(const std::string& a_clas 100 if(void* p = tools::cmp_cast<a__class>(thi 101 return parent::cast(a_class);\ 102 }\ 103 virtual const std::string& s_cls() const {re 104 virtual tools::sg::bcbk* copy() const {retur 105 106 #define TOOLS_T2_CBK(a__T1,a__T2,a__class,a__s 107 private:\ 108 typedef a__parent parent;\ 109 public:\ 110 TOOLS_T2_SCLASS(a__T1,a__T2,a__sclass)\ 111 public:\ 112 virtual void* cast(const std::string& a_clas 113 if(void* p = tools::cmp_cast<a__class>(thi 114 return parent::cast(a_class);\ 115 }\ 116 virtual const std::string& s_cls() const {re 117 virtual tools::sg::bcbk* copy() const {retur 118 119 #define TOOLS_T3_CBK(a__T1,a__T2,a__T3,a__clas 120 private:\ 121 typedef a__parent parent;\ 122 public:\ 123 TOOLS_T3_SCLASS(a__T1,a__T2,a__T3,a__sclass) 124 public:\ 125 virtual void* cast(const std::string& a_clas 126 if(void* p = tools::cmp_cast<a__class>(thi 127 return parent::cast(a_class);\ 128 }\ 129 virtual const std::string& s_cls() const {re 130 virtual tools::sg::bcbk* copy() const {retur 131 132 #endif