Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -12,12 +12,19 @@
|
||||
#include "../mem"
|
||||
#endif
|
||||
|
||||
#define TOOLS_SG_EVENT_ID_CAST
|
||||
|
||||
namespace tools {
|
||||
namespace sg {
|
||||
|
||||
class event {
|
||||
public:
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
static cid id_class() {return 0;}
|
||||
virtual void* cast(cid) const = 0;
|
||||
#else
|
||||
virtual void* cast(const std::string&) const = 0;
|
||||
#endif
|
||||
virtual event* copy() const = 0;
|
||||
public:
|
||||
#ifdef TOOLS_MEM
|
||||
@@ -44,12 +51,21 @@ public:
|
||||
};
|
||||
|
||||
class size_event : public event {
|
||||
typedef event parent;
|
||||
public:
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
static cid id_class() {return parent::id_class()+1;}
|
||||
virtual void* cast(cid a_class) const {
|
||||
if(void* p = cmp_cast<size_event>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
TOOLS_SCLASS(tools::sg::size_event)
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = cmp_cast<size_event>(this,a_class)) {return p;}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
virtual event* copy() const {return new size_event(*this);}
|
||||
public:
|
||||
size_event(unsigned int a_ow,unsigned int a_oh,
|
||||
@@ -89,12 +105,21 @@ protected:
|
||||
};
|
||||
|
||||
class down_event : public event {
|
||||
typedef event parent;
|
||||
public:
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
static cid id_class() {return parent::id_class()+2;}
|
||||
virtual void* cast(cid a_class) const {
|
||||
if(void* p = cmp_cast<down_event>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
TOOLS_SCLASS(tools::sg::down_event)
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = cmp_cast<down_event>(this,a_class)) {return p;}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
virtual event* copy() const {return new down_event(*this);}
|
||||
public:
|
||||
down_event(int a_x,int a_y) //signed because of wall.
|
||||
@@ -123,12 +148,21 @@ protected:
|
||||
};
|
||||
|
||||
class up_event : public event {
|
||||
typedef event parent;
|
||||
public:
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
static cid id_class() {return parent::id_class()+3;}
|
||||
virtual void* cast(cid a_class) const {
|
||||
if(void* p = cmp_cast<up_event>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
TOOLS_SCLASS(tools::sg::up_event)
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = cmp_cast<up_event>(this,a_class)) {return p;}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
virtual event* copy() const {return new up_event(*this);}
|
||||
public:
|
||||
up_event(int a_x,int a_y) //signed because of wall.
|
||||
@@ -157,12 +191,21 @@ protected:
|
||||
};
|
||||
|
||||
class move_event : public event {
|
||||
typedef event parent;
|
||||
public:
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
static cid id_class() {return parent::id_class()+4;}
|
||||
virtual void* cast(cid a_class) const {
|
||||
if(void* p = cmp_cast<move_event>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
TOOLS_SCLASS(tools::sg::move_event)
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = cmp_cast<move_event>(this,a_class)) {return p;}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
virtual event* copy() const {return new move_event(*this);}
|
||||
public:
|
||||
move_event(int a_x,int a_y, //signed because of wall.
|
||||
@@ -211,12 +254,21 @@ protected:
|
||||
};
|
||||
|
||||
class anim_event : public event {
|
||||
typedef event parent;
|
||||
public:
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
static cid id_class() {return parent::id_class()+5;}
|
||||
virtual void* cast(cid a_class) const {
|
||||
if(void* p = cmp_cast<anim_event>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
TOOLS_SCLASS(tools::sg::anim_event)
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = cmp_cast<anim_event>(this,a_class)) {return p;}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
virtual event* copy() const {return new anim_event(*this);}
|
||||
public:
|
||||
typedef uint64 num_t;
|
||||
@@ -257,16 +309,24 @@ protected:
|
||||
bool m_some_found;
|
||||
};
|
||||
|
||||
#ifdef TOOLS_SG_EVENT_ID_CAST
|
||||
template <class FROM,class TO> inline TO* event_cast(FROM& a_o) {return id_cast<FROM,TO>(a_o);}
|
||||
template <class FROM,class TO> inline const TO* event_cast(const FROM& a_o) {return id_cast<FROM,TO>(a_o);}
|
||||
#else
|
||||
template <class FROM,class TO> inline TO* event_cast(FROM& a_o) {return safe_cast<FROM,TO>(a_o);}
|
||||
template <class FROM,class TO> inline const TO* event_cast(const FROM& a_o) {return safe_cast<FROM,TO>(a_o);}
|
||||
#endif
|
||||
|
||||
inline bool get_event_xy(const sg::event& a_event,int& a_x,int& a_y) {
|
||||
typedef sg::event evt_t;
|
||||
typedef sg::up_event up_evt_t;
|
||||
typedef sg::down_event dn_evt_t;
|
||||
if(const dn_evt_t* devt = safe_cast<evt_t,dn_evt_t>(a_event)) {
|
||||
if(const dn_evt_t* devt = event_cast<evt_t,dn_evt_t>(a_event)) {
|
||||
a_x = devt->x();
|
||||
a_y = devt->y();
|
||||
return true;
|
||||
|
||||
} else if(const up_evt_t* uevt = safe_cast<evt_t,up_evt_t>(a_event)) {
|
||||
} else if(const up_evt_t* uevt = event_cast<evt_t,up_evt_t>(a_event)) {
|
||||
a_x = uevt->x();
|
||||
a_y = uevt->y();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user