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 /*
10 \section{Object class}
11 
12 Every object begins with an object preamble, which contains the class
13 number and a reference count.
14 */
15 
16 #include <dx/dx.h>
17 
18 /* the following make ANSI compilers happier */
19 struct shade;
20 struct buffer;
21 struct tile;
22 struct gather;
23 struct survey;
24 struct count;
25 
26 CLASS Object
27 DEFINES Error  Delete(Object)
28 DEFINES Error  Shade(Object, struct shade *)
29 DEFINES Object BoundingBox(Object, Point*, Matrix*, int)
30 DEFINES Object Paint(Object, struct buffer *, int, struct tile *)
31 DEFINES Object Gather(Object, struct gather *, struct tile *)
32 DEFINES Error  Partition(Object, int*, int, Object*, int)
33 DEFINES Object GetType(Object, Type*, Category*, int*, int*);
34 DEFINES Object Copy(Object, enum _dxd_copy)
35 IMPLEMENTS Delete BoundingBox Shade
36 
37 #define NATTRIBUTES 2			/* number of attributes in object */
38 
39 struct object {				/* object preamble */
40     struct object_class *class;		/* class vector */
41     Class class_id;			/* class id (for debugging only!) */
42     lock_type lock;			/* for Reference and Delete */
43     int count;				/* reference count */
44     int tag;				/* object tag */
45     struct attribute {			/* object attributes */
46 	char *name;			/* attribute name */
47 	Object value;			/* attribue value */
48     } local[NATTRIBUTES], *attributes;	/* the attributes */
49     int nattributes;			/* number of attributes */
50     int attr_alloc;			/* allocated space for attributes */
51 };
52 
53 #if 0 /* was if OPTIMIZED */
54 #define CHECK(obj, cls) { \
55     if (!obj) \
56 	return ERROR; \
57 }
58 #else
59 #define CHECK(obj, cls) { \
60     if (!obj) \
61         return ERROR; \
62     if (DXGetObjectClass((Object)(obj)) != cls) \
63         DXErrorReturn(ERROR_BAD_CLASS, "called with object of wrong class"); \
64 }
65 #endif
66 /**
67 This macro eases the task of checking argument class.  Note: This is not needed
68 when a method implementation is called, because {\tt o} and its class will
69 both have been checked by the method.
70 **/
71 
72 Object _dxf_NewObject(struct object_class *class);
73 /**
74 This internal routine is called only by other {\tt New...} routines to
75 create and initialize the object preamble.
76 **/
77 
78 Object _dxf_CopyObject(Object new, Object old, enum _dxd_copy copy);
79 /**
80 Copies the portion of the data of {\tt old} managed by the {\tt
81 Object} class to {\tt new}.  This is provided for subclasses of {\tt Object}
82 to use in their copy routines.  Copying works something like creating
83 an object.  Every class {\tt X} that implements copying should provide
84 an {\tt \_CopyX} routine that copies relevant data from an old object
85 to a new object, so that subclass copy routines may call this routine
86 to copy the superclass's data.  The {\tt CopyX} routine just creates a
87 new object of the appropriate type and then calls {\tt \_CopyX} to copy
88 the data.
89 **/
90