48#ifndef constraint_evaluator_h
49#include "ConstraintEvaluator.h"
81class Vector :
public BaseType {
86 int64_t d_length_ll = -1;
89 BaseType *d_proto =
nullptr;
92 char *d_buf =
nullptr;
94 vector<BaseType *> d_compound_buf;
99 unsigned int d_capacity = 0;
100 uint64_t d_capacity_ll = 0;
102 bool d_too_big_for_dap2 =
false;
104 friend class MarshallerTest;
108 template <
typename T>
void value_worker(T *v)
const;
109 template <
typename T>
void value_ll_worker(T *v)
const;
110 template <
typename T>
void value_worker(vector<unsigned int> *indices, T *b)
const;
111 template <
typename T>
void value_ll_worker(vector<uint64_t> *indices, T *b)
const;
113 template <
typename T>
bool set_value_worker(T *v,
int sz);
114 template <
typename T>
bool set_value_ll_worker(T *v, int64_t sz);
115 template <
typename T>
bool set_value_worker(vector<T> &v,
int sz);
116 template <
typename T>
bool set_value_ll_worker(vector<T> &v, int64_t sz);
118 bool m_is_cardinal_type()
const;
119 int64_t m_create_cardinal_data_buffer_for_type(int64_t num_elements);
120 void m_delete_cardinal_data_buffer();
121 template <
class CardType>
void m_set_cardinal_values_internal(
const CardType *fromArray, int64_t num_elements);
124 void m_duplicate(
const Vector &v);
127 Vector(
const string &n, BaseType *v,
const Type &t,
bool is_dap4 =
false);
128 Vector(
const string &n,
const string &d, BaseType *v,
const Type &t,
bool is_dap4 =
false);
129 Vector(
const Vector &rhs);
133 Vector &operator=(
const Vector &rhs);
163 virtual BaseType *prototype()
const {
return d_proto; }
176 void set_name(
const std::string &name)
override;
178 int element_count(
bool leaves)
override;
180 void set_send_p(
bool state)
override;
182 void set_read_p(
bool state)
override;
191 unsigned int width(
bool constrained =
false)
const override {
195 return length() * d_proto->width(constrained);
203 int64_t
width_ll(
bool constrained =
false)
const override {
return length_ll() * d_proto->width_ll(constrained); }
210 int length()
const override {
return d_length; }
218 int64_t
length_ll()
const override {
return d_length_ll; }
225 void intern_data(ConstraintEvaluator &eval, DDS &dds)
override;
226 bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m,
bool ce_eval =
true)
override;
227 bool deserialize(UnMarshaller &um, DDS *dds,
bool reuse =
false)
override;
232 void serialize(D4StreamMarshaller &m, DMR &dmr,
bool filter =
false)
override;
233 void deserialize(D4StreamUnMarshaller &um, DMR &dmr)
override;
235 unsigned int val2buf(
void *val,
bool reuse =
false)
override;
236 unsigned int buf2val(
void **val)
override;
238 uint64_t val2buf_ll(
void *val,
bool reuse =
false);
239 uint64_t buf2val_ll(
void **val);
241 void set_vec(
unsigned int i, BaseType *val);
244 void set_vec_ll(uint64_t i, BaseType *val);
245 void set_vec_nocopy_ll(uint64_t i, BaseType *val);
248 void vec_resize_ll(int64_t l);
253 virtual uint64_t get_value_capacity_ll()
const;
255 void set_value_capacity(uint64_t l);
265 virtual bool set_value(dods_byte *val,
int sz);
266 virtual bool set_value(dods_int8 *val,
int sz);
267 virtual bool set_value(dods_int16 *val,
int sz);
268 virtual bool set_value(dods_uint16 *val,
int sz);
269 virtual bool set_value(dods_int32 *val,
int sz);
270 virtual bool set_value(dods_uint32 *val,
int sz);
271 virtual bool set_value(dods_int64 *val,
int sz);
272 virtual bool set_value(dods_uint64 *val,
int sz);
273 virtual bool set_value(dods_float32 *val,
int sz);
274 virtual bool set_value(dods_float64 *val,
int sz);
275 virtual bool set_value(
string *val,
int sz);
277 virtual bool set_value_ll(dods_byte *val, int64_t sz);
278 virtual bool set_value_ll(dods_int8 *val, int64_t sz);
279 virtual bool set_value_ll(dods_int16 *val, int64_t sz);
280 virtual bool set_value_ll(dods_uint16 *val, int64_t sz);
281 virtual bool set_value_ll(dods_int32 *val, int64_t sz);
282 virtual bool set_value_ll(dods_uint32 *val, int64_t sz);
283 virtual bool set_value_ll(dods_int64 *val, int64_t sz);
284 virtual bool set_value_ll(dods_uint64 *val, int64_t sz);
285 virtual bool set_value_ll(dods_float32 *val, int64_t sz);
286 virtual bool set_value_ll(dods_float64 *val, int64_t sz);
287 virtual bool set_value_ll(
string *val, int64_t sz);
289 virtual bool set_value(vector<dods_byte> &val,
int sz);
290 virtual bool set_value(vector<dods_int8> &val,
int sz);
291 virtual bool set_value(vector<dods_int16> &val,
int sz);
292 virtual bool set_value(vector<dods_uint16> &val,
int sz);
293 virtual bool set_value(vector<dods_int32> &val,
int sz);
294 virtual bool set_value(vector<dods_uint32> &val,
int sz);
295 virtual bool set_value(vector<dods_int64> &val,
int sz);
296 virtual bool set_value(vector<dods_uint64> &val,
int sz);
297 virtual bool set_value(vector<dods_float32> &val,
int sz);
298 virtual bool set_value(vector<dods_float64> &val,
int sz);
299 virtual bool set_value(vector<string> &val,
int sz);
301 virtual bool set_value_ll(vector<dods_byte> &val, int64_t sz);
302 virtual bool set_value_ll(vector<dods_int8> &val, int64_t sz);
303 virtual bool set_value_ll(vector<dods_int16> &val, int64_t sz);
304 virtual bool set_value_ll(vector<dods_uint16> &val, int64_t sz);
305 virtual bool set_value_ll(vector<dods_int32> &val, int64_t sz);
306 virtual bool set_value_ll(vector<dods_uint32> &val, int64_t sz);
307 virtual bool set_value_ll(vector<dods_int64> &val, int64_t sz);
308 virtual bool set_value_ll(vector<dods_uint64> &val, int64_t sz);
309 virtual bool set_value_ll(vector<dods_float32> &val, int64_t sz);
310 virtual bool set_value_ll(vector<dods_float64> &val, int64_t sz);
311 virtual bool set_value_ll(vector<string> &val, int64_t sz);
313 virtual void value(dods_byte *b)
const;
314 virtual void value(dods_int8 *b)
const;
315 virtual void value(dods_int16 *b)
const;
316 virtual void value(dods_uint16 *b)
const;
317 virtual void value(dods_int32 *b)
const;
318 virtual void value(dods_uint32 *b)
const;
319 virtual void value(dods_int64 *b)
const;
320 virtual void value(dods_uint64 *b)
const;
321 virtual void value(dods_float32 *b)
const;
322 virtual void value(dods_float64 *b)
const;
323 virtual void value(vector<string> &b)
const;
325 virtual void value(vector<unsigned int> *indices, dods_byte *b)
const;
326 virtual void value(vector<unsigned int> *indices, dods_int8 *b)
const;
327 virtual void value(vector<unsigned int> *indices, dods_int16 *b)
const;
328 virtual void value(vector<unsigned int> *indices, dods_uint16 *b)
const;
329 virtual void value(vector<unsigned int> *indices, dods_int32 *b)
const;
330 virtual void value(vector<unsigned int> *indices, dods_uint32 *b)
const;
331 virtual void value(vector<unsigned int> *indices, dods_int64 *b)
const;
332 virtual void value(vector<unsigned int> *indices, dods_uint64 *b)
const;
333 virtual void value(vector<unsigned int> *indices, dods_float32 *b)
const;
334 virtual void value(vector<unsigned int> *indices, dods_float64 *b)
const;
335 virtual void value(vector<unsigned int> *index, vector<string> &b)
const;
337 virtual void value_ll(vector<uint64_t> *indices, dods_byte *b)
const;
338 virtual void value_ll(vector<uint64_t> *indices, dods_int8 *b)
const;
339 virtual void value_ll(vector<uint64_t> *indices, dods_int16 *b)
const;
340 virtual void value_ll(vector<uint64_t> *indices, dods_uint16 *b)
const;
341 virtual void value_ll(vector<uint64_t> *indices, dods_int32 *b)
const;
342 virtual void value_ll(vector<uint64_t> *indices, dods_uint32 *b)
const;
343 virtual void value_ll(vector<uint64_t> *indices, dods_int64 *b)
const;
344 virtual void value_ll(vector<uint64_t> *indices, dods_uint64 *b)
const;
345 virtual void value_ll(vector<uint64_t> *indices, dods_float32 *b)
const;
346 virtual void value_ll(vector<uint64_t> *indices, dods_float64 *b)
const;
347 virtual void value_ll(vector<uint64_t> *index, vector<string> &b)
const;
349 virtual void *
value();
351 BaseType *
var(
const string &name =
"",
bool exact_match =
true, btp_stack *s =
nullptr)
override;
352 BaseType *
var(
const string &name, btp_stack &s)
override;
354 virtual BaseType *
var(
unsigned int i);
355 virtual BaseType *var_ll(uint64_t i);
357 void add_var(BaseType *v, Part p = nil)
override;
358 void add_var_nocopy(BaseType *v, Part p = nil)
override;
360 bool check_semantics(
string &msg,
bool all =
false)
override;
362 bool is_dap4_projected(std::vector<std::string> &projected_dap4_inventory)
override;
364 void dump(ostream &strm)
const override;
top level DAP object to house generic methods
virtual void set_length(int64_t)
Set the number of elements for this variable. use -1 to indicate nothing set.
virtual uint64_t set_value_slice_from_row_major_vector(const Vector &rowMajorData, uint64_t startElement)
virtual int64_t length_ll() const
Get the number of elements in this variable This version of the function deprecates length() which is...
virtual unsigned int get_value_capacity() const
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
virtual void reserve_value_capacity_ll(uint64_t numElements)
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=nullptr)
Returns a pointer to a member of a constructor class.
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 int length() const
How many elements are in this variable? Uses -1 in places.
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
virtual int64_t width_ll(bool constrained=false) const
Return the number of bytes needed to hold the array data.
virtual void reserve_value_capacity(unsigned int numElements)
virtual unsigned int buf2val(void **val)=0
Reads the class data.
virtual BaseType * set_prototype(BaseType *btp)
Change the Vector/Array element type.
vector< BaseType * > & get_compound_buf()
virtual void set_value(D4SeqValues &values)
Set the internal value. The 'values' of a D4Sequence is a vector of vectors of BaseType* objects....
virtual void set_length_ll(int64_t)
Set the number of elements in this variable This version of the function deprecates set_length() whic...
virtual unsigned int width(bool constrained=false) const
Returns the width of the data, in bytes.
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 D4SeqValues value() const
Get the values for this D4Sequence This method returns a reference to the values held by the instance...
void set_vec_nocopy(unsigned int i, BaseType *val)
Sets element i to value val. Set the ith element to val. Extend the vector if needed.
virtual void reserve_value_capacity_ll_byte(uint64_t numBytes)
vector< string > & get_str()
virtual void clear_local_data()
The basic data type for the DODS DAP types. */.
char * get_buf()
Holds a one-dimensional collection of DAP2 data types.
virtual unsigned int val2buf(void *val, bool reuse=false)=0
Loads class data.
void set_vec(unsigned int i, BaseType *val)
Sets element i to value val.