IUserData.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This file is part of the "Irrlicht Engine".
  2. // For conditions of distribution and use, see copyright notice in irrlicht.h
  3. #ifndef IRR_I_USER_DATA_H_INCLUDED
  4. #define IRR_I_USER_DATA_H_INCLUDED
  5. #include "irrTypes.h"
  6. namespace irr
  7. {
  8. namespace io
  9. {
  10. class IAttributes;
  11. struct SAttributeReadWriteOptions;
  12. //! Irrlicht may allow users to set their own data via those pointers
  13. //! Irrlicht has no memory control over IUserData, the user is completely responsible for that
  14. class IUserData
  15. {
  16. public:
  17. //! To identify the class type.
  18. //! You can for example use MAKE_IRR_ID to create four CC codes
  19. virtual irr::u32 getType() const { return 0; }
  20. //! To be overloaded if comparisons matter
  21. //! You can then cast other to your derived class
  22. virtual bool compare(const IUserData& other) const
  23. {
  24. return getType() == other.getType();
  25. }
  26. //! Used internally by Irrlicht to check if data has changed
  27. bool operator!=(const IUserData& other) const
  28. {
  29. return !compare(other);
  30. }
  31. protected:
  32. // Irrlicht is never allowed to delete this
  33. // If users want to delete such objects they should go over derived classes
  34. ~IUserData() {}
  35. };
  36. } // end namespace io
  37. } // end namespace irr
  38. #endif // IRR_I_USER_DATA_H_INCLUDED