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 librararies 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: Pointer.C /main/4 1996/09/27 19:02:17 drk $
29 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
30 * All rights reserved. Unpublished -- rights reserved under
31 * the Copyright Laws of the United States. USE OF A COPYRIGHT
32 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
35 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
36 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
37 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
38 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
41 * RESTRICTED RIGHTS LEGEND
42 * Use, duplication, or disclosure by the Government is subject
43 * to the restrictions as set forth in subparagraph (c)(l)(ii)
44 * of the Rights in Technical Data and Computer Software clause
45 * at DFARS 252.227-7013.
47 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
54 Pointer<T>::Pointer (const Pointer<T> &pointer)
55 : f_pointer (pointer.f_pointer)
57 ON_DEBUG (printf ("Pointer& (0x%p) @ 0x%p\n", f_pointer, this));
58 if (f_pointer) f_pointer->reference();
62 Pointer<T>::Pointer (T *pointer)
65 ON_DEBUG (printf ("Pointer* (0x%p) @ 0x%p\n", f_pointer, this));
66 if (f_pointer) f_pointer->reference();
71 Pointer<T>::Pointer (T &object)
74 if (f_pointer) f_pointer->reference();
79 Pointer<T>::~Pointer()
81 ON_DEBUG (printf ("~Pointer (0x%p) @ 0x%p\n", f_pointer, this));
82 if (f_pointer) f_pointer->unreference();
87 Pointer<T>::operator= (T *pointer)
89 if (f_pointer) f_pointer->unreference();
91 ON_DEBUG (printf ("Pointer = 0x%p @ 0x%p\n", f_pointer, this));
92 if (f_pointer) f_pointer->reference();
98 Pointer<T>::operator= (const Pointer<T> &pointer)
100 if (f_pointer) f_pointer->unreference();
101 f_pointer = pointer.f_pointer;
102 ON_DEBUG (printf ("Pointer<T> = 0x%p @ 0x%p\n", f_pointer, this));
103 if (f_pointer) f_pointer->reference();
109 Pointer<T>::operator== (const Pointer<T> &pointer) const
111 ON_DEBUG (printf ("Pointer== this = 0x%p, ", this));
112 ON_DEBUG (printf ("Pointer== this->f_pointer = 0x%p, ", f_pointer));
113 ON_DEBUG (printf ("arg = 0x%p, ", &pointer));
114 ON_DEBUG (printf ("arg->f_pointer = 0x%p\n", pointer.f_pointer));
115 if ((f_pointer == NULL && pointer.f_pointer != NULL) ||
116 (f_pointer != NULL && pointer.f_pointer == NULL))
118 ON_DEBUG (puts ("1 Done Pointer =="));
121 else if (f_pointer == pointer.f_pointer)
123 ON_DEBUG (puts ("2 Done Pointer =="));
128 ON_DEBUG (puts ("3 Done Pointer =="));
129 return (*f_pointer == *pointer.f_pointer);
136 Pointer<T>::operator!= (const Pointer<T> &pointer) const
138 if ((f_pointer == NULL && pointer.f_pointer != NULL) ||
139 (f_pointer != NULL && pointer.f_pointer == NULL))
141 else if (f_pointer == NULL && pointer.f_pointer == NULL)
144 return (!(*f_pointer == *pointer.f_pointer));
150 Pointer<T>::operator==(const int) const
152 return f_pointer == NULL ;
157 Pointer<T>::operator!=(const int) const
159 return f_pointer != NULL ;