IAttributeExchangingObject.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_ATTRIBUTE_EXCHANGING_OBJECT_H_INCLUDED
  5. #define IRR_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/deserialization is done for an xml file
  16. EARWF_FOR_FILE = 0x00000001,
  17. //! Serialization/deserialization 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