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: container_desc.cc /main/5 1996/07/18 14:49:46 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 "schema/container_desc.h"
53 container_desc::container_desc(int code, const char* comment) :
54 index_nms(10), stored_object_desc(code, comment)
58 container_desc::~container_desc()
60 int ind = index_nms.first();
65 idx_nm = (char*)index_nms[ind];
73 void container_desc::set_index_nm(const char* str)
75 if ( index_nms.count() <= index_nms.no_elmts() ) {
76 index_nms.expandWith(2*index_nms.count());
79 int i = index_nms.no_elmts() + 1;
82 char *x = new char[l+1];
86 //cerr << "container_desc::set_index_nm(): this = " << this << ", str=(long)" << (long)str << " i=" << i << endl;
87 index_nms.insert(x, i);
89 index_nms.reset_elmts(i);
92 ostream& container_desc::asciiOut(ostream& out, Boolean last)
94 if ( index_nms.no_elmts() == 0 ) {
95 stored_object_desc::asciiOut(out, last);
99 stored_object_desc::asciiOut(out, false);
101 int ind = index_nms.first();
105 for ( int i=0; i<index_nms.count(); i++ ) {
106 //cerr << "ind=" << ind << endl;
107 index_nm = (char*)index_nms[ind];
111 //cerr << "this=" << this << "; index_nm=(long)" << (long)index_nm << " ind=" << ind << endl;
112 if ( num_printed < index_nms.no_elmts() )
113 desc_print(out, index_nm);
115 if ( last == true ) {
116 desc_print_end(out, index_nm);
119 desc_print(out, index_nm);
129 int ind = index_nms.first();
132 cerr << "this=" << this << "; index_nms.no_elmts()=" << index_nms.no_elmts();
133 cerr << "first()=" << ind << endl;
140 if ( index_nms[ind] == 0 )
143 } while ( ind != -1 );
145 ////////////////////////////
146 stored_object_desc::asciiOut(out, false);
148 cerr << "last_ind=" << last_ind << endl;
149 cerr << "ind=" << ind << endl;
151 while ( ind != last_ind ) {
153 index_nm = (char*)index_nms[ind];
157 cerr << "this=" << this << "; index_nm=(long)" << (long)index_nm << " ind=" << ind << endl;
158 desc_print(out, index_nm);
162 index_nm = (char*)index_nms[last_ind];
165 desc_print_end(out, index_nm);
167 desc_print(out, index_nm);
175 container_desc::init_index_array(object_dict& dict,
176 c_index_handlerPtr*& index_array,
179 c_index_handlerPtr* tmp_index_array =
180 new c_index_handlerPtr[index_nms.no_elmts()];
185 int ind = index_nms.first();
188 while ( ind != -1 ) {
190 idx_nm = (char*)index_nms[ind];
194 c_index_handler* idx_handler =
195 (c_index_handler*)dict.get_handler(idx_nm);
197 idx_array_sz = MAX(idx_array_sz, (*idx_handler) -> bound_to());
199 tmp_index_array[i++] = idx_handler;
203 //cerr << "ind=" << ind << endl;
208 index_array = new c_index_handlerPtr[idx_array_sz];
210 for ( ind=0; ind<idx_array_sz; ind++ )
211 index_array[ind] = 0;
213 for ( ind=0; ind<i; ind++ ) {
214 int pos = (*tmp_index_array[ind]) -> bound_to();
215 index_array[pos] = tmp_index_array[ind];
218 delete tmp_index_array;
221 //////////////////////////////////////////////////////////////////////
223 //////////////////////////////////////////////////////////////////////
225 set_desc::set_desc() : container_desc(SET_CODE, "container set")
229 handler* set_desc::init_handler(object_dict& dict)
231 page_storage* store = (page_storage*)dict.get_store(get_store_nm());
233 if ( v_oid.icode() == 0 ) {
234 v_handler_ptr = new handler(SET_CODE, store);
235 desc::set_oid(v_handler_ptr -> its_oid());
237 v_handler_ptr = new cset_handler(v_oid, store);
239 /////////////////////////////
241 /////////////////////////////
242 c_index_handlerPtr* idx_array = 0; int sz = 0;
244 init_index_array(dict, idx_array, sz) ;
246 //debug(cerr, v_handler_ptr -> its_oid());
247 //debug(cerr, int(v_handler_ptr -> operator ->()));
249 (*(cset_handler*)v_handler_ptr) -> init_data_member(idx_array, sz);
251 return v_handler_ptr;
254 //////////////////////////////////////////////////////////////////////
256 //////////////////////////////////////////////////////////////////////
258 list_desc::list_desc() : container_desc(DL_LIST_CODE, "container list")
262 handler* list_desc::init_handler(object_dict& dict)
264 page_storage* store = (page_storage*)dict.get_store(get_store_nm());
266 if ( v_oid.icode() == 0 ) {
267 v_handler_ptr = new handler(DL_LIST_CODE, store);
268 desc::set_oid(v_handler_ptr -> its_oid());
270 v_handler_ptr = new dl_list_handler(v_oid, store);
272 /////////////////////////////
274 /////////////////////////////
275 c_index_handlerPtr* idx_array = 0; int sz = 0;
277 init_index_array(dict, idx_array, sz) ;
279 //debug(cerr, v_handler_ptr -> its_oid());
280 (*(dl_list_handler*)v_handler_ptr) -> init_data_member(idx_array, sz);
282 return v_handler_ptr;