OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / ALPHALINUX5 / util / ALPHALINUX5 / include / bltVector.h
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
29 typedef 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
36 typedef struct Blt_VectorIdRec *Blt_VectorId;
37
38 typedef void (Blt_VectorChangedProc) _ANSI_ARGS_((Tcl_Interp *interp,
39         ClientData clientData, Blt_VectorNotify notify));
40
41 typedef 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
51 typedef double (Blt_VectorIndexProc) _ANSI_ARGS_((Blt_Vector * vecPtr));
52
53 typedef 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_VecMin(v)           ((v)->min)
80 #define Blt_VecMax(v)           ((v)->max)
81 #define Blt_VecDirty(v)         ((v)->dirty)
82
83 EXTERN Blt_VectorId Blt_AllocVectorId _ANSI_ARGS_((Tcl_Interp *interp,
84         char *vecName));
85
86 EXTERN void Blt_SetVectorChangedProc _ANSI_ARGS_((Blt_VectorId clientId,
87         Blt_VectorChangedProc * proc, ClientData clientData));
88
89 EXTERN void Blt_FreeVectorId _ANSI_ARGS_((Blt_VectorId clientId));
90
91 EXTERN int Blt_GetVectorById _ANSI_ARGS_((Tcl_Interp *interp,
92         Blt_VectorId clientId, Blt_Vector **vecPtrPtr));
93
94 EXTERN char *Blt_NameOfVectorId _ANSI_ARGS_((Blt_VectorId clientId));
95
96 EXTERN char *Blt_NameOfVector _ANSI_ARGS_((Blt_Vector *vecPtr));
97
98 EXTERN int Blt_VectorNotifyPending _ANSI_ARGS_((Blt_VectorId clientId));
99
100 EXTERN int Blt_CreateVector _ANSI_ARGS_((Tcl_Interp *interp, char *vecName,
101         int size, Blt_Vector ** vecPtrPtr));
102
103 EXTERN int Blt_GetVector _ANSI_ARGS_((Tcl_Interp *interp, char *vecName,
104         Blt_Vector **vecPtrPtr));
105
106 EXTERN int Blt_VectorExists _ANSI_ARGS_((Tcl_Interp *interp, char *vecName));
107
108 EXTERN int Blt_ResetVector _ANSI_ARGS_((Blt_Vector *vecPtr, double *dataArr,
109         int nValues, int arraySize, Tcl_FreeProc *freeProc));
110
111 EXTERN int Blt_ResizeVector _ANSI_ARGS_((Blt_Vector *vecPtr, int nValues));
112
113 EXTERN int Blt_DeleteVectorByName _ANSI_ARGS_((Tcl_Interp *interp,
114         char *vecName));
115
116 EXTERN int Blt_DeleteVector _ANSI_ARGS_((Blt_Vector *vecPtr));
117
118 EXTERN int Blt_ExprVector _ANSI_ARGS_((Tcl_Interp *interp, char *expression,
119         Blt_Vector *vecPtr));
120
121 EXTERN void Blt_InstallIndexProc _ANSI_ARGS_((Tcl_Interp *interp, 
122         char *indexName, Blt_VectorIndexProc * procPtr));
123
124 #endif /* _BLT_VECTOR_H */