libdap::D4Enum Class Reference

Holds a DAP4 enumeration. More...

`#include <D4Enum.h>`

Inheritance diagram for libdap::D4Enum:

## Public Member Functions

unsigned int | buf2val (void **) override
void | compute_checksum (Crc32 &checksum) override
| D4Enum (const D4Enum &src)
| D4Enum (const string &name, const string &dataset, Type type)
| D4Enum (const string &name, const string &enum_type)
| D4Enum (const string &name, Type type)
void | deserialize (D4StreamUnMarshaller &um, DMR &dmr) override
void | dump (ostream &strm) const override
| dumps information about this object
Type | element_type ()
virtual D4EnumDef * | enumeration () const
bool | is_signed () const
D4Enum & | operator= (const D4Enum &rhs)
bool | ops (BaseType *b, int op) override
void | print_val (ostream &out, string space="", bool print_decl_p=true) override
void | print_xml_writer (XMLWriter &xml, bool constrained) override
BaseType * | ptr_duplicate () override
void | serialize (D4StreamMarshaller &m, DMR &dmr, bool filter=false) override
| Serialize a D4Enum Use the (integer) data type associated with an Enumeration definition to serialize the value of a D4Enum variable. This send just the bits that correspond to the declared type, not all 64-bits of storage used by a scalar D4Enum.
void | set_element_type (Type type)
virtual void | set_enumeration (D4EnumDef *enum_def)
void | set_is_signed (Type t)
template<typename T>
void | set_value (T v, bool check_value=true)
| Set the value of the Enum Template member function to set the value of the Enum. The libdap library contains versions of this member function for dods_byte, ..., dods_uint64 types for the parameter `v`.
std::vector< BaseType * > * | transform_to_dap2 (AttrTable *parent_attr_table) override
| Convert an Enum to a DAP2 int type.
unsigned int | val2buf (void *, bool) override
template<typename T>
void | value (T *v) const
| Get the value of an Enum Get the value of this instance. The caller is responsible for using a type T than can hold the value.
unsigned int | width (bool=false) const override

Return the number of bytes in an instance of an Enum. This returns the number of bytes an instance of Enum will use in memory or on the wire (i.e., in a serialization of the type). On the wire this type uses the minimum number of bytes for the given Enum type - an Enum with type Byte uses one byte, Int16 uses two, and so on. In memory, a single instance uses 64-bits but a vector of these will use the same number of bytes per value as the on-the-wire representation.

int64_t | width_ll (bool=false) const override

## Protected Attributes

uint64_t | d_buf

## Friends

class | D4EnumTest

## Detailed Description

Holds a DAP4 enumeration.

Note
  When constructed a type for the Enum must be specified. If it is not an integer type, the Enum will use unsigned int 64. This is not the same as the enumeration type that is defined using the Enumeration XML element in the DMR - that information is stored in additional fields and used for checking values and printing the variable's declaration, but not for the internal storage of values.

Todo
  Note the hack to remove the union...

Definition at line 53 of file D4Enum.h.

## Constructor & Destructor Documentation

## D4Enum() [1/4]

libdap::D4Enum::D4Enum | ( | const string & | name,
|  | const string & | enum_type )

Definition at line 268 of file D4Enum.cc.

## D4Enum() [2/4]

libdap::D4Enum::D4Enum | ( | const string & | name,
|  | Type | type )

Definition at line 277 of file D4Enum.cc.

## D4Enum() [3/4]

libdap::D4Enum::D4Enum | ( | const string & | name,
|  | const string & | dataset,
|  | Type | type )

Definition at line 284 of file D4Enum.cc.

## D4Enum() [4/4]

libdap::D4Enum::D4Enum | ( | const D4Enum & | src | ) |

inline

Definition at line 100 of file D4Enum.h.

## ~D4Enum()

virtual libdap::D4Enum::~D4Enum | ( |  | ) |

inline virtual

Definition at line 110 of file D4Enum.h.

## Member Function Documentation

## buf2val()

unsigned int libdap::D4Enum::buf2val | ( | void ** | val | ) |

override

Definition at line 520 of file D4Enum.cc.

## compute_checksum()

void libdap::D4Enum::compute_checksum | ( | Crc32 & | checksum | ) |

override

Definition at line 317 of file D4Enum.cc.

## deserialize()

void libdap::D4Enum::deserialize | ( | D4StreamUnMarshaller & | um,
|  | DMR & | dmr )

override

Definition at line 425 of file D4Enum.cc.

## dump()

void libdap::D4Enum::dump | ( | ostream & | strm | ) | const

override

dumps information about this object

Displays the pointer value of this instance and information about this instance.

Parameters

  strm | C++ i/o stream to dump the information to

Returns
  void

Definition at line 679 of file D4Enum.cc.

## element_type()

Type libdap::D4Enum::element_type | ( |  | ) |

inline

Definition at line 117 of file D4Enum.h.

## enumeration()

virtual D4EnumDef * libdap::D4Enum::enumeration | ( |  | ) | const

inline virtual

Definition at line 112 of file D4Enum.h.

## is_signed()

bool libdap::D4Enum::is_signed | ( |  | ) | const

inline

Definition at line 120 of file D4Enum.h.

## operator=()

D4Enum & libdap::D4Enum::operator= | ( | const D4Enum & | rhs | ) |

inline

Definition at line 102 of file D4Enum.h.

## ops()

bool libdap::D4Enum::ops | ( | BaseType * | b,
|  | int | op )

override

Definition at line 633 of file D4Enum.cc.

## print_val()

void libdap::D4Enum::print_val | ( | ostream & | out,
|  | string | space = "",
|  | bool | print_decl_p = true )

override

Definition at line 574 of file D4Enum.cc.

## print_xml_writer()

void libdap::D4Enum::print_xml_writer | ( | XMLWriter & | xml,
|  | bool | constrained )

override

Write the XML representation of this variable. This method is used to build the DDX XML response.

Parameters

  out | Destination output stream
  space | Use this to indent child declarations. Default is "".
  constrained | If true, only print this if it's part part of the current projection. Default is False.

Definition at line 602 of file D4Enum.cc.

## ptr_duplicate()

BaseType * libdap::D4Enum::ptr_duplicate | ( |  | ) |

inline override

Definition at line 115 of file D4Enum.h.

## serialize()

void libdap::D4Enum::serialize | ( | D4StreamMarshaller & | m,
|  | DMR & | dmr,
|  | bool | filter = false )

override

Serialize a D4Enum Use the (integer) data type associated with an Enumeration definition to serialize the value of a D4Enum variable. This send just the bits that correspond to the declared type, not all 64-bits of storage used by a scalar D4Enum.

Parameters

  m |
  dmr | Unused
  eval | Unused
  filter | Unused

Exceptions

  Error | is thrown if the value needs to be read and that operation fails.

Definition at line 389 of file D4Enum.cc.

## set_element_type()

void libdap::D4Enum::set_element_type | ( | Type | type | ) |

inline

Definition at line 118 of file D4Enum.h.

## set_enumeration()

void libdap::D4Enum::set_enumeration | ( | D4EnumDef * | enum_def | ) |

virtual

Definition at line 312 of file D4Enum.cc.

## set_is_signed()

void libdap::D4Enum::set_is_signed | ( | Type | t | ) |

Definition at line 350 of file D4Enum.cc.

## set_value()

template<typename T>

template void libdap::D4Enum::set_value< dods_uint64 > | ( | T | v,
|  | bool | check_value = true )

inline

Set the value of the Enum Template member function to set the value of the Enum. The libdap library contains versions of this member function for dods_byte, ..., dods_uint64 types for the parameter `v`.

Parameters

  v | Set the Enum to this value.
  check_value | If true test the value 'v' against the type of the Enum. Defaults to true.

Definition at line 143 of file D4Enum.h.

## transform_to_dap2()

vector< BaseType * > * libdap::D4Enum::transform_to_dap2 | ( | AttrTable * | parent_attr_table | ) |

override

Convert an Enum to a DAP2 int type.

Build a DAP2 integer type that matches the D4Enum's internal type and then add an attribute table to that new variable that holds the D4Enum's symbolic name and value mapping.

Parameters

  attr | AttrTable pointer, ignored by this method.

Definition at line 90 of file D4Enum.cc.

## val2buf()

unsigned int libdap::D4Enum::val2buf | ( | void * | val,
|  | bool | )

override

Definition at line 482 of file D4Enum.cc.

## value()

template<typename T>

template void libdap::D4Enum::value< dods_uint64 > | ( | T * | v | ) | const

inline

Get the value of an Enum Get the value of this instance. The caller is responsible for using a type T than can hold the value.

Parameters

  v | Value-result parameter; return the value of the Enum in this variable.

Definition at line 131 of file D4Enum.h.

## width()

unsigned int libdap::D4Enum::width | ( | bool | = false | ) | const

inline override

Return the number of bytes in an instance of an Enum. This returns the number of bytes an instance of Enum will use in memory or on the wire (i.e., in a serialization of the type). On the wire this type uses the minimum number of bytes for the given Enum type - an Enum with type Byte uses one byte, Int16 uses two, and so on. In memory, a single instance uses 64-bits but a vector of these will use the same number of bytes per value as the on-the-wire representation.

Note
  The private method m_type_width() returns the byte width used for the on-the-wire representation of values.

Returns
  The number of bytes used by a value.

Definition at line 164 of file D4Enum.h.

## width_ll()

int64_t libdap::D4Enum::width_ll | ( | bool | = false | ) | const

inline override

Definition at line 166 of file D4Enum.h.

## Friends And Related Symbol Documentation

## D4EnumTest

friend class D4EnumTest

friend

Definition at line 54 of file D4Enum.h.

## Member Data Documentation

## d_buf

uint64_t libdap::D4Enum::d_buf

protected

Definition at line 59 of file D4Enum.h.

The documentation for this class was generated from the following files:

- D4Enum.h
- D4Enum.cc