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
24 * $XConsortium: handler.cc /main/5 1996/07/18 14:41:25 drk $
26 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27 * All rights reserved. Unpublished -- rights reserved under
28 * the Copyright Laws of the United States. USE OF A COPYRIGHT
29 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
32 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
34 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject
40 * to the restrictions as set forth in subparagraph (c)(l)(ii)
41 * of the Rights in Technical Data and Computer Software clause
42 * at DFARS 252.227-7013.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
51 #include "object/handler.h"
52 #include "mgrs/managers.h"
54 //memory_pool handler::handler_space_pool;
55 extern memory_pool g_memory_pool;
58 store(0), obj_id(ground), obj_ptr(0)
62 handler::handler(const oid_t& id, abs_storage* s) :
63 store(s), obj_id(id), obj_ptr(0)
67 handler::handler(c_code_t cod, abs_storage* s) :
68 store(s), obj_id(cod, 0), obj_ptr(0)
71 operator->(); // to init the object from the store
74 handler::handler(rootPtr ptr, abs_storage* s) :
75 store(s), obj_id(ptr -> my_oid()), obj_ptr(ptr)
79 void handler::set(rootPtr ptr, abs_storage* s)
81 store = (abs_storage*)s;
84 obj_id.become(ptr -> my_oid());
92 managers::template_mgr -> quit_obj(store, obj_ptr);
100 void handler::destroy()
103 managers::template_mgr -> destroy_obj(store, obj_ptr);
110 if ( store ) store -> sync();
113 void handler::commit()
117 obj_ptr -> commit(); // save all its handler components
118 managers::template_mgr -> commit_obj(store, obj_ptr);
122 root* handler::operator ->()
126 if ( obj_ptr == 0 ) {
129 (obj_ptr && obj_id.eq(obj_ptr -> my_oid()) == false )
130 MESSAGE(cerr, "handler::operator ->()");
131 debug(cerr, (void*)obj_ptr);
133 if ( obj_ptr -> get_mode(SWAP_ALLOWED) == true )
134 //r_obj_cache.promote_object(store, obj_ptr);
137 //obj_ptr = r_obj_cache.init_object(store, obj_id);
139 if ( obj_id.icode() ) {
140 managers::template_mgr -> init_obj(store, obj_id.icode(), obj_ptr);
142 managers::template_mgr -> create_obj(store, obj_id.ccode(), obj_ptr);
146 ///////////////////////////////////////////////////////////////////
147 // update the handler side object id. Its class code may not
148 // be initialized as class code of a oid_t is not saved on the disk.
149 // We do not expect this check will degrade the performance as
150 // this init_object block is only called once for the operator->().
151 // Subsequent calls will bypass it as obj_ptr is not 0.
152 ///////////////////////////////////////////////////////////////////
153 obj_id.become(obj_ptr -> my_oid());
158 if ( store && obj_ptr == 0 ) {
159 debug(cerr, long(store));
160 debug(cerr, its_oid());
161 throw(stringException("null obj ptr"));
168 handler::operator root&()
170 return *(this -> operator->());
173 void* handler::operator new( size_t x )
175 //return (void*)g_memory_pool.alloc(x);
177 return ::operator new(x);
180 void handler::operator delete( void* ptr )
182 //g_memory_pool.free((char*)ptr);
184 ::operator delete(ptr);