HdfAttribute_priv.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <string>
  11. #include <vector>
  12. #include <map>
  13. #include <memory>
  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) : HdfObject(type,
  19. ATTRIBUTE,
  20. chain),
  21. id(id),
  22. index(index) {
  23. if (id == FAIL || index == FAIL) {
  24. raiseException(INVALID_ID);
  25. }
  26. }
  27. virtual ~HdfAttributeBase() {}
  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