5 * Copyright 1993-2000 Lucent Technologies, Inc.
7 * Permission to use, copy, modify, and distribute this software and
8 * its documentation for any purpose and without fee is hereby
9 * granted, provided that the above copyright notice appear in all
10 * copies and that both that the copyright notice and warranty
11 * disclaimer appear in supporting documentation, and that the names
12 * of Lucent Technologies any of their entities not be used in
13 * advertising or publicity pertaining to distribution of the software
14 * without specific, written prior permission.
16 * Lucent Technologies disclaims all warranties with regard to this
17 * software, including all implied warranties of merchantability and
18 * fitness. In no event shall Lucent Technologies be liable for any
19 * special, indirect or consequential damages or any damages
20 * whatsoever resulting from loss of use, data or profits, whether in
21 * an action of contract, negligence or other tortuous action, arising
22 * out of or in connection with the use or performance of this
30 BLT_VECTOR_NOTIFY_UPDATE = 1, /* The vector's values has been updated */
31 BLT_VECTOR_NOTIFY_DESTROY /* The vector has been destroyed and the client
32 * should no longer use its data (calling
33 * Blt_FreeVectorId) */
36 typedef struct Blt_VectorIdRec *Blt_VectorId;
38 typedef void (Blt_VectorChangedProc) _ANSI_ARGS_((Tcl_Interp *interp,
39 ClientData clientData, Blt_VectorNotify notify));
42 double *valueArr; /* Array of values (possibly malloc-ed) */
43 int numValues; /* Number of values in the array */
44 int arraySize; /* Size of the allocated space */
45 double min, max; /* Minimum and maximum values in the vector */
46 int dirty; /* Indicates if the vector has been updated */
47 int reserved; /* Reserved for future use */
51 typedef double (Blt_VectorIndexProc) _ANSI_ARGS_((Blt_Vector * vecPtr));
54 BLT_MATH_FUNC_SCALAR = 1, /* The function returns a single double
56 BLT_MATH_FUNC_VECTOR /* The function processes the entire vector. */
60 * To be safe, use the macros below, rather than the fields of the
63 * The Blt_Vector is basically an opaque type. But it's also the
64 * actual memory address of the vector itself. I wanted to make the
65 * API as unobtrusive as possible. So instead of giving you a copy of
66 * the vector, providing various functions to access and update the
67 * vector, you get your hands on the actual memory (array of doubles)
68 * shared by all the vector's clients.
70 * The trade-off for speed and convenience is safety. You can easily
71 * break things by writing into the vector when other clients are
72 * using it. Use Blt_ResetVector to get around this. At least the
73 * macros are a reminder it isn't really safe to reset the data
74 * fields, except by the API routines.
76 #define Blt_VecData(v) ((v)->valueArr)
77 #define Blt_VecLength(v) ((v)->numValues)
78 #define Blt_VecSize(v) ((v)->arraySize)
79 #define Blt_VecMin(v) ((v)->min)
80 #define Blt_VecMax(v) ((v)->max)
81 #define Blt_VecDirty(v) ((v)->dirty)
83 EXTERN Blt_VectorId Blt_AllocVectorId _ANSI_ARGS_((Tcl_Interp *interp,
86 EXTERN void Blt_SetVectorChangedProc _ANSI_ARGS_((Blt_VectorId clientId,
87 Blt_VectorChangedProc * proc, ClientData clientData));
89 EXTERN void Blt_FreeVectorId _ANSI_ARGS_((Blt_VectorId clientId));
91 EXTERN int Blt_GetVectorById _ANSI_ARGS_((Tcl_Interp *interp,
92 Blt_VectorId clientId, Blt_Vector **vecPtrPtr));
94 EXTERN char *Blt_NameOfVectorId _ANSI_ARGS_((Blt_VectorId clientId));
96 EXTERN char *Blt_NameOfVector _ANSI_ARGS_((Blt_Vector *vecPtr));
98 EXTERN int Blt_VectorNotifyPending _ANSI_ARGS_((Blt_VectorId clientId));
100 EXTERN int Blt_CreateVector _ANSI_ARGS_((Tcl_Interp *interp, char *vecName,
101 int size, Blt_Vector ** vecPtrPtr));
103 EXTERN int Blt_GetVector _ANSI_ARGS_((Tcl_Interp *interp, char *vecName,
104 Blt_Vector **vecPtrPtr));
106 EXTERN int Blt_VectorExists _ANSI_ARGS_((Tcl_Interp *interp, char *vecName));
108 EXTERN int Blt_ResetVector _ANSI_ARGS_((Blt_Vector *vecPtr, double *dataArr,
109 int nValues, int arraySize, Tcl_FreeProc *freeProc));
111 EXTERN int Blt_ResizeVector _ANSI_ARGS_((Blt_Vector *vecPtr, int nValues));
113 EXTERN int Blt_DeleteVectorByName _ANSI_ARGS_((Tcl_Interp *interp,
116 EXTERN int Blt_DeleteVector _ANSI_ARGS_((Blt_Vector *vecPtr));
118 EXTERN int Blt_ExprVector _ANSI_ARGS_((Tcl_Interp *interp, char *expression,
119 Blt_Vector *vecPtr));
121 EXTERN void Blt_InstallIndexProc _ANSI_ARGS_((Tcl_Interp *interp,
122 char *indexName, Blt_VectorIndexProc * procPtr));
124 #endif /* _BLT_VECTOR_H */