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);
96 friend class DmrppCommonTest;
97 friend class DmrppParserTest;
100 bool d_compact =
false;
101 std::string d_filters;
102 std::string d_byte_order;
103 std::vector<unsigned long long> d_chunk_dimension_sizes;
104 std::vector<std::shared_ptr<Chunk>> d_chunks;
105 bool d_twiddle_bytes =
false;
109 bool d_chunks_loaded =
false;
110 bool d_attributes_loaded =
false;
112 bool d_uses_fill_value {
false};
114 std::string d_fill_value_str;
115 libdap::Type d_fill_value_type{libdap::dods_null_c};
123 std::shared_ptr<DMZ> d_dmz;
124 pugi::xml_node d_xml_node;
127 virtual char *
read_atomic(
const std::string &name);
131 friend void compute_super_chunks(
dmrpp::DmrppArray *array,
bool only_constrained, std::vector<dmrpp::SuperChunk *> &super_chunks);
140 explicit DmrppCommon(std::shared_ptr<DMZ> dmz) : d_dmz(std::move(dmz)) { }
153 virtual bool is_filters_empty()
const {
154 return d_filters.empty();
175 virtual void set_chunks_loaded(
bool state) { d_chunks_loaded = state; }
179 virtual void set_attributes_loaded(
bool state) { d_attributes_loaded = state; }
181 virtual const pugi::xml_node &get_xml_node()
const {
return d_xml_node; }
182 virtual void set_xml_node(pugi::xml_node node) { d_xml_node = node; }
196 return d_chunk_dimension_sizes;
202 unsigned long long elements = 1;
203 for (
auto d_chunk_dimension_size : d_chunk_dimension_sizes) {
204 elements *= d_chunk_dimension_size;
230 void print_compact_element(libdap::XMLWriter &xml,
const std::string &name_space =
"",
const std::string &encoded =
"");
232 void print_dmrpp(libdap::XMLWriter &writer,
bool constrained =
false);
236 for (
auto chunk_dim : chunk_dims) {
237 d_chunk_dimension_sizes.push_back(chunk_dim);
251 virtual std::string get_byte_order()
const {
return d_byte_order; }
259 std::shared_ptr<http::url> d_data_url,
260 const std::string &byte_order,
261 unsigned long long size,
262 unsigned long long offset,
263 const std::string &position_in_array);
266 std::shared_ptr<http::url> d_data_url,
267 const std::string &byte_order,
268 unsigned long long size,
269 unsigned long long offset,
270 const std::vector<unsigned long long> &position_in_array);
273 const std::string &byte_order,
274 unsigned long long size,
275 unsigned long long offset,
276 const std::string &position_in_array);
279 const std::string &byte_order,
280 unsigned long long size,
281 unsigned long long offset,
282 const std::vector<unsigned long long> &position_in_array);
285 const std::string &byte_order,
286 const std::string &fill_value,
287 libdap::Type fv_type,
288 unsigned long long chunk_size,
289 const std::vector<unsigned long long> &position_in_array);
291 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.
virtual void set_fill_value_string(const std::string &fv)
Set the fill value (using a string)
virtual libdap::Type get_fill_value_type() const
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 std::string get_fill_value() const
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 set_uses_fill_value(bool ufv)
Set the uses_fill_value property.
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.
void set_chunk_dimension_sizes(const std::vector< unsigned long long > &chunk_dims)
Set the value of the chunk dimension sizes given a vector of HDF5 hsize_t.
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)
Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal ve...
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 bool get_uses_fill_value() const
virtual const std::vector< unsigned long long > & get_chunk_dimension_sizes() const
The chunk dimension sizes held in a const vector.
virtual void set_fill_value_type(libdap::Type t)
Set the libdap data type to use with the fill value.
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
hold the value used to fill empty chunks