2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* Copyright (c) 1995 FUJITSU LIMITED */
24 /* All Rights Reserved */
27 * $XConsortium: FolioObject.hh /main/5 1996/09/10 17:26:30 barstow $
29 * Copyright (c) 1991 HaL Computer Systems, Inc. All rights reserved.
30 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
31 * States. Use of a copyright notice is precautionary only and does not
32 * imply publication or disclosure.
34 * This software contains confidential information and trade secrets of HaL
35 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
36 * without the prior express written permission of HaL Computer Systems, Inc.
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject to
40 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
41 * Technical Data and Computer Software clause at DFARS 252.227-7013.
42 * HaL Computer Systems, Inc.
43 * 1315 Dell Avenue, Campbell, CA 95008
47 // Base Object for ALL Folio Objects
53 typedef void (FolioObject::* notify_handler_t)
54 (FolioObject *object, u_int notify_type,
55 void *call_data, void *client_data);
57 #if defined(__STDC__) || defined(hpux)
58 #define DEF_CLASS(C) \
59 virtual ClassType type() const; \
60 static ClassType C##Class
61 #define INIT_CLASS(C) \
62 ClassType C::type() const { return (C##Class); } \
63 ClassType C::C##Class = (size_t) &C::C##Class
65 #define DEF_CLASS(C) \
66 virtual ClassType type() const; \
67 static ClassType C/**/Class
68 #define INIT_CLASS(C) \
69 ClassType C::type() const { return (C/**/Class); } \
70 ClassType C::C/**/Class = (ClassType) &C::C/**/Class
73 typedef int ClassType;
78 #define FolioObjectLast 1
79 enum notify_types { DESTROYED = 0, _LAST = FolioObjectLast };
80 DEF_CLASS (FolioObject);
84 virtual ~FolioObject();
86 virtual const char *display_as();
88 #define AddDependent(CB, TYPE) \
89 add_dependent (this, (notify_handler_t)CB, TYPE)
90 #define AddDependentd(CB, TYPE, DATA) \
91 add_dependent (this, (notify_handler_t)CB, TYPE, DATA)
93 #if defined(SC3) || defined(__SunOS)
94 void add_dependent (FolioObject *dependent, notify_handler_t handler,
95 u_int notify_type, void *dependent_data = NULL);
97 void add_dependent (void *dependent, notify_handler_t handler,
98 u_int notify_type, void *dependent_data = NULL);
101 #define RemoveDependent(CB, TYPE) \
102 remove_dependent(this, (notify_handler_t)CB, TYPE)
103 #define RemoveDependentd(CB, TYPE, DATA) \
104 remove_dependent(this, (notify_handler_t)CB, TYPE, DATA)
106 #if defined(SC3) || defined(__SunOS)
107 void remove_dependent (FolioObject *dependent, notify_handler_t handler,
108 u_int notify_type, void *dependent_data = NULL);
110 void remove_dependent (void *dependent, notify_handler_t handler,
111 u_int notify_type, void *dependent_data = NULL);
113 void remove_depend_on (FolioObject *target, Dependent *d);
114 void release_dependents();
115 void release_depend_on_list();
117 #define Observe(TARG, TYPE, CB) \
118 observe (this, TARG, (notify_handler_t) CB, TYPE)
119 #define Observed(TARG, TYPE, CB, DATA) \
120 observe (this, TARG, (notify_handler_t) CB, TYPE, DATA)
122 #if defined(SC3) || defined(__SunOS)
123 void observe (FolioObject *real_this, FolioObject *target,
124 notify_handler_t callback, u_int notify_type,
125 void *client_data = NULL);
127 void observe (void *real_this, FolioObject *target,
128 notify_handler_t callback, u_int notify_type,
129 void *client_data = NULL);
133 { return (f_initialized); }
135 { return (f_status); }
137 protected: // functions
138 // Object states that it has changed - dependents notified.
139 // notify_type should be an enum provided by the object. Dependents
140 // should know about various object change types that it cares about.
141 // Dependents should ignore change types that it doesn't care about.
142 void notify (u_int notify_type, void *notify_data = NULL);
144 void self_destruct();
145 void setInitialized()
146 { f_initialized = TRUE; }
147 void unsetInitialized()
148 { f_initialized = FALSE; }
149 void setStatus (ErrorCode status)
150 { f_status = status; }
152 protected: // variables
155 Dependent *f_dependents;
156 DependOnList *f_depend_on_list;