IAttributeExchangingObject.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__
  5. #define __I_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED__
  6. #include "IReferenceCounted.h"
  7. namespace irr
  8. {
  9. namespace io
  10. {
  11. class IAttributes;
  12. //! Enumeration flags passed through SAttributeReadWriteOptions to the IAttributeExchangingObject object
  13. enum E_ATTRIBUTE_READ_WRITE_FLAGS
  14. {
  15. //! Serialization/Deserializion is done for an xml file
  16. EARWF_FOR_FILE = 0x00000001,
  17. //! Serialization/Deserializion is done for an editor property box
  18. EARWF_FOR_EDITOR = 0x00000002,
  19. //! When writing filenames, relative paths should be used
  20. EARWF_USE_RELATIVE_PATHS = 0x00000004
  21. };
  22. //! struct holding data describing options
  23. struct SAttributeReadWriteOptions
  24. {
  25. //! Constructor
  26. SAttributeReadWriteOptions()
  27. : Flags(0), Filename(0)
  28. {
  29. }
  30. //! Combination of E_ATTRIBUTE_READ_WRITE_FLAGS or other, custom ones
  31. s32 Flags;
  32. //! Optional filename
  33. const fschar_t* Filename;
  34. };
  35. //! An object which is able to serialize and deserialize its attributes into an attributes object
  36. class IAttributeExchangingObject : virtual public IReferenceCounted
  37. {
  38. public:
  39. //! Writes attributes of the object.
  40. /** Implement this to expose the attributes of your scene node animator for
  41. scripting languages, editors, debuggers or xml serialization purposes. */
  42. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {}
  43. //! Reads attributes of the object.
  44. /** Implement this to set the attributes of your scene node animator for
  45. scripting languages, editors, debuggers or xml deserialization purposes. */
  46. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) {}
  47. };
  48. } // end namespace io
  49. } // end namespace irr
  50. #endif