EntityClass.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef SE_INCL_ENTITYCLASS_H
  13. #define SE_INCL_ENTITYCLASS_H
  14. #ifdef PRAGMA_ONCE
  15. #pragma once
  16. #endif
  17. #include <Engine/Base/Serial.h>
  18. #include <Engine/Entities/Entity.h>
  19. #include <Engine/Entities/EntityProperties.h> /* rcg10042001 */
  20. /*
  21. * General structure of an entity class.
  22. */
  23. class ENGINE_API CEntityClass : public CSerial {
  24. public:
  25. /* Obtain all components from component table. */
  26. void ObtainComponents_t(void); // throw char *
  27. /* Release all components from component table. */
  28. void ReleaseComponents(void);
  29. public:
  30. CTFileName ec_fnmClassDLL; // filename of the DLL with the class
  31. HINSTANCE ec_hiClassDLL; // handle to the DLL with the class
  32. class CDLLEntityClass *ec_pdecDLLClass; // pointer to DLL class in the DLL
  33. /* Default constructor. */
  34. CEntityClass(void);
  35. /* Constructor for a fixed class. */
  36. CEntityClass(class CDLLEntityClass *pdecDLLClass);
  37. /* Destructor. */
  38. ~CEntityClass(void);
  39. /* Clear the object. */
  40. void Clear(void);
  41. // reference counting functions
  42. void AddReference(void);
  43. void RemReference(void);
  44. /* Check that all properties have been properly declared. */
  45. void CheckClassProperties(void);
  46. /* Construct a new member of the class. */
  47. class CEntity *New(void);
  48. /* Get pointer to entity property from its name. */
  49. class CEntityProperty *PropertyForName(const CTString &strPropertyName);
  50. /* Get pointer to entity property from its packed identifier. */
  51. class CEntityProperty *PropertyForTypeAndID(ULONG ulType, ULONG ulID);
  52. /* Get event handler for given state and event code. */
  53. CEntity::pEventHandler HandlerForStateAndEvent(SLONG slState, SLONG slEvent);
  54. /* Get pointer to component from its type and identifier. */
  55. class CEntityComponent *ComponentForTypeAndID(enum EntityComponentType ectType, SLONG slID);
  56. /* Get pointer to component from the component. */
  57. class CEntityComponent *ComponentForPointer(void *pv);
  58. // overrides from CSerial
  59. /* Read from stream. */
  60. virtual void Read_t( CTStream *istr); // throw char *
  61. /* Write to stream. */
  62. virtual void Write_t( CTStream *ostr); // throw char *
  63. // get amount of memory used by this object
  64. SLONG GetUsedMemory(void);
  65. // check if this kind of objects is auto-freed
  66. BOOL IsAutoFreed(void);
  67. // gather the CRC of the file
  68. void AddToCRCTable(void);
  69. };
  70. #endif /* include-once check. */