Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Comments, some loose ends with the print code in dmrpp_module
I made the DMR++ namespace and namespace prefix static class
fields of DmrppCommon. This way we can change the default prefix
using a parameter in the module's conf file.
  • Loading branch information
jgallagher59701 committed May 10, 2018
1 parent 7f58da8 commit e15a1e0
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 19 deletions.
4 changes: 3 additions & 1 deletion doxy.conf.in
Expand Up @@ -833,9 +833,9 @@ EXCLUDE_SYMLINKS = NO

EXCLUDE_PATTERNS = */old/* \
*/not-used/* \
*/unused/* \
*/tests/* \
*/unit-tests/* \
*/modules/* \
*/templates/* \
*/apache/* \
*/bin/* \
Expand All @@ -848,6 +848,8 @@ Test*.cc \
Test*.h \
*Test.cc \
*T.cc

# This was excluded. jhrg 5/10/18 */modules/* \

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
Expand Down
36 changes: 33 additions & 3 deletions modules/dmrpp_module/DMRpp.cc
Expand Up @@ -34,8 +34,37 @@ using namespace libdap;

namespace dmrpp {

#if 0
/**
* @brief The DMR++ namespace.
*/
const string dmrpp_namespace = "http://xml.opendap.org/dap/dmrpp/1.0.0#";

#endif


/**
* @brief Print the DMR++ response
*
* This is a clone of DMR::print_dap4() modified to include the DMR++ namespace
* and to print the DMR++ XML which is the standard DMR XML with the addition of
* new elements that include information about the 'chunks' that hold data values.
* It uses a static field defined in DmrppCommon to control whether the
* chunk information should be printed. The third argument \arg print_chunks
* will set this static class member to true or false, which controls the
* output of the chunk information. This method resets the field to its previous
* value on exit.
*
* @param xml Writer the XML to this instance of XMLWriter
* @param constrained Should the DMR++ be constrained, in the same sense that the
* DMR::print_dap4() method can print a constrained DMR. False by default.
* @param print_chunks Print the chunks? This parameter sets the DmrppCommon::d_print_chunks
* static field. That field is used by other methods in the Dmrpp<Type> classes to
* control if they print the chunk information. True by default.
*
* @see DmrppArray::print_dap4()
* @see DmrppCommon::print_dmrpp()
*/
void DMRpp::print_dmrpp(XMLWriter &xml, bool constrained, bool print_chunks)
{
bool pc_initial_value = DmrppCommon::d_print_chunks;
Expand All @@ -51,8 +80,9 @@ void DMRpp::print_dmrpp(XMLWriter &xml, bool constrained, bool print_chunks)

// The dmrpp namespace
if (DmrppCommon::d_print_chunks)
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "xmlns:dmrpp",
(const xmlChar*) dmrpp_namespace.c_str()) < 0)
if (xmlTextWriterWriteAttribute(xml.get_writer(),
(const xmlChar*)string("xmlns:").append(DmrppCommon::d_ns_prefix).c_str(),
(const xmlChar*)DmrppCommon::d_dmrpp_ns.c_str()) < 0)
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for xmlns:dmrpp");

if (!request_xml_base().empty()) {
Expand Down
5 changes: 4 additions & 1 deletion modules/dmrpp_module/DMRpp.h
Expand Up @@ -33,12 +33,15 @@ class XMLWriter;

namespace dmrpp {

/**
* @brief Provide a way to print the DMR++ response
*/
class DMRpp : public libdap::DMR {
public:
DMRpp() { }
virtual ~DMRpp() { }

virtual void print_dmrpp(libdap::XMLWriter &xml, bool constrained = false, bool print_chunks = false);
virtual void print_dmrpp(libdap::XMLWriter &xml, bool constrained = false, bool print_chunks = true);
};

} /* namespace dmrpp */
Expand Down
39 changes: 28 additions & 11 deletions modules/dmrpp_module/DmrppArray.cc
Expand Up @@ -46,6 +46,7 @@
#include "DmrppArray.h"
#include "DmrppRequestHandler.h"

// Used with BESDEBUG
static const string dmrpp_3 = "dmrpp:3";

using namespace libdap;
Expand Down Expand Up @@ -213,7 +214,7 @@ void DmrppArray::insert_constrained_contiguous(Dim_iter dimIter, unsigned long *
subsetAddress.pop_back();

// Copy data block from start_index to stop_index
// FIXME Replace this loop with a call to std::memcpy()
// TODO Replace this loop with a call to std::memcpy()
for (unsigned long sourceIndex = start_index; sourceIndex <= stop_index; sourceIndex++) {
unsigned long target_byte = *target_index * bytesPerElt;
unsigned long source_byte = sourceIndex * bytesPerElt;
Expand Down Expand Up @@ -484,10 +485,6 @@ void DmrppArray::read_chunks_serial()
* When \arg dim is the array's rank, `target_element_address` will
* have a value for all but the rightmost dimension.
*
* @todo Save the target element address with the chunk for use in the
* insert code. It might be useful to compute the last (rightmost)
* component of the `target_element_address.`
*
* @param dim Starting with 0, compute values for this dimension of the array
* @param target_element_address Initially empty, this becomes the location
* in the array where data should be written.
Expand Down Expand Up @@ -831,11 +828,31 @@ class PrintD4MapXMLWriter: public unary_function<D4Map*, void> {
};
///@}

/**
* @brief Shadow libdap::Array::print_dap4() - optionally prints DMR++ chunk information
*
* This version of libdap::BaseType::print_dap4() will print information about
* HDF5 chunks when the value of the static class filed dmrpp::DmrppCommon::d_print_chunks
* is true. The method DMRpp::print_dmrpp() will set the _d_pprint_chunks_ field to
* true causing this method to include the _chunks_ elements in its output. When
* the field's value is false, this method prints the same output as libdap::Array.
*
* @note There are, no doubt, better ways to do this than using what is essentially a
* global flag; one way is to synchronize access to a DMR C++ object and a DOM
* tree for the same DMR document. The chunk information can be read from the DMR and
* inserted into the DOM tree, which then printed. If the
* approach I took here becomes an issue (i.e., if we have to fix problems in libdap and
* here because of code duplication), we should probably recode this and the related
* methods to use the 'DOM tree approach.'
*
* @param xml Write the XML to this instance of XMLWriter
* @param constrained True if the response should be constrained. False by default
*
* @see DmrppCommon::print_dmrpp()
* @see DMRpp::print_dmrpp()
*/
void DmrppArray::print_dap4(XMLWriter &xml, bool constrained /*false*/)
{
#if USE_LIBDAP_print_dap4
Array::print_dap4(writer, constrained);
#else
if (constrained && !send_p()) return;

if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) var()->type_name().c_str()) < 0)
Expand Down Expand Up @@ -870,13 +887,13 @@ void DmrppArray::print_dap4(XMLWriter &xml, bool constrained /*false*/)

for_each(maps()->map_begin(), maps()->map_end(), PrintD4MapXMLWriter(xml));

// Only print the chunks info if there.
// Only print the chunks info if there. This is the code added to libdap::Array::print_dap4().
// jhrg 5/10/18
if (DmrppCommon::d_print_chunks && get_immutable_chunks().size() > 0)
print_chunks_element(xml, "dmrpp");
print_chunks_element(xml, DmrppCommon::d_ns_prefix);

if (xmlTextWriterEndElement(xml.get_writer()) < 0)
throw InternalErr(__FILE__, __LINE__, "Could not end " + type_name() + " element");
#endif
}

void DmrppArray::dump(ostream & strm) const
Expand Down
7 changes: 7 additions & 0 deletions modules/dmrpp_module/DmrppArray.h
Expand Up @@ -31,6 +31,13 @@

#include "DmrppCommon.h"

// The 'read_serial()' method is more closely related to the original code
// used to read data when the DMR++ handler was initial developed for NASA.
// I modified that code for a while when we built the prototype version of
// the handler, but then morphed that into a version that would support parallel
// access. Defining this symbol will include the old code in the handler,
// although the DmrppArray::read() method will still have to be hacked to
// use it. jhrg 5/10/18
#undef USE_READ_SERIAL

namespace libdap {
Expand Down
15 changes: 14 additions & 1 deletion modules/dmrpp_module/DmrppCommon.cc
Expand Up @@ -46,6 +46,8 @@ using namespace libdap;
namespace dmrpp {

bool DmrppCommon::d_print_chunks = false;
string DmrppCommon::d_dmrpp_ns = "http://xml.opendap.org/dap/dmrpp/1.0.0#";
string DmrppCommon::d_ns_prefix = "dmrpp";

/**
* @brief Set the dimension sizes for a chunk
Expand Down Expand Up @@ -236,6 +238,16 @@ DmrppCommon::print_chunks_element(XMLWriter &xml, const string &name_space)
}
}

/**
* @brief Print the DMR++ response for the Scalar types
*
* @note See DmrppArray::print_dap4() for a discussion about the design of
* this, and related, method.
*
* @param xml Write the XML to this instance of XMLWriter
* @param constrained If true, print the constrained DMR. False by default.
* @see DmrppArray::print_dap4()
*/
void DmrppCommon::print_dap4(XMLWriter &xml, bool constrained /*false*/)
{
BaseType &bt = dynamic_cast<BaseType&>(*this);
Expand All @@ -255,8 +267,9 @@ void DmrppCommon::print_dap4(XMLWriter &xml, bool constrained /*false*/)
if (!bt.is_dap4() && bt.get_attr_table().get_size() > 0)
bt.get_attr_table().print_xml_writer(xml);

// This is the code added to libdap::BaseType::print_dap4(). jhrg 5/10/18
if (DmrppCommon::d_print_chunks && get_immutable_chunks().size() > 0)
print_chunks_element(xml, "dmrpp");
print_chunks_element(xml, DmrppCommon::d_ns_prefix);

if (xmlTextWriterEndElement(xml.get_writer()) < 0)
throw InternalErr(__FILE__, __LINE__, "Could not end " + bt.type_name() + " element");
Expand Down
4 changes: 3 additions & 1 deletion modules/dmrpp_module/DmrppCommon.h
Expand Up @@ -86,7 +86,9 @@ class DmrppCommon {
virtual char *read_atomic(const std::string &name);

public:
static bool d_print_chunks; ///< if true, print_dap4() prints chunk elements
static bool d_print_chunks; ///< if true, print_dap4() prints chunk elements
static string d_dmrpp_ns; ///< The DMR++ XML namespace
static string d_ns_prefix; ///< The XML namespace prefix to use

DmrppCommon() : d_deflate(false), d_shuffle(false)
{
Expand Down
2 changes: 1 addition & 1 deletion modules/hdf5_handler
Submodule hdf5_handler updated 43 files
+39 −0 HDF5BaseArray.cc
+7 −0 HDF5CF.cc
+3 −0 HDF5CF.h
+128 −0 HDF5CFArray.cc
+4 −1 HDF5CFArray.h
+99 −0 HDF5CFInt64.cc
+55 −0 HDF5CFInt64.h
+99 −0 HDF5CFUInt64.cc
+55 −0 HDF5CFUInt64.h
+3 −2 HDF5CFUtil.cc
+4 −5 HDF5Int64.cc
+33 −26 HDF5RequestHandler.cc
+5 −0 HDF5RequestHandler.h
+2 −2 Makefile.am
+9 −0 bes-testsuite/h5.cf/t_int64_dap4.h5.dap.bescmd
+85 −0 bes-testsuite/h5.cf/t_int64_dap4.h5.dap.bescmd.baseline
+9 −0 bes-testsuite/h5.cf/t_int64_dap4.h5.dmr.bescmd
+66 −0 bes-testsuite/h5.cf/t_int64_dap4.h5.dmr.bescmd.baseline
+3 −0 bes-testsuite/hdf5_handlerTest.at
+0 −8 bes-testsuite/hdf5_handlerTest.nasa.at
+3 −0 bes-testsuite/hdf5_handlerTest.valgrind.at
+907 −0 bes-testsuite/pydap.client/MLS-Aura_L2GP-BrO_v04-23-c03_2016d302.he_ddsdas.txt.exp
+78 −0 bes-testsuite/pydap.client/d_int_default_ddsdas.txt.exp
+2 −0 bes-testsuite/pydap.client/grid_1_2d_data.txt.exp
+62 −0 bes-testsuite/pydap.client/grid_1_2d_ddsdas.txt.exp
+111 −0 bes-testsuite/pydap.client/test.sh
+8 −0 bes-testsuite/pydap.client/test_urs.py
+60 −0 bes-testsuite/pydap.client/write_cf_das_dds.py
+21 −0 bes-testsuite/pydap.client/write_data_pydap.py
+154 −0 data/src/t_int64_dap4.c
+ data/t_int64_dap4.h5
+4 −4 gctp/include/gctp_prototypes.h
+1 −1 gctp/src/for_init.c
+1 −1 gctp/src/inv_init.c
+62 −12 gctp/src/sinfor.c
+101 −27 gctp/src/sininv.c
+57 −0 h5cfdaputil.cc
+5 −0 h5cfdaputil.h
+195 −4 h5commoncfdap.cc
+4 −0 h5commoncfdap.h
+70 −70 h5dmr.cc
+20 −1 h5gmcfdap.cc
+13 −0 heos5cfdap.cc

0 comments on commit e15a1e0

Please sign in to comment.