source: trunk/kitgen/8.x/blt/generic/bltVector.h@ 196

Last change on this file since 196 was 175, checked in by demin, 12 years ago

initial commit

File size: 4.6 KB
Line 
1
2/*
3 * bltVector.h --
4 *
5 * Copyright 1993-2000 Lucent Technologies, Inc.
6 *
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.
15 *
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
23 * software.
24 */
25
26#ifndef _BLT_VECTOR_H
27#define _BLT_VECTOR_H
28
29typedef enum {
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) */
34} Blt_VectorNotify;
35
36typedef struct Blt_VectorIdStruct *Blt_VectorId;
37
38typedef void (Blt_VectorChangedProc) _ANSI_ARGS_((Tcl_Interp *interp,
39 ClientData clientData, Blt_VectorNotify notify));
40
41typedef struct {
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 */
48
49} Blt_Vector;
50
51typedef double (Blt_VectorIndexProc) _ANSI_ARGS_((Blt_Vector * vecPtr));
52
53typedef enum {
54 BLT_MATH_FUNC_SCALAR = 1, /* The function returns a single double
55 * precision value. */
56 BLT_MATH_FUNC_VECTOR /* The function processes the entire vector. */
57} Blt_MathFuncType;
58
59/*
60 * To be safe, use the macros below, rather than the fields of the
61 * structure directly.
62 *
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.
69 *
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.
75 */
76#define Blt_VecData(v) ((v)->valueArr)
77#define Blt_VecLength(v) ((v)->numValues)
78#define Blt_VecSize(v) ((v)->arraySize)
79#define Blt_VecDirty(v) ((v)->dirty)
80
81EXTERN double Blt_VecMin _ANSI_ARGS_((Blt_Vector *vPtr));
82EXTERN double Blt_VecMax _ANSI_ARGS_((Blt_Vector *vPtr));
83
84EXTERN Blt_VectorId Blt_AllocVectorId _ANSI_ARGS_((Tcl_Interp *interp,
85 char *vecName));
86
87EXTERN void Blt_SetVectorChangedProc _ANSI_ARGS_((Blt_VectorId clientId,
88 Blt_VectorChangedProc * proc, ClientData clientData));
89
90EXTERN void Blt_FreeVectorId _ANSI_ARGS_((Blt_VectorId clientId));
91
92EXTERN int Blt_GetVectorById _ANSI_ARGS_((Tcl_Interp *interp,
93 Blt_VectorId clientId, Blt_Vector **vecPtrPtr));
94
95EXTERN char *Blt_NameOfVectorId _ANSI_ARGS_((Blt_VectorId clientId));
96
97EXTERN char *Blt_NameOfVector _ANSI_ARGS_((Blt_Vector *vecPtr));
98
99EXTERN int Blt_VectorNotifyPending _ANSI_ARGS_((Blt_VectorId clientId));
100
101EXTERN int Blt_CreateVector _ANSI_ARGS_((Tcl_Interp *interp, char *vecName,
102 int size, Blt_Vector ** vecPtrPtr));
103
104EXTERN int Blt_GetVector _ANSI_ARGS_((Tcl_Interp *interp, char *vecName,
105 Blt_Vector **vecPtrPtr));
106
107EXTERN int Blt_VectorExists _ANSI_ARGS_((Tcl_Interp *interp, char *vecName));
108
109EXTERN int Blt_ResetVector _ANSI_ARGS_((Blt_Vector *vecPtr, double *dataArr,
110 int nValues, int arraySize, Tcl_FreeProc *freeProc));
111
112EXTERN int Blt_ResizeVector _ANSI_ARGS_((Blt_Vector *vecPtr, int nValues));
113
114EXTERN int Blt_DeleteVectorByName _ANSI_ARGS_((Tcl_Interp *interp,
115 char *vecName));
116
117EXTERN int Blt_DeleteVector _ANSI_ARGS_((Blt_Vector *vecPtr));
118
119EXTERN void Blt_InstallIndexProc _ANSI_ARGS_((Tcl_Interp *interp,
120 char *indexName, Blt_VectorIndexProc * procPtr));
121
122#endif /* _BLT_VECTOR_H */
Note: See TracBrowser for help on using the repository browser.