libSplash
AttributeInfo.hpp
1 /*
2  * Copyright 2016 Alexander Grund
3  *
4  * This file is part of libSplash.
5  *
6  * libSplash is free software: you can redistribute it and/or modify
7  * it under the terms of of either the GNU General Public License or
8  * the GNU Lesser General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * libSplash is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License and the GNU Lesser General Public License
16  * for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * and the GNU Lesser General Public License along with libSplash.
20  * If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef DCATTRIBUTE_INFO_H
24 #define DCATTRIBUTE_INFO_H
25 
26 #include "splash/Dimensions.hpp"
27 #include "splash/DCException.hpp"
28 #include "splash/core/H5IdWrapper.hpp"
29 #include "splash/core/splashMacros.hpp"
30 #include <string>
31 
32 namespace splash
33 {
34  class CollectionType;
35 
51  {
52  H5AttributeIdRefCt attr_;
53 
54  public:
55  explicit AttributeInfo(hid_t attr);
57  explicit AttributeInfo(H5AttributeId& attr);
58  ~AttributeInfo();
59 
60  AttributeInfo(const AttributeInfo& other);
61  AttributeInfo& operator=(const AttributeInfo& other);
62 
64  size_t getMemSize() throw(DCException);
66  const CollectionType& getType() throw(DCException);
70  uint32_t getNDims() throw(DCException);
72  bool isScalar() throw(DCException){ return getNDims() == 1 && getDims().getScalarSize() == 1; }
75  bool isVarSize() throw(DCException);
77  std::string readName();
78 
88  void read(const CollectionType& colType, void* buf) throw(DCException);
89 
100  bool readNoThrow(const CollectionType& colType, void* buf);
101 
113  void read(void* buf, size_t bufSize) throw(DCException);
114 
120  void close();
121 
122  friend void swap(AttributeInfo& lhs, AttributeInfo& rhs);
123 
124  private:
125 
126  std::string getExceptionString(const std::string& msg);
127  void loadType() throw(DCException);
128  void loadSpace() throw(DCException);
129 
130  // Those values are lazy loaded on access
131  CollectionType* colType_;
132  H5TypeId type_;
133  H5DataspaceId space_;
134  uint32_t nDims_;
135 };
136 }
137 
138 #endif /* DCATTRIBUTE_INFO_H */
const CollectionType & getType()
size_t getScalarSize() const
Definition: Dimensions.hpp:219
bool readNoThrow(const CollectionType &colType, void *buf)
void read(const CollectionType &colType, void *buf)