Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_scast 4 #ifndef tools_scast 5 #define tools_scast 5 #define tools_scast 6 6 7 // For implementations of cast methods. 7 // For implementations of cast methods. 8 8 9 #include "safe_cast" 9 #include "safe_cast" 10 #include "rcmp" 10 #include "rcmp" 11 11 12 namespace tools { 12 namespace tools { 13 13 14 template <class TO> 14 template <class TO> 15 inline void* cmp_cast(const TO* a_this,const s 15 inline void* cmp_cast(const TO* a_this,const std::string& a_class) { 16 if(!rcmp(a_class,TO::s_class())) return 0; 16 if(!rcmp(a_class,TO::s_class())) return 0; 17 return (void*)static_cast<const TO*>(a_this) 17 return (void*)static_cast<const TO*>(a_this); 18 } 18 } 19 19 20 template <class TO> 20 template <class TO> 21 inline void* cmp_cast(const TO* a_this,cid a_i 21 inline void* cmp_cast(const TO* a_this,cid a_id) { 22 if(TO::id_class()!=a_id) return 0; 22 if(TO::id_class()!=a_id) return 0; 23 return (void*)static_cast<const TO*>(a_this) 23 return (void*)static_cast<const TO*>(a_this); 24 } 24 } 25 25 26 } 26 } 27 27 28 #endif 28 #endif