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: root.h /main/6 1996/07/18 14:46:10 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.
54 #include "utility/funcs.h"
55 #include "utility/buffer.h"
56 #include "storage/rep_cell.h"
57 #include "storage/page.h"
58 #include "object/oid_t.h"
59 #include "object/c_codes.h"
60 #include "object/new_delete.h"
61 //#include "Exceptions.hh"
66 /************************************/
67 // constants used to name status bits
68 /************************************/
69 enum obj_mode_t { HEALTH,
77 /************************************/
78 // structure recording various status
80 /************************************/
83 unsigned reserved: 10; //
84 unsigned swap: 1; // swapped out allowed? (true, or false)
85 unsigned cdr: 1; // compacted disk rep? (true, or false)
86 unsigned ok: 1; // in good shape ? (true, or false)
87 unsigned persistent: 1; // persistent ? (true, or false)
88 unsigned update: 1; // updated ? (true, or false)
89 unsigned old_object :1; // old object? (true, or false)
90 unsigned ref_count: 16; // reference count [0, 2^16 - 1];
93 /************************************/
94 // structure recording io information
95 /************************************/
100 persistent_info(abs_storage* s = 0, c_code_t = 0,
101 mmdb_pos_t = 0, Boolean =0, Boolean = 0);
102 ~persistent_info() {};
105 abs_storage* storage;
108 Boolean persistent; // true -> on persisent store
109 // false -> on memory
110 Boolean old_object; // true -> object has been created on store
114 extern persistent_info transient_info;
116 /*************************************/
118 /*************************************/
120 #define THIS 0 // const to name this object
121 #define BASE_COMPONENT_INDEX 1 // const to name the 1st component
123 class root : public Destructable, public rep_cell
127 /***************************/
128 // instance-wise data
129 /***************************/
132 abs_storage* storage_ptr;
134 virtual void init_persistent_info(persistent_info* = &transient_info);
135 void set_c_code(c_code_t); // set class code
137 /***************************/
138 // static data and function
139 /***************************/
140 static void* heap_alloc( size_t sz );
143 root(c_code_t c_id = ROOT_CODE);
149 NEW_AND_DELETE_SIGNATURES(root);
152 MMDB_SIGNATURES(root);
154 // status set and get functions
155 virtual void set_mode(obj_mode_t, Boolean);
156 Boolean get_mode(obj_mode_t) const;
158 // reference count set and get functions
159 void reset_ref_count();
160 void set_ref_count(int delta);
163 abs_storage* get_store() { return storage_ptr; };
165 // status inquiry functions
166 virtual Boolean OK() const ; // in good shape ?
167 virtual ostream& memory_layout(root*, ostream& = cerr);
170 // value comparison functions
171 virtual Boolean value_EQ(root&, Boolean safe = true) const ;
172 virtual Boolean value_LS(root&, Boolean safe = true) const ;
176 const oid_t& my_oid() const ; // get oid
178 // ascii In and Out functions
179 virtual io_status asciiOut(ostream&) ; // output (ASCII)
180 virtual io_status asciiIn(istream&) ; // init from istream (ASCII)
182 friend ostream& operator<<(ostream&, const root&) ;
184 // compacted disk representation In and Out functions
185 virtual int cdr_sizeof();
186 virtual io_status cdrOut(buffer&);
187 virtual io_status cdrIn(buffer&);
188 virtual void commit() {}; // for commit all components
191 friend class template_mgr_t;
192 friend class service_mgr_t;
196 friend void initialize_MMDB();
197 friend void quit_MMDB();
202 typedef root* rootPtr;