ISceneUserDataSerializer.h 1.8 KB

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