1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14 #include <string>
15
16 #include "H5Include.h"
17 #include "H5Exception.h"
18 #include "H5IdComponent.h"
19 #include "H5PropList.h"
20 #include "H5FaccProp.h"
21 #include "H5OcreatProp.h"
22
23 namespace H5 {
24
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 // This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
27 // the order of creation and deletion of the global constants. See Design Notes
28 // in "H5PredType.cpp" for information.
29
30 // Initialize a pointer for the constant
31 ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0;
32
33 //--------------------------------------------------------------------------
34 // Function: ObjCreatPropList::getConstant
35 // Creates a ObjCreatPropList object representing the HDF5 constant
36 // H5P_FILE_ACCESS, pointed to by ObjCreatPropList::DEFAULT_
37 // exception H5::PropListIException
38 // Description
39 // If ObjCreatPropList::DEFAULT_ already points to an allocated
40 // object, throw a PropListIException. This scenario should not
41 // happen.
42 // Programmer Binh-Minh Ribler - 2015
43 //--------------------------------------------------------------------------
getConstant()44 ObjCreatPropList* ObjCreatPropList::getConstant()
45 {
46 // Tell the C library not to clean up, H5Library::termH5cpp will call
47 // H5close - more dependency if use H5Library::dontAtExit()
48 if (!IdComponent::H5dontAtexit_called)
49 {
50 (void) H5dont_atexit();
51 IdComponent::H5dontAtexit_called = true;
52 }
53
54 // If the constant pointer is not allocated, allocate it. Otherwise,
55 // throw because it shouldn't be.
56 if (DEFAULT_ == 0)
57 DEFAULT_ = new ObjCreatPropList(H5P_OBJECT_CREATE);
58 else
59 throw PropListIException("ObjCreatPropList::getConstant", "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_");
60 return(DEFAULT_);
61 }
62
63 //--------------------------------------------------------------------------
64 // Function: ObjCreatPropList::deleteConstants
65 // Purpose: Deletes the constant object that ObjCreatPropList::DEFAULT_
66 // points to.
67 // exception H5::PropListIException
68 // Programmer Binh-Minh Ribler - 2015
69 //--------------------------------------------------------------------------
deleteConstants()70 void ObjCreatPropList::deleteConstants()
71 {
72 if (DEFAULT_ != 0)
73 delete DEFAULT_;
74 }
75
76 //--------------------------------------------------------------------------
77 // Purpose: Constant for default property
78 //--------------------------------------------------------------------------
79 const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant();
80
81 #endif // DOXYGEN_SHOULD_SKIP_THIS
82
83 //--------------------------------------------------------------------------
84 // Function: Default Constructor
85 ///\brief Creates a file access property list
86 // Programmer: Binh-Minh Ribler - 2000
87 //--------------------------------------------------------------------------
ObjCreatPropList()88 ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {}
89
90 //--------------------------------------------------------------------------
91 // Function: ObjCreatPropList copy constructor
92 ///\brief Copy Constructor: makes a copy of the original
93 ///\param original - IN: ObjCreatPropList instance to copy
94 // Programmer: Binh-Minh Ribler - 2000
95 //--------------------------------------------------------------------------
ObjCreatPropList(const ObjCreatPropList & original)96 ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList(original) {}
97
98 //--------------------------------------------------------------------------
99 // Function: ObjCreatPropList overloaded constructor
100 ///\brief Creates a file access property list using the id of an
101 /// existing one.
102 // Programmer: Binh-Minh Ribler - 2000
103 //--------------------------------------------------------------------------
ObjCreatPropList(const hid_t plist_id)104 ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {}
105
106 //--------------------------------------------------------------------------
107 // Function: ObjCreatPropList::setAttrPhaseChange
108 ///\brief Sets attribute storage phase change thresholds.
109 ///\param max_compact - IN: Maximum number of attributes to be stored in
110 /// compact storage. Default to 8
111 ///\param min_dense - IN: Minimum number of attributes to be stored in
112 /// dense storage. Default to 6
113 ///\exception H5::PropListIException
114 ///\par Description
115 /// If \c max_compact is set to 0, dense storage will be used.
116 /// For more detail about on attribute storage, please refer to the
117 /// C layer Reference Manual at:
118 /// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAttrPhaseChange
119 // Programmer: Binh-Minh Ribler - September 2015
120 //--------------------------------------------------------------------------
setAttrPhaseChange(unsigned max_compact,unsigned min_dense) const121 void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const
122 {
123 herr_t ret_value = H5Pset_attr_phase_change(id, max_compact, min_dense);
124 if (ret_value < 0)
125 {
126 throw PropListIException("ObjCreatPropList::setAttrPhaseChange", "H5Pset_attr_phase_change failed");
127 }
128 }
129
130 //--------------------------------------------------------------------------
131 // Function: ObjCreatPropList::getAttrPhaseChange
132 ///\brief Gets attribute storage phase change thresholds.
133 ///\param max_compact - OUT: Maximum number of attributes to be stored in
134 /// compact storage.
135 ///\param min_dense - OUT: Minimum number of attributes to be stored in
136 /// dense storage.
137 ///\exception H5::PropListIException
138 ///\par Description
139 /// If \c max_compact is set to 0, dense storage will be used.
140 /// For more detail about on attribute storage, please refer to the
141 /// C layer Reference Manual at:
142 /// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetAttrPhaseChange
143 // Programmer: Binh-Minh Ribler - September 2015
144 //--------------------------------------------------------------------------
getAttrPhaseChange(unsigned & max_compact,unsigned & min_dense) const145 void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const
146 {
147 herr_t ret_value;
148 ret_value = H5Pget_attr_phase_change(id, &max_compact, &min_dense);
149 if (ret_value < 0)
150 {
151 throw PropListIException("ObjCreatPropList::getAttrPhaseChange", "H5Pget_attr_phase_change failed");
152 }
153 }
154
155 //--------------------------------------------------------------------------
156 // Function: ObjCreatPropList::setAttrCrtOrder
157 ///\brief Sets tracking and indexing of attribute creation order.
158 ///\param crt_order_flags - IN: Flags specifying whether to track and
159 /// index attribute creation order. Default: No flag set
160 ///\exception H5::PropListIException
161 ///\par Description
162 /// Valid flags are:
163 /// \li \c H5P_CRT_ORDER_TRACKED - Attribute creation order is tracked
164 /// \li \c H5P_CRT_ORDER_INDEXED - Attribute creation order is
165 /// indexed (requires H5P_CRT_ORDER_TRACKED).
166 /// When no flag is set, attribute creation order is neither
167 /// tracked not indexed. Note that HDF5 currently provides no
168 /// mechanism to turn on attribute creation order tracking at object
169 /// creation time and to build the index later.
170 /// The C layer Reference Manual at can be found at:
171 /// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAttrCreationOrder
172 // Programmer: Binh-Minh Ribler - September 2015
173 //--------------------------------------------------------------------------
setAttrCrtOrder(unsigned crt_order_flags) const174 void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const
175 {
176 herr_t ret_value = H5Pset_attr_creation_order(id, crt_order_flags);
177 if (ret_value < 0)
178 {
179 throw PropListIException("ObjCreatPropList::setAttrCrtOrder", "H5Pset_attr_creation_order failed");
180 }
181 }
182
183 //--------------------------------------------------------------------------
184 // Function: ObjCreatPropList::getAttrCrtOrder
185 ///\brief Gets tracking and indexing settings for attribute
186 /// creation order.
187 ///\return Attribute creation order
188 ///\exception H5::PropListIException
189 ///\par Description
190 /// When no flag is set, i.e. crt_order_flags = 0, attribute
191 /// creation order is neither tracked not indexed.
192 /// The C layer Reference Manual at can be found at:
193 /// https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetAttrCreationOrder
194 // Programmer: Binh-Minh Ribler - September 2015
195 //--------------------------------------------------------------------------
getAttrCrtOrder() const196 unsigned ObjCreatPropList::getAttrCrtOrder() const
197 {
198 herr_t ret_value;
199 unsigned crt_order_flags = 0;
200 ret_value = H5Pget_attr_creation_order(id, &crt_order_flags);
201 if (ret_value < 0)
202 {
203 throw PropListIException("ObjCreatPropList::getAttrCrtOrder", "H5Pget_attr_creation_order failed");
204 }
205 return(crt_order_flags);
206 }
207
208 //--------------------------------------------------------------------------
209 // Function: ObjCreatPropList destructor
210 ///\brief Noop destructor
211 // Programmer Binh-Minh Ribler - 2000
212 //--------------------------------------------------------------------------
~ObjCreatPropList()213 ObjCreatPropList::~ObjCreatPropList() {}
214
215 } // end namespace
216