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