Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / object / root.h
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 librararies 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 /*
24  * $XConsortium: root.h /main/6 1996/07/18 14:46:10 drk $
25  *
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
30  * OR DISCLOSURE.
31  * 
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
36  * INTERNATIONAL, LTD.
37  * 
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.
43  *
44  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
45  *                  1315 Dell Avenue
46  *                  Campbell, CA  95008
47  * 
48  */
49
50
51 #ifndef _root_h
52 #define _root_h 1
53
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"
62
63 class abs_storage;
64
65
66 /************************************/
67 // constants used to name status bits
68 /************************************/
69 enum obj_mode_t { HEALTH, 
70                   SWAP_ALLOWED, 
71                   PERSISTENT, 
72                   UPDATE, 
73                   OLD_OBJECT, 
74                   CDR 
75                 };
76
77 /************************************/
78 // structure recording various status 
79 // of an object
80 /************************************/
81 struct status_t 
82 {
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];
91 };
92
93 /************************************/
94 // structure recording io information
95 /************************************/
96 class persistent_info
97 {
98 public:
99
100    persistent_info(abs_storage* s = 0, c_code_t = 0,
101        mmdb_pos_t = 0, Boolean =0, Boolean = 0);
102    ~persistent_info() {};
103    
104    Boolean cdr;
105    abs_storage* storage;
106    c_code_t  class_code;
107    mmdb_pos_t position;
108    Boolean persistent; // true -> on persisent store
109                        // false -> on memory 
110    Boolean old_object; // true -> object has been created on store
111                        
112 };
113
114 extern persistent_info transient_info;
115
116 /*************************************/
117 // The root class
118 /*************************************/
119
120 #define THIS                 0 // const to name this object
121 #define BASE_COMPONENT_INDEX 1 // const to name the 1st component
122
123 class root : public Destructable, public rep_cell
124 {
125 protected:
126
127 /***************************/
128 // instance-wise data 
129 /***************************/
130    oid_t f_oid;
131    status_t status;
132    abs_storage* storage_ptr;
133
134    virtual void init_persistent_info(persistent_info* = &transient_info);
135    void set_c_code(c_code_t); // set class code
136
137 /***************************/
138 // static data and function
139 /***************************/
140    static void* heap_alloc( size_t sz );
141
142 public:
143    root(c_code_t c_id = ROOT_CODE);
144    root(const oid_t& );
145    root(const root&);
146    virtual ~root() ;
147
148 #ifdef C_API
149    NEW_AND_DELETE_SIGNATURES(root);
150 #endif
151
152    MMDB_SIGNATURES(root);
153
154 // status set and get functions
155    virtual void set_mode(obj_mode_t, Boolean);
156    Boolean get_mode(obj_mode_t) const;
157
158 // reference count set and get functions
159    void reset_ref_count();
160    void set_ref_count(int delta);
161    int get_ref_count();
162
163    abs_storage* get_store() { return storage_ptr; };
164
165 // status inquiry functions
166    virtual Boolean OK() const ;        // in good shape ? 
167    virtual ostream& memory_layout(root*, ostream& = cerr);
168
169 /*
170 // value comparison functions 
171    virtual Boolean value_EQ(root&, Boolean safe = true) const ;
172    virtual Boolean value_LS(root&, Boolean safe = true) const ;
173 */
174
175 // export functions 
176    const oid_t& my_oid() const ;      // get oid
177
178 // ascii In and Out functions
179    virtual io_status asciiOut(ostream&) ; // output (ASCII)
180    virtual io_status asciiIn(istream&) ;  // init from istream (ASCII)  
181
182    friend ostream& operator<<(ostream&, const root&) ;  
183
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
189
190
191    friend class template_mgr_t;
192    friend class service_mgr_t;
193    friend class oid;
194
195 #ifdef C_API
196    friend void initialize_MMDB();
197    friend void quit_MMDB();
198 #endif
199
200 };
201
202 typedef root* rootPtr;
203
204
205 #endif