IAttributes.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #pragma once
  5. #include "IReferenceCounted.h"
  6. #include "EAttributes.h"
  7. // not needed here but I can't be bothered to clean the transitive includes up.
  8. #include "quaternion.h"
  9. namespace irr
  10. {
  11. namespace video
  12. {
  13. class ITexture;
  14. } // end namespace video
  15. namespace io
  16. {
  17. //! Provides a generic interface for attributes and their values and the possibility to serialize them
  18. class IAttributes : public virtual IReferenceCounted
  19. {
  20. public:
  21. //! Returns amount of attributes in this collection of attributes.
  22. virtual u32 getAttributeCount() const = 0;
  23. //! Returns attribute name by index.
  24. //! \param index: Index value, must be between 0 and getAttributeCount()-1.
  25. virtual const c8 *getAttributeName(s32 index) const = 0;
  26. //! Returns the type of an attribute
  27. //! \param attributeName: Name for the attribute
  28. virtual E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const = 0;
  29. //! Returns attribute type by index.
  30. //! \param index: Index value, must be between 0 and getAttributeCount()-1.
  31. virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) const = 0;
  32. //! Returns if an attribute with a name exists
  33. virtual bool existsAttribute(const c8 *attributeName) const = 0;
  34. //! Returns attribute index from name, -1 if not found
  35. virtual s32 findAttribute(const c8 *attributeName) const = 0;
  36. //! Removes all attributes
  37. virtual void clear() = 0;
  38. /*
  39. Integer Attribute
  40. */
  41. //! Adds an attribute as integer
  42. virtual void addInt(const c8 *attributeName, s32 value) = 0;
  43. //! Sets an attribute as integer value
  44. virtual void setAttribute(const c8 *attributeName, s32 value) = 0;
  45. //! Gets an attribute as integer value
  46. //! \param attributeName: Name of the attribute to get.
  47. //! \param defaultNotFound Value returned when attributeName was not found
  48. //! \return Returns value of the attribute previously set by setAttribute()
  49. virtual s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const = 0;
  50. //! Gets an attribute as integer value
  51. //! \param index: Index value, must be between 0 and getAttributeCount()-1.
  52. virtual s32 getAttributeAsInt(s32 index) const = 0;
  53. //! Sets an attribute as integer value
  54. virtual void setAttribute(s32 index, s32 value) = 0;
  55. /*
  56. Float Attribute
  57. */
  58. //! Adds an attribute as float
  59. virtual void addFloat(const c8 *attributeName, f32 value) = 0;
  60. //! Sets a attribute as float value
  61. virtual void setAttribute(const c8 *attributeName, f32 value) = 0;
  62. //! Gets an attribute as float value
  63. //! \param attributeName: Name of the attribute to get.
  64. //! \param defaultNotFound Value returned when attributeName was not found
  65. //! \return Returns value of the attribute previously set by setAttribute()
  66. virtual f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const = 0;
  67. //! Gets an attribute as float value
  68. //! \param index: Index value, must be between 0 and getAttributeCount()-1.
  69. virtual f32 getAttributeAsFloat(s32 index) const = 0;
  70. //! Sets an attribute as float value
  71. virtual void setAttribute(s32 index, f32 value) = 0;
  72. /*
  73. Bool Attribute
  74. */
  75. //! Adds an attribute as bool
  76. virtual void addBool(const c8 *attributeName, bool value) = 0;
  77. //! Sets an attribute as boolean value
  78. virtual void setAttribute(const c8 *attributeName, bool value) = 0;
  79. //! Gets an attribute as boolean value
  80. //! \param attributeName: Name of the attribute to get.
  81. //! \param defaultNotFound Value returned when attributeName was not found
  82. //! \return Returns value of the attribute previously set by setAttribute()
  83. virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const = 0;
  84. //! Gets an attribute as boolean value
  85. //! \param index: Index value, must be between 0 and getAttributeCount()-1.
  86. virtual bool getAttributeAsBool(s32 index) const = 0;
  87. //! Sets an attribute as boolean value
  88. virtual void setAttribute(s32 index, bool value) = 0;
  89. };
  90. } // end namespace io
  91. } // end namespace irr