HdfAttribute_priv.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // Created by patrik on 11.08.17.
  3. //
  4. #ifndef HDF4CPP_HDFATTRIBUTE_PRIV_H
  5. #define HDF4CPP_HDFATTRIBUTE_PRIV_H
  6. #include <hdf4cpp/HdfAttribute.h>
  7. #include <hdf4cpp/HdfException.h>
  8. #include <hdf4cpp/HdfObject.h>
  9. #include <hdf/hdf.h>
  10. #include <hdf/mfhdf.h>
  11. #include <string>
  12. #include <vector>
  13. #include <map>
  14. #include <memory>
  15. namespace hdf4cpp {
  16. /// The base class of the attribute classes
  17. class HdfAttribute::HdfAttributeBase : public HdfObject {
  18. public:
  19. HdfAttributeBase(int32 id, int32 index, Type type, const HdfDestroyerChain& chain) : HdfObject(type,
  20. ATTRIBUTE,
  21. chain),
  22. id(id),
  23. index(index) {
  24. if (id == FAIL || index == FAIL) {
  25. raiseException(INVALID_ID);
  26. }
  27. }
  28. virtual ~HdfAttributeBase() {}
  29. /// \returns The number of existing data in the attribute
  30. virtual intn size() const = 0;
  31. /// \returns The data type number of the data held by the attribute
  32. virtual int32 getDataType() const = 0;
  33. /// Reads the data from the attribute
  34. /// \param dest The destination vector
  35. virtual void get(void* dest) = 0;
  36. protected:
  37. int32 id;
  38. int32 index;
  39. };
  40. /// Attribute class for the SData attributes
  41. class HdfAttribute::HdfDatasetAttribute : public HdfAttributeBase {
  42. public:
  43. HdfDatasetAttribute(int32 id, const std::string& name, const HdfDestroyerChain& chain);
  44. intn size() const;
  45. private:
  46. intn _size;
  47. int32 dataType;
  48. void get(void *dest);
  49. int32 getDataType() const;
  50. };
  51. /// Attribute class for the VGroup attributes
  52. class HdfAttribute::HdfGroupAttribute : public HdfAttributeBase {
  53. public:
  54. HdfGroupAttribute(int32 id, const std::string& name, const HdfDestroyerChain& chain);
  55. intn size() const;
  56. private:
  57. intn _size;
  58. int32 dataType;
  59. void get(void *dest);
  60. int32 getDataType() const;
  61. };
  62. /// Attribute class for the VData attributes
  63. class HdfAttribute::HdfDataAttribute : public HdfAttributeBase {
  64. public:
  65. HdfDataAttribute(int32 id, const std::string& name, const HdfDestroyerChain& chain);
  66. intn size() const;
  67. private:
  68. intn _size;
  69. int32 dataType;
  70. void get(void *dest);
  71. int32 getDataType() const;
  72. };
  73. }
  74. #endif //HDF4CPP_HDFATTRIBUTE_PRIV_H