"L. Spiro Engine"
|
00001 00017 #ifndef __LSE_ENTITY_H__ 00018 #define __LSE_ENTITY_H__ 00019 00020 #include "../LSEEngine.h" 00021 #include "LSEEntityTypes.h" 00022 #include "Vector/LSTLVectorPoD.h" 00023 00024 namespace lse { 00025 00033 class CEntity { 00034 public : 00035 // == Various constructors. 00036 LSE_CALLCTOR CEntity(); 00037 virtual LSE_CALLCTOR ~CEntity(); 00038 00039 00040 // == Functions. 00046 virtual LSUINT32 LSE_CALL EntityType() const; 00047 00053 virtual LSVOID LSE_CALL SetEntityParent( CEntity * _peParent ); 00054 00061 virtual LSBOOL LSE_CALL AddEntityChild( CEntity * _peChild ); 00062 00069 virtual LSBOOL LSE_CALL RemEntityChild( CEntity * _peChild ); 00070 00076 LSE_INLINE CEntity * LSE_CALL EntityParent(); 00077 00083 LSE_INLINE const CEntity * LSE_CALL EntityParent() const; 00084 00090 LSE_INLINE CEntity * LSE_CALL EntityGrandFather() const; 00091 00092 00093 protected : 00094 // == Members. 00098 CVectorPoD<CEntity *, LSUINT32> m_vEntityChildren; 00099 00103 CEntity * m_peParent; 00104 00105 00106 private : 00107 // == Functions. 00111 LSVOID LSE_CALL Detach(); 00112 00113 }; 00114 00115 00116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00117 // DEFINITIONS 00118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00119 // == Functions. 00125 LSE_INLINE CEntity * LSE_CALL CEntity::EntityParent() { 00126 return m_peParent; 00127 } 00128 00134 LSE_INLINE const CEntity * LSE_CALL CEntity::EntityParent() const { 00135 return m_peParent; 00136 } 00137 00143 LSE_INLINE CEntity * LSE_CALL CEntity::EntityGrandFather() const { 00144 if ( !m_peParent ) { return NULL; } 00145 CEntity * peThis = m_peParent; 00146 while ( peThis->EntityParent() ) { 00147 peThis = peThis->EntityParent(); 00148 } 00149 return peThis; 00150 } 00151 00152 } // namespace lse 00153 00154 #endif // __LSE_ENTITY_H__