Warning, /include/Geant4/tools/sg/bcbk is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_bcbk
0005 #define tools_sg_bcbk
0006
0007 // "cbk" is for callback. Base class to handle a callback.
0008
0009 #ifdef TOOLS_MEM
0010 #include "../mem"
0011 #endif
0012
0013 #include "../scast"
0014 #include "../S_STRING"
0015
0016 #include <string>
0017
0018 namespace tools {
0019 namespace sg {
0020
0021 enum return_action {
0022 return_none,
0023 return_to_render
0024 };
0025
0026 class bcbk {
0027 public:
0028 TOOLS_SCLASS(tools::sg::bcbk)
0029 public:
0030 virtual void* cast(const std::string& a_class) const {
0031 if(void* p = cmp_cast<bcbk>(this,a_class)) {return p;}
0032 return 0;
0033 }
0034 virtual const std::string& s_cls() const {return s_class();}
0035 public:
0036 virtual return_action action() = 0;
0037 virtual bcbk* copy() const = 0;
0038 //virtual bool equal(const bcbk&) const = 0; //it would need the upper cast.
0039 public:
0040 virtual ~bcbk(){
0041 #ifdef TOOLS_MEM
0042 mem::decrement(s_class().c_str());
0043 #endif
0044 }
0045 protected:
0046 bcbk()
0047 :m_single_shoot(false)
0048 ,m_is_valid(true)
0049 {
0050 #ifdef TOOLS_MEM
0051 mem::increment(s_class().c_str());
0052 #endif
0053 }
0054 bcbk(const bcbk& a_from)
0055 :m_single_shoot(a_from.m_single_shoot)
0056 ,m_is_valid(a_from.m_is_valid)
0057 {
0058 #ifdef TOOLS_MEM
0059 mem::increment(s_class().c_str());
0060 #endif
0061 }
0062 bcbk& operator=(const bcbk& a_from){
0063 m_single_shoot = a_from.m_single_shoot;
0064 m_is_valid = a_from.m_is_valid;
0065 return *this;
0066 }
0067 public:
0068 void set_single_shoot(bool a_value) {m_single_shoot = a_value;}
0069 bool is_single_shoot() const {return m_single_shoot;}
0070
0071 bool is_valid() const {return m_is_valid;}
0072 void invalidate() {m_is_valid = false;}
0073 protected:
0074 bool m_single_shoot;
0075 bool m_is_valid;
0076 };
0077
0078 }}
0079
0080 #define TOOLS_CBK(a__class,a__sclass,a__parent)\
0081 private:\
0082 typedef a__parent parent;\
0083 public:\
0084 TOOLS_SCLASS(a__sclass)\
0085 public:\
0086 virtual void* cast(const std::string& a_class) const {\
0087 if(void* p = tools::cmp_cast<a__class>(this,a_class)) return p;\
0088 return parent::cast(a_class);\
0089 }\
0090 virtual const std::string& s_cls() const {return s_class();}\
0091 virtual tools::sg::bcbk* copy() const {return new a__class(*this);}
0092
0093 #define TOOLS_T_CBK(a__T,a__class,a__sclass,a__parent)\
0094 private:\
0095 typedef a__parent parent;\
0096 public:\
0097 TOOLS_T_SCLASS(a__T,a__sclass)\
0098 public:\
0099 virtual void* cast(const std::string& a_class) const {\
0100 if(void* p = tools::cmp_cast<a__class>(this,a_class)) return p;\
0101 return parent::cast(a_class);\
0102 }\
0103 virtual const std::string& s_cls() const {return s_class();}\
0104 virtual tools::sg::bcbk* copy() const {return new a__class(*this);}
0105
0106 #define TOOLS_T2_CBK(a__T1,a__T2,a__class,a__sclass,a__parent)\
0107 private:\
0108 typedef a__parent parent;\
0109 public:\
0110 TOOLS_T2_SCLASS(a__T1,a__T2,a__sclass)\
0111 public:\
0112 virtual void* cast(const std::string& a_class) const {\
0113 if(void* p = tools::cmp_cast<a__class>(this,a_class)) return p;\
0114 return parent::cast(a_class);\
0115 }\
0116 virtual const std::string& s_cls() const {return s_class();}\
0117 virtual tools::sg::bcbk* copy() const {return new a__class(*this);}
0118
0119 #define TOOLS_T3_CBK(a__T1,a__T2,a__T3,a__class,a__sclass,a__parent)\
0120 private:\
0121 typedef a__parent parent;\
0122 public:\
0123 TOOLS_T3_SCLASS(a__T1,a__T2,a__T3,a__sclass)\
0124 public:\
0125 virtual void* cast(const std::string& a_class) const {\
0126 if(void* p = tools::cmp_cast<a__class>(this,a_class)) return p;\
0127 return parent::cast(a_class);\
0128 }\
0129 virtual const std::string& s_cls() const {return s_class();}\
0130 virtual tools::sg::bcbk* copy() const {return new a__class(*this);}
0131
0132 #endif