libdap
Updated for version 3.20.3
libdap4 is an implementation of OPeNDAP's DAP protocol.
|
56 #include "Structure.h"
60 #include "D4Attributes.h"
62 #include "XMLWriter.h"
63 #include "D4BaseTypeFactory.h"
65 #include "InternalErr.h"
69 #include "DapIndent.h"
88 DBG(cerr <<
"In BaseType::m_duplicate for " << bt.
name() << endl);
92 d_dataset = bt.d_dataset;
93 d_is_read = bt.d_is_read;
94 d_is_send = bt.d_is_send;
95 d_in_selection = bt.d_in_selection;
96 d_is_synthesized = bt.d_is_synthesized;
98 d_parent = bt.d_parent;
107 d_is_dap4 = bt.d_is_dap4;
109 DBG(cerr <<
"Exiting BaseType::m_duplicate for " << bt.
name() << endl);
126 BaseType::BaseType(
const string &n,
const Type &t,
bool is_dap4)
127 : d_name(n), d_type(t), d_dataset(
""), d_is_read(false), d_is_send(false),
128 d_parent(0), d_attributes(0), d_is_dap4(is_dap4),
129 d_in_selection(false), d_is_synthesized(false)
145 : d_name(n), d_type(t), d_dataset(d), d_is_read(false), d_is_send(false),
146 d_parent(0), d_attributes(0), d_is_dap4(is_dap4),
147 d_in_selection(false), d_is_synthesized(false)
153 DBG(cerr <<
"In BaseTpe::copy_ctor for " << copy_from.
name() << endl);
157 BaseType::~BaseType()
159 DBG2(cerr <<
"Entering ~BaseType (" <<
this <<
")" << endl);
164 DBG2(cerr <<
"Exiting ~BaseType" << endl);
168 BaseType::operator=(
const BaseType &rhs)
170 DBG(cerr <<
"Entering BaseType::operator=" << endl);
176 DBG(cerr <<
"Exiting BaseType::operator=" << endl);
187 oss <<
"BaseType (" <<
this <<
"):" << endl
188 <<
" _name: " <<
name() << endl
190 <<
" _dataset: " << d_dataset << endl
191 <<
" _read_p: " << d_is_read << endl
192 <<
" _send_p: " << d_is_send << endl
193 <<
" _synthesized_p: " << d_is_synthesized << endl
194 <<
" d_parent: " << d_parent << endl
195 <<
" d_attr: " << hex << &d_attr << dec << endl;
222 dest->set_is_dap4(
true);
258 std::vector<BaseType *> *
265 dest->set_is_dap4(
false);
268 vector<BaseType *> *result =
new vector<BaseType *>();
269 result->push_back(dest);
285 strm << DapIndent::LMarg <<
"BaseType::dump - ("
286 << (
void *)
this <<
")" << endl ;
287 DapIndent::Indent() ;
289 strm << DapIndent::LMarg <<
"name: " <<
name() << endl ;
290 strm << DapIndent::LMarg <<
"type: " <<
type_name() << endl ;
291 strm << DapIndent::LMarg <<
"dataset: " << d_dataset << endl ;
292 strm << DapIndent::LMarg <<
"read_p: " << d_is_read << endl ;
293 strm << DapIndent::LMarg <<
"send_p: " << d_is_send << endl ;
294 strm << DapIndent::LMarg <<
"synthesized_p: " << d_is_synthesized << endl ;
295 strm << DapIndent::LMarg <<
"parent: " << (
void *)d_parent << endl ;
296 strm << DapIndent::LMarg <<
"attributes: " << endl ;
297 DapIndent::Indent() ;
300 d_attributes->
dump(strm);
304 DapIndent::UnIndent() ;
306 DapIndent::UnIndent() ;
446 return d_is_synthesized;
457 d_is_synthesized = state;
527 if (!d_is_synthesized) {
562 DBG2(cerr <<
"Calling BaseType::set_send_p() for: " << this->
name()
604 BaseType::set_attributes_nocopy(D4Attributes *attrs)
606 d_attributes = attrs;
638 DBG(cerr << __func__ <<
"() - BEGIN name:'" <<
name() <<
"'" << endl);
641 DBG(cerr << __func__ <<
"() - at: "<< (
void *) at << endl);
645 at->set_is_global_attribute(
false);
646 DBG(cerr << __func__ <<
"() - Processing AttrTable: " << at->
get_name() << endl);
650 DBG(cerr << __func__ <<
"() - Attribute '" << at->
get_name(at_p) <<
"' is type: " << at->
get_type(at_p) << endl);
662 DBG(cerr << __func__ <<
"() - Adding container '" << at->
get_name(at_p) << endl);
666 DBG(cerr << __func__ <<
"() - Found child var: '"<< bt->
type_name()<<
" " << bt->
name() <<
" (address:" << (
void *) bt <<
")" << endl);
667 DBG(cerr << __func__ <<
"() - Skipping container '" << at->
get_name(at_p) << endl);
671 DBG(cerr << __func__ <<
"() - Adding Attribute '" << at->
get_name(at_p) << endl);
678 DBG(cerr << __func__ <<
"() - Unable to locate AttrTable '" <<
name() <<
"' SKIPPING" << endl);
697 return d_in_selection;
712 d_in_selection = state;
728 && !
dynamic_cast<Vector *
>(parent)
730 throw InternalErr(
"Call to set_parent with incorrect variable type.");
809 throw InternalErr(__FILE__, __LINE__,
"BaseType::add_var unimplemented");
815 throw InternalErr(__FILE__, __LINE__,
"BaseType::add_var_nocopy unimplemented");
896 throw InternalErr(
"Unimplemented BaseType::read() method called for the variable named: " +
name());
902 #if USE_LOCAL_TIMEOUT_SCHEME
905 DBG2(cerr <<
"BaseType::intern_data: " <<
name() << endl);
908 #if USE_LOCAL_TIMEOUT_SCHEME
931 throw InternalErr(__FILE__, __LINE__,
"The DAP2 serialize() method has not been implemented for " +
type_name());
937 throw InternalErr(__FILE__, __LINE__,
"The DAP2 deserialize() method has not been implemented for " +
type_name());
943 throw InternalErr(__FILE__, __LINE__,
"The DAP4 serialize() method has not been implemented for " +
type_name());
949 throw InternalErr(__FILE__, __LINE__,
"The DAP4 deserialize() method has not been implemented for " +
type_name());
996 bool constraint_info,
bool constrained)
999 print_decl(oss, space, print_semi, constraint_info, constrained);
1000 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
1047 bool constraint_info,
bool constrained)
1051 if (constrained && !
send_p())
1056 if (constraint_info) {
1058 out <<
": Send True" ;
1060 out <<
": Send False" ;
1086 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
1101 fwrite(xml.get_doc(),
sizeof(
char), xml.get_doc_size(), out);
1116 out << xml.get_doc();
1128 if (constrained && !
send_p())
1131 if (xmlTextWriterStartElement(xml.get_writer(), (
const xmlChar*)
type_name().c_str()) < 0)
1134 if (!
name().empty())
1135 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
1136 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
1144 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
1203 bool sem = (d_type != dods_null_c &&
name().length());
1206 msg =
"Every variable must have both a name and a type\n";
1254 throw InternalErr(__FILE__, __LINE__,
"Unimplemented operator.");
1276 throw InternalErr(__FILE__, __LINE__,
"Unimplemented operator.");
1295 throw InternalErr(__FILE__, __LINE__,
"not implemented");
1297 return width(constrained);
Evaluate a constraint expression.
virtual void set_attr_table(const AttrTable &at)
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
bool is_constructor_type(Type t)
Returns true if the instance is a constructor (i.e., Structure, Sequence or Grid) type variable.
virtual bool is_constructor_type() const
Returns true if the instance is a constructor (i.e., Structure, Sequence or Grid) type variable.
virtual Attr_iter attr_end()
virtual BaseType * ptr_duplicate()=0
virtual void intern_data()
Read data into this variable.
virtual void transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.
abstract base class used to unmarshall/deserialize dap data objects
virtual string toString()
virtual string name() const
Returns the name of the class instance.
void m_duplicate(const BaseType &bt)
Perform a deep copy.
virtual void print_decl(FILE *out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
A class for software fault reporting.
Part
Names the parts of multi-section constructor data types.
abstract base class used to marshal/serialize dap data objects
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net, then remove them from the object.
virtual void print_dap4(XMLWriter &xml, bool constrained=false)
virtual void set_name(const string &n)
Sets the name of the class instance.
virtual string get_type(const string &name)
Get the type name of an attribute within this attribute table.
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Holds a one-dimensional collection of DAP2 data types.
virtual D4Attributes * attributes()
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
Type
Identifies the data type.
bool is_simple_type(Type t)
Returns true if the instance is a numeric, string or URL type variable.
virtual bool ops(BaseType *b, int op)
Evaluate relational operators.
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
AttrTable * get_AttrTable(const std::string name)
copy attributes from DAP4 to DAP2
top level DAP object to house generic methods
bool is_vector_type(Type t)
Returns true if the instance is a vector (i.e., array) type variable.
libdap base object for common functionality of libdap objects
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
virtual unsigned int width(bool constrained=false) const
How many bytes does this use Return the number of bytes of storage this variable uses....
virtual bool send_p()
Should this variable be sent?
virtual bool is_in_selection()
Is this variable part of the current selection?
void print_xml_writer(XMLWriter &xml)
virtual std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
DAP4 to DAP2 transform.
virtual BaseType * get_parent() const
virtual void set_parent(BaseType *parent)
virtual void dump(ostream &strm) const
dumps information about this object
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Read data from the stream made by D4StreamMarshaller.
virtual void print_xml(FILE *out, string space=" ", bool constrained=false)
virtual void set_in_selection(bool state)
virtual void set_synthesized_p(bool state)
string D4type_name(Type t)
Returns the type of the class instance as a string. Supports all DAP4 types and not the DAP2-only typ...
virtual bool read_p()
Has this variable been read?
string D2type_name(Type t)
Returns the type of the class instance as a string. Supports all DAP2 types and not the DAP4-only typ...
virtual vector< string > * get_attr_vector(const string &name)
Get a vector-valued attribute.
Contains the attributes for a dataset.
virtual bool d4_ops(BaseType *b, int op)
Evaluator a relop for DAP4.
virtual bool is_vector_type() const
Returns true if the instance is a vector (i.e., array) type variable.
virtual void compute_checksum(Crc32 &checksum)=0
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
virtual Type type() const
Returns the type of the class instance.
virtual void set_type(const Type &t)
Sets the type of the class instance.
virtual void dump(ostream &strm) const
dumps information about this object
string www2id(const string &in, const string &escape, const string &except)
virtual void transfer_attributes(AttrTable *at)
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual bool is_simple_type() const
Returns true if the instance is a numeric, string or URL type variable.
virtual void add_var(BaseType *bt, Part part=nil)
Add a variable.
virtual Attr_iter attr_begin()
virtual bool synthesized_p()
virtual bool read()
Read data into a local buffer.
virtual std::string FQN() const
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
string id2www(string in, const string &allowable)
virtual AttrTable & get_attr_table()
The basic data type for the DODS DAP types.
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual void dump(ostream &strm) const
dumps information about this object
virtual string get_name() const
Get the name of this attribute table.
virtual AttrType get_attr_type(const string &name)
Get the type of an attribute.
virtual string type_name() const
Returns the type of the class instance as a string.
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
virtual int element_count(bool leaves=false)
Count the members of constructor types.
virtual unsigned int append_attr(const string &name, const string &type, const string &value)
Add an attribute to the table.
virtual void set_send_p(bool state)
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...