ISceneUserDataSerializer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED
  5. #define IRR_I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED
  6. namespace irr
  7. {
  8. namespace io
  9. {
  10. class IAttributes;
  11. } // end namespace io
  12. namespace scene
  13. {
  14. class ISceneNode;
  15. //! Interface to read and write user data to and from .irr files.
  16. /** This interface is to be implemented by the user, to make it possible to read
  17. and write user data when reading or writing .irr files via ISceneManager.
  18. To be used with ISceneManager::loadScene() and ISceneManager::saveScene() */
  19. class ISceneUserDataSerializer
  20. {
  21. public:
  22. virtual ~ISceneUserDataSerializer() {}
  23. //! Called when the scene manager create a scene node while loading a file.
  24. virtual void OnCreateNode(ISceneNode* node) = 0;
  25. //! Called when the scene manager read a scene node while loading a file.
  26. /** The userData pointer contains a list of attributes with userData which
  27. were attached to the scene node in the read scene file.*/
  28. virtual void OnReadUserData(ISceneNode* forSceneNode, io::IAttributes* userData) = 0;
  29. //! Called when the scene manager is writing a scene node to an xml file for example.
  30. /** Implement this method and return a list of attributes containing the user data
  31. you want to be saved together with the scene node. Return 0 if no user data should
  32. be added. Please note that the scene manager will call drop() to the returned pointer
  33. after it no longer needs it, so if you didn't create a new object for the return value
  34. and returning a longer existing IAttributes object, simply call grab() before returning it. */
  35. virtual io::IAttributes* createUserData(ISceneNode* forSceneNode) = 0;
  36. };
  37. } // end namespace scene
  38. } // end namespace irr
  39. #endif