2dd1d4b40ca041ad383814de600b7fede48023f2
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / dti_excs / Destructable_il.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 // $TOG: Destructable_il.hh /main/9 1998/04/20 10:06:23 mgreess $
24
25 // /////////////////////////////////////////////////////////////////
26 // class constructor
27 // /////////////////////////////////////////////////////////////////
28
29 inline
30 Destructable::Destructable()
31 {
32   // Make sure the application has initialized this library.
33 #ifdef DEBUG
34   Exceptions::check_initialized();
35 #endif
36
37   if (in_stack_set_size())
38     Jump_Environment::register_object (this);
39   PRINTF (("  Constructed obj @ %p\n", this));
40 }
41
42
43 // NOTE:  Both the copy and assignment constructors below init
44 // f_constructed to 0, which is going to be bogus if the derived
45 // class checks this value.  This is a problem because we don't
46 // know if the derived class uses the default copy constructor or
47 // not.  If it does we want f_constructed to be set to 1, otherwise
48 // we want it to be set to 0 until its methods complete.
49 // Ugh! 
50
51 // /////////////////////////////////////////////////////////////////
52 // copy constructor
53 // /////////////////////////////////////////////////////////////////
54
55 inline
56 Destructable::Destructable (const Destructable &)
57 {
58   if (in_stack_set_size())
59     Jump_Environment::register_object (this);
60   PRINTF (("  Copy ctor @ %p\n", this));
61 }
62
63
64 // /////////////////////////////////////////////////////////////////
65 // assignment operator
66 // /////////////////////////////////////////////////////////////////
67
68 inline Destructable &
69 Destructable::operator = (const Destructable &)
70 {
71   // Assignment operator does nothing to preserve state of original
72   // creation of this object.  State information is permanently
73   // associated with a Destructable object and cannot be assigned to. 
74   PRINTF (("Assign op @ %p\n", this));
75   return (*this);
76 }
77
78
79 // /////////////////////////////////////////////////////////////////
80 // class destructor
81 // /////////////////////////////////////////////////////////////////
82
83 // There is currently no checking here for objects that have not
84 // been constructed.  It is possible for this to be called for such
85 // objects if an exception is thrown in a constructor.  See test18.C. 
86
87 inline
88 Destructable::~Destructable()
89 {
90   if (in_stack())
91     Jump_Environment::unregister_object (this);
92 }
93
94 // /////////////////////////////////////////////////////////////////
95 // destruct function
96 // /////////////////////////////////////////////////////////////////
97
98 // This code relies on the fact that in cfront 2.1 this qualified
99 // call to the destructor will actually call the virtual destructor. 
100
101 #if (!defined(hpux)) && (!defined(__uxp__)) && (CC_VERSION < 30)
102 inline void
103 Destructable::destruct()
104 {
105 #if defined(linux) || defined(CSRG_BASED) || defined(sun)
106   delete this;
107 #else
108   // Have to call this here since some compilers don't allow
109   // qualified calls through object pointer.
110   Destructable::~Destructable();
111 #endif
112 }
113 #endif