HdfAttribute_priv.h 2.2 KB

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