1 /* Copyright (c) 1995 FUJITSU LIMITED */
2 /* All Rights Reserved */
5 * $XConsortium: FolioObject.hh /main/5 1996/09/10 17:26:30 barstow $
7 * Copyright (c) 1991 HaL Computer Systems, Inc. All rights reserved.
8 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
9 * States. Use of a copyright notice is precautionary only and does not
10 * imply publication or disclosure.
12 * This software contains confidential information and trade secrets of HaL
13 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
14 * without the prior express written permission of HaL Computer Systems, Inc.
16 * RESTRICTED RIGHTS LEGEND
17 * Use, duplication, or disclosure by the Government is subject to
18 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
19 * Technical Data and Computer Software clause at DFARS 252.227-7013.
20 * HaL Computer Systems, Inc.
21 * 1315 Dell Avenue, Campbell, CA 95008
25 // Base Object for ALL Folio Objects
31 typedef void (FolioObject::* notify_handler_t)
32 (FolioObject *object, u_int notify_type,
33 void *call_data, void *client_data);
35 #if defined(__STDC__) || defined(hpux) || defined(__osf__)
36 #define DEF_CLASS(C) \
37 virtual ClassType type() const; \
38 static ClassType C##Class
39 #define INIT_CLASS(C) \
40 ClassType C::type() const { return (C##Class); } \
41 ClassType C::C##Class = (size_t) &C::C##Class
43 #define DEF_CLASS(C) \
44 virtual ClassType type() const; \
45 static ClassType C/**/Class
46 #define INIT_CLASS(C) \
47 ClassType C::type() const { return (C/**/Class); } \
48 ClassType C::C/**/Class = (ClassType) &C::C/**/Class
52 typedef char * ClassType;
54 typedef int ClassType;
60 #define FolioObjectLast 1
61 enum notify_types { DESTROYED = 0, _LAST = FolioObjectLast };
62 DEF_CLASS (FolioObject);
66 virtual ~FolioObject();
68 virtual const char *display_as();
70 #define AddDependent(CB, TYPE) \
71 add_dependent (this, (notify_handler_t)CB, TYPE)
72 #define AddDependentd(CB, TYPE, DATA) \
73 add_dependent (this, (notify_handler_t)CB, TYPE, DATA)
75 #if defined(SC3) || defined(__osf__) || defined(USL) || defined(__SunOS)
76 void add_dependent (FolioObject *dependent, notify_handler_t handler,
77 u_int notify_type, void *dependent_data = NULL);
79 void add_dependent (void *dependent, notify_handler_t handler,
80 u_int notify_type, void *dependent_data = NULL);
83 #define RemoveDependent(CB, TYPE) \
84 remove_dependent(this, (notify_handler_t)CB, TYPE)
85 #define RemoveDependentd(CB, TYPE, DATA) \
86 remove_dependent(this, (notify_handler_t)CB, TYPE, DATA)
88 #if defined(SC3) || defined(__osf__) || defined(USL) || defined(__SunOS)
89 void remove_dependent (FolioObject *dependent, notify_handler_t handler,
90 u_int notify_type, void *dependent_data = NULL);
92 void remove_dependent (void *dependent, notify_handler_t handler,
93 u_int notify_type, void *dependent_data = NULL);
95 void remove_depend_on (FolioObject *target, Dependent *d);
96 void release_dependents();
97 void release_depend_on_list();
99 #define Observe(TARG, TYPE, CB) \
100 observe (this, TARG, (notify_handler_t) CB, TYPE)
101 #define Observed(TARG, TYPE, CB, DATA) \
102 observe (this, TARG, (notify_handler_t) CB, TYPE, DATA)
104 #if defined(SC3) || defined(__osf__) || defined(USL) || defined(__SunOS)
105 void observe (FolioObject *real_this, FolioObject *target,
106 notify_handler_t callback, u_int notify_type,
107 void *client_data = NULL);
109 void observe (void *real_this, FolioObject *target,
110 notify_handler_t callback, u_int notify_type,
111 void *client_data = NULL);
115 { return (f_initialized); }
117 { return (f_status); }
119 protected: // functions
120 // Object states that it has changed - dependents notified.
121 // notify_type should be an enum provided by the object. Dependents
122 // should know about various object change types that it cares about.
123 // Dependents should ignore change types that it doesn't care about.
124 void notify (u_int notify_type, void *notify_data = NULL);
126 void self_destruct();
127 void setInitialized()
128 { f_initialized = TRUE; }
129 void unsetInitialized()
130 { f_initialized = FALSE; }
131 void setStatus (ErrorCode status)
132 { f_status = status; }
134 protected: // variables
137 Dependent *f_dependents;
138 DependOnList *f_depend_on_list;