20 #ifndef _das_variable_h_
21 #define _das_variable_h_
33 #define D2V_MAX_VEC_LEN 4
36 D2V_CONST, D2V_SEQUENCE, D2V_ARRAY, D2V_UNARY_OP, D2V_BINARY_OP
40 #error macro _D already defined, pick something else
42 #define _D DASIDX_UNUSED
55 #define SCALAR_0 0, (NULL), 0
56 #define SCALAR_1(I) 1, (int8_t[DASIDX_MAX]){I,_D,_D,_D,_D,_D,_D,_D}, 0
57 #define SCALAR_2(I,J) 2, (int8_t[DASIDX_MAX]){I,J,_D,_D,_D,_D,_D,_D}, 0
58 #define SCALAR_3(I,J,K) 3, (int8_t[DASIDX_MAX]){I,J,K,_D,_D,_D,_D,_D}, 0
59 #define SCALAR_4(I,J,K,L) 4, (int8_t[DASIDX_MAX]){I,J,K,L,_D,_D,_D,_D}, 0
60 #define SCALAR_5(I,J,K,L,M) 5, (int8_t[DASIDX_MAX]){I,J,K,L,M,_D,_D,_D}, 0
61 #define SCALAR_6(I,J,K,L,M,N) 6, (int8_t[DASIDX_MAX]){I,J,K,L,M,N,_D,_D}, 0
62 #define SCALAR_7(I,J,K,L,M,N,O) 7, (int8_t[DASIDX_MAX]){I,J,K,L,M,N,O,_D}, 0
63 #define SCALAR_8(I,J,K,L,M,N,O,P) 8, (int8_t[DASIDX_MAX]){I,J,K,L,M,N,O,P}, 0
65 #define VEC_0 0, (int8_t[DASIDX_MAX]){_D,_D,_D,_D,_D,_D,_D,_D}, 1
66 #define VEC_1(I) 1, (int8_t[DASIDX_MAX]){I,_D,_D,_D,_D,_D,_D,_D}, 1
67 #define VEC_2(I,J) 2, (int8_t[DASIDX_MAX]){I,J,_D,_D,_D,_D,_D,_D}, 1
68 #define VEC_3(I,J,K) 3, (int8_t[DASIDX_MAX]){I,J,K,_D,_D,_D,_D,_D}, 1
69 #define VEC_4(I,J,K,L) 4, (int8_t[DASIDX_MAX]){I,J,K,L,_D,_D,_D,_D}, 1
70 #define VEC_5(I,J,K,L,M) 5, (int8_t[DASIDX_MAX]){I,J,K,L,M,_D,_D,_D}, 1
71 #define VEC_6(I,J,K,L,M,N) 6, (int8_t[DASIDX_MAX]){I,J,K,L,M,N,_D,_D}, 1
72 #define VEC_7(I,J,K,L,M,N,O) 7, (int8_t[DASIDX_MAX]){I,J,K,L,M,N,O,_D}, 1
86 DAS_API
void das_varindex_merge(
int nRank, ptrdiff_t* pDest, ptrdiff_t* pSrc);
89 DAS_API ptrdiff_t das_varlength_merge(ptrdiff_t nLeft, ptrdiff_t nRight);
91 #define D2V_EXP_UNITS 0x02
92 #define D2V_EXP_RANGE 0x04
93 #define D2V_EXP_SUBEX 0x08
94 #define D2V_EXP_INTR 0x10
95 #define D2V_EXP_TYPE 0x20
247 typedef struct das_variable{
248 enum var_type vartype;
277 const char* (*id)(
const struct das_variable* pThis);
280 int (*shape)(
const struct das_variable* pThis, ptrdiff_t* pShape);
287 int (*intrShape)(
const struct das_variable* pThis, ptrdiff_t* pComp);
298 char* (*expression)(
const struct das_variable* pThis,
char* sBuf,
int nLen,
299 unsigned int uFlags);
302 ptrdiff_t (*lengthIn)(
303 const struct das_variable* pThis,
int nIdx, ptrdiff_t* pLoc
308 const struct das_variable* pThis, ptrdiff_t* pIdx,
das_datum* pDatum
312 const struct das_variable* pThis,
const ubyte* pCheck,
das_val_type vt
316 bool (*isNumeric)(
const struct das_variable* pThis);
319 const struct das_variable* pThis,
int nRank,
const ptrdiff_t* pMin,
320 const ptrdiff_t* pMax
324 int (*incRef)(
struct das_variable* pThis);
331 int (*decRef)(
struct das_variable* pThis);
334 bool (*degenerate)(
const struct das_variable* pThis,
int iIndex);
379 DAS_API
DasVar* new_DasVarUnary_tok(
int nOpTok,
const DasVar* pVar);
428 const char* sId,
DasVar* pLeft,
const char* sOp,
DasVar* pRight
482 const char* sId,
das_val_type vt,
size_t vSz,
const void* pMin,
483 const void* pInterval,
int nExtRank, int8_t* pMap,
int nIntRank,
587 DasAry* pAry,
int nExtRank, int8_t* pMap,
int nIntRank,
588 const char* sFrame, ubyte nFrameId, ubyte frametype, ubyte nDirs,
902 const DasVar* pThis,
int nRank,
const ptrdiff_t* pMin,
const ptrdiff_t* pMax
A dynamic buffer with multi-dimensional array style access.
const char * das_units
Handle SI and other units, with accommodations for Epoch systems, from units.h.
Definition: units.h:139
das_val_type
Enumeration of types stored in Das Array (DasAry) objects from value.h.
Definition: value.h:64
Dynamic recursive ragged arrays.
Definition: array.h:270
Das2 fexible variables.
Definition: variable.h:247
DAS_API bool DasVar_isComposite(const DasVar *pVar)
Is this a simple variable or more than one variable combinded via operators?
DAS_API bool DasVar_orthoginal(const DasVar *pThis, const DasVar *pOther)
Getting data from a variable.
const char * DasVar_id(const DasVar *pThis)
Get id token for variable, may be NULL for anoymous vars.
DAS_API bool DasVar_isFill(const DasVar *pThis, const ubyte *pCheck, das_val_type vt)
Check to see if a value is a fill value for this variable.
das_units DasVar_units(const DasVar *pThis)
Get the units for the values.
das_val_type DasVar_valType(const DasVar *pThis)
Get the type of values held by the variable.
DAS_API DasVar * new_DasVarArray(DasAry *pAry, int nExtRank, int8_t *pMap, int nIntRank)
Create a variable backed by an Array.
enum var_type DasVar_type(const DasVar *pThis)
Get the type of variable.
DAS_API DasVar * new_DasConstant(const char *sId, const das_datum *pDm)
Create a constant value on the heap.
DAS_API DasVar * new_DasVarSeq(const char *sId, das_val_type vt, size_t vSz, const void *pMin, const void *pInterval, int nExtRank, int8_t *pMap, int nIntRank, das_units units)
Create a simple linear sequence variable.
DAS_API DasAry * DasVar_subset(const DasVar *pThis, int nRank, const ptrdiff_t *pMin, const ptrdiff_t *pMax)
Copy a subset of a variable into a memory buffer.
size_t DasVar_valSize(const DasVar *pThis)
Get the size in bytes of each value.
DAS_API ptrdiff_t DasVar_lengthIn(const DasVar *pThis, int nIdx, ptrdiff_t *pLoc)
Return the current max value index value + 1 for any partial index.
DAS_API int DasVar_shape(const DasVar *pThis, ptrdiff_t *pShape)
Return the current shape of this variable.
DAS_API DasVar * new_DasVarVecAry(DasAry *pAry, int nExtRank, int8_t *pMap, int nIntRank, const char *sFrame, ubyte nFrameId, ubyte frametype, ubyte nDirs, const ubyte *pDir)
Create a vector backed by an array.
int ref_DasVar(const DasVar *pThis)
Get number of references.
DAS_API int dec_DasVar(DasVar *pThis)
Decrement the reference count on a variable.
DAS_API DasVar * new_DasVarBinary(const char *sId, DasVar *pLeft, const char *sOp, DasVar *pRight)
Create a new variable from a binary operation on two other variables.
DAS_API int DasVar_intrShape(const DasVar *pThis, ptrdiff_t *pShape)
Return the internal composition of this variable.
DAS_API DasVar * new_DasVarUnary(const char *sOp, const DasVar *pVar)
Create a new variable from unary operation on an existing variable.
DAS_API bool DasVar_get(const DasVar *pThis, ptrdiff_t *pIdx, das_datum *pDatum)
Get a value given an index.
DAS_API char * DasVar_toStr(const DasVar *pThis, char *sBuf, int nLen)
Get a string representation of this variable.
DAS_API int inc_DasVar(DasVar *pThis)
Increment the reference count on a variable.
DAS_API DasAry * DasVarAry_getArray(DasVar *pThis)
Get the backing array if present.
void * pUser
User data pointer.
Definition: variable.h:344
DAS_API bool DasVar_isNumeric(const DasVar *pThis)
Are the values in this variable convertable to doubles?
An atomic data processing unit, and it's units.
Definition: datum.h:67
Defines units used for items in the stream, most notably time units that reference an epoch and a ste...
DAS_API bool DasVar_degenerate(const DasVar *pThis, int iIndex)
Does a given extern index even matter the this variable?
DAS_API void das_varindex_prndir(bool bFastLast)
Set index printing direction.