1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 #ifndef _CAT_H_
12 #define _CAT_H_
13 
14 #include <dx/dx.h>
15 #include <math.h>
16 
17 #define ICH InvalidComponentHandle
18 
19 /* max supported is 32 dimensional */
20 #define MAXRANK 32
21 
22 /* number of parallel tasks * (number of processors - 1) */
23 #define PFACTOR 4
24 
25 #define LISTJUMP 64
26 
27 #define DEFAULTCOMP "data"
28 #define STR_DATA "data"
29 #define STR_POSITIONS "positions"
30 
31 /* only used when computing categorize groups in parallel */
32 typedef struct {
33     Object h;		/* the categorize itself */
34     char *name;		/* the group member name */
35     int didwork;	/* global copy of didwork flag */
36     /* slicecnt here? */
37 } parinfo;
38 
39 /* values for the 'XXXset' flags below -
40  *  indicates whether or how the values were determined.
41  */
42 #define NOTSET   0	/* no value yet */
43 #define EXPLICIT 1	/* user-given input parameter to module */
44 #define BYOBJECT 2	/* statistics of input object used */
45 
46 #define CAT_SCALAR    0
47 #define CAT_STRING    1
48 #define CAT_ARBITRARY 2
49 
50 #define CAT_I_CASE	1
51 #define CAT_I_SPACE	2
52 #define CAT_I_LSPACE	4
53 #define CAT_I_RSPACE	8
54 #define CAT_I_LRSPACE	16
55 #define CAT_I_PUNCT	32
56 
57 /* parm list */
58 typedef struct _catinfo{
59     Object o;		/* use component of this object */
60     char *comp_name;	/* current component name in use */
61     char **comp_list;	/* component list to use */
62     int sort;  /* 0 - don't sort lookup, 1 - sort lookup (default) */
63     int comp_rank;
64     int comp_shape[30];
65     Array comp_array;	/* component array */
66     Pointer comp_data;	/* array data */
67     int free_data;	/* data was copied so must be freed */
68     int cat_type;	/* scalar, string, arbitrary */
69     Type comp_type;	/* component type */
70     uint num;		/* number in list */
71     int obj_size;	/* component object size, including shape and rank */
72     int count;          /* number of constituent components */
73     int intsize;	/* number of integers in object size */
74     int remainder;	/* bytes remaining after integer division */
75     Array new_comp;	/* New array component */
76     Error (*cmpcat)(struct _catinfo *cp, Pointer s, Pointer t);
77     int (*hashcmp)(Key searckey, Element element);
78     PseudoKey (*catkey) (Key key);
79     uint *cind;		/* component indices into built list. Pre-allocd full size */
80     uint ncats;		/* number of categories */
81     Array unique_array;	/* unique array of component values*/
82     int maxparallel;    /* max number of parallel tasks; based on nproc */
83     int goneparallel;	/* number of parallel tasks already spawned */
84     ICH invalid;        /* if set, there are invalid data values */
85     struct parinfo *p;	/* if computing in parallel, where to put the output */
86 } catinfo;
87 
88 typedef struct {
89     PseudoKey key;
90     uint index;
91     Pointer p;
92     catinfo *cp;
93 } hashelement;
94 
95 typedef struct {
96     hashelement *ph;
97     uint sortindex;
98     catinfo *cp;
99 } sortelement;
100 
101 typedef struct {
102     Pointer lookup;
103     Pointer value;
104     uint sortindex;
105     catinfo *cp;
106 } table_entry;
107 
108 Object _dxfCategorize(Object o, char **comp_list);
109 
110 Error _dxf_cat_FindCompType(catinfo *cp);
111 int _dxf_cat_cmp_char(catinfo *cp, Pointer s, Pointer t);
112 int _dxf_cat_cmp_ubyte(catinfo *cp, Pointer s, Pointer t);
113 int _dxf_cat_cmp_short(catinfo *cp, Pointer s, Pointer t);
114 int _dxf_cat_cmp_ushort(catinfo *cp, Pointer s, Pointer t);
115 int _dxf_cat_cmp_float(catinfo *cp, Pointer s, Pointer t);
116 int _dxf_cat_cmp_int(catinfo *cp, Pointer s, Pointer t);
117 int _dxf_cat_cmp_uint(catinfo *cp, Pointer s, Pointer t);
118 int _dxf_cat_cmp_double(catinfo *cp, Pointer s, Pointer t);
119 int _dxf_cat_cmp_str(catinfo *cp, Pointer s, Pointer t);
120 int _dxf_cat_cmp_any(catinfo *cp, Pointer s, Pointer t);
121 
122 int _dxf_cat_ignore(char *s, int ignore);
123 
124 #define INTERNALERROR DXSetError(ERROR_INTERNAL, \
125 		      "unexpected error, file %s line %d",  __FILE__, __LINE__)
126 
127 
128 typedef struct {
129     catinfo *data;
130     catinfo *lookup;
131     catinfo *value;
132     catinfo *dest;
133     table_entry *lut;
134     int ignore;
135     Pointer nfValue;  /* allow explicit return val for unfound */
136     int nfLen;
137 } lookupinfo;
138 
139 #endif /* _CAT_H_ */
140