25#ifndef _dmrpp_common_h
26#define _dmrpp_common_h 1
32#define PUGIXML_NO_XPATH
33#define PUGIXML_HEADER_ONLY
39class D4BaseTypeFactory;
62void join_threads(pthread_t threads[],
unsigned int num_threads);
78 friend class DmrppCommonTest;
79 friend class DmrppParserTest;
82 bool d_compact =
false;
83 std::string d_filters;
84 std::string d_byte_order;
85 std::vector<unsigned long long> d_chunk_dimension_sizes;
86 std::vector<std::shared_ptr<Chunk>> d_chunks;
87 bool d_twiddle_bytes =
false;
91 bool d_chunks_loaded =
false;
92 bool d_attributes_loaded =
false;
99 std::shared_ptr<DMZ> d_dmz;
100 pugi::xml_node d_xml_node;
106 virtual std::vector<std::shared_ptr<Chunk>> get_chunks() {
111 virtual char *
read_atomic(
const std::string &name);
115 friend void compute_super_chunks(
dmrpp::DmrppArray *array,
bool only_constrained, std::vector<dmrpp::SuperChunk *> &super_chunks);
124 DmrppCommon(std::shared_ptr<DMZ> dmz) : d_dmz(dmz) { }
137 virtual bool is_filters_empty()
const {
138 return d_filters.empty();
159 virtual void set_chunks_loaded(
bool state) { d_chunks_loaded = state; }
163 virtual void set_attributes_loaded(
bool state) { d_attributes_loaded = state; }
165 virtual const pugi::xml_node &get_xml_node()
const {
return d_xml_node; }
166 virtual void set_xml_node(pugi::xml_node node) { d_xml_node = node; }
180 return d_chunk_dimension_sizes;
186 unsigned long long elements = 1;
187 for (
auto d_chunk_dimension_size : d_chunk_dimension_sizes) {
188 elements *= d_chunk_dimension_size;
196 void print_compact_element(libdap::XMLWriter &xml,
const std::string &name_space =
"",
const std::string &encoded =
"");
198 void print_dmrpp(libdap::XMLWriter &writer,
bool constrained =
false);
205 for (
auto chunk_dim : chunk_dims) {
206 d_chunk_dimension_sizes.push_back(chunk_dim);
220 virtual std::string get_byte_order()
const {
return d_byte_order; }
223 std::shared_ptr<http::url> d_data_url,
224 const std::string &byte_order,
225 unsigned long long size,
226 unsigned long long offset,
227 const std::string &position_in_array);
230 std::shared_ptr<http::url> d_data_url,
231 const std::string &byte_order,
232 unsigned long long size,
233 unsigned long long offset,
234 const std::vector<unsigned long long> &position_in_array);
237 const std::string &byte_order,
238 unsigned long long size,
239 unsigned long long offset,
240 const std::string &position_in_array);
243 const std::string &byte_order,
244 unsigned long long size,
245 unsigned long long offset,
246 const std::vector<unsigned long long> &position_in_array);
248 virtual void dump(std::ostream & strm)
const;
Extend libdap::Array so that a handler can read data using a DMR++ file.
Size and offset information of data included in DMR++ files.
static std::string d_ns_prefix
The XML namespace prefix to use.
virtual bool twiddle_bytes() const
Returns true if this object utilizes shuffle compression.
void set_chunk_dimension_sizes(const std::vector< size_t > &chunk_dims)
Set the value of the chunk dimension sizes given a vector of HDF5 hsize_t.
static bool d_print_chunks
if true, print_dap4() prints chunk elements
virtual bool is_compact_layout() const
Returns true if this object utilizes COMPACT layout.
virtual void ingest_compression_type(const std::string &compression_type_string)
Parses the text content of the XML element h4:chunkDimensionSizes into the internal vector<unsigned i...
virtual void load_attributes(libdap::BaseType *btp)
Load the attribute information for this variable.
void print_compact_element(libdap::XMLWriter &xml, const std::string &name_space="", const std::string &encoded="")
Print the Compact base64-encoded information.
virtual bool get_chunks_loaded() const
Have the chunks been loaded?
virtual size_t get_chunks_size() const
Use this when the number of chunks is needed.
static std::string d_dmrpp_ns
The DMR++ XML namespace.
void print_chunks_element(libdap::XMLWriter &xml, const std::string &name_space="")
Print the Chunk information.
virtual void parse_chunk_dimension_sizes(const std::string &chunk_dim_sizes_string)
Set the dimension sizes for a chunk.
virtual const std::vector< std::shared_ptr< Chunk > > & get_immutable_chunks() const
A const reference to the vector of chunks.
virtual unsigned long add_chunk(std::shared_ptr< http::url > d_data_url, const std::string &byte_order, unsigned long long size, unsigned long long offset, const std::string &position_in_array)
Add a new chunk as defined by an h4:byteStream element.
void set_filter(const std::string &value)
Set the value of the filters property.
virtual void ingest_byte_order(const std::string &byte_order_string)
Parses the text content of the XML element chunks:byteOrder.
virtual const std::vector< unsigned long long > & get_chunk_dimension_sizes() const
The chunk dimension sizes held in a const vector.
void set_compact(bool value)
Set the value of the compact property.
void print_dmrpp(libdap::XMLWriter &writer, bool constrained=false)
Print the DMR++ response for the Scalar types.
virtual void load_chunks(libdap::BaseType *btp)
Load chunk information for this variable.
virtual unsigned long long get_chunk_size_in_elements() const
Get the number of elements in this chunk.
virtual std::string get_filters() const
Return the names of all the filters in the order they were applied.
virtual bool get_attributes_loaded() const
Have the attributes been loaded?
virtual char * read_atomic(const std::string &name)
read method for the atomic types
utility class for the HTTP catalog module