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: inv_lists.cc /main/5 1996/07/18 14:37: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 "index/inv_lists.h"
52 #include "utility/funcs.h"
55 inv_lists::inv_lists(c_code_t c_cd) : oid_list(c_cd)
57 //set_mode(HEALTH, true);
60 inv_lists::~inv_lists()
64 Boolean inv_lists::insert_list_pinned(int index, oid_list& lst)
66 if ( lst.count() == 0 ) {
67 throw(boundaryException(0, lst.count(), index));
70 oid_list_handler list_hd(lst.count(), storage_ptr);
72 for ( int i=1; i<=lst.count(); i++ )
73 list_hd -> update_component(i, lst(i)) ;
75 oid_list::update_component(index, list_hd.its_oid()) ;
77 set_mode(UPDATE, true);
81 Boolean inv_lists::append_list(oid_list& lst)
84 MESSAGE(cerr, "append a inv list");
85 lst.asciiOut(cerr); cerr << "\n";
88 handler hd(OID_LIST_CODE, storage_ptr);
90 oid_list_handler& lst_handler = *(oid_list_handler*)&hd;
93 lst_handler -> expand_space(lst.count());
95 for ( int i=1; i<=lst.count(); i++ )
96 lst_handler -> update_component(i, lst(i)) ;
98 oid_list::insert_component(hd.its_oid()) ;
100 set_mode(UPDATE, true);
105 Boolean inv_lists::remove_list(int index)
107 update_component(index, ground);
111 oid_list_handler* inv_lists::get_list(int index)
113 oid_t x((*this)(index));
115 if ( x.eq(ground) == true ) {
118 return new oid_list_handler(x, storage_ptr);
123 oid_list_handler* inv_lists::get_list(mmdb_pos_t)
125 throw( stringException("get_list(): not implemented yet"));
130 ostream& operator <<(ostream&s, inv_lists& o)
132 for (int i=0; i < o.count(); i++) {
133 oid_list_handler* x = o.get_list(i);
141 void inv_lists::insert_to_list(int index, oid_t& id)
143 if ( !INRANGE(index, 1, v_sz) ) {
144 throw(boundaryException(1, v_sz, index));
147 oid_t list_id = (*this)(index);
150 MESSAGE(cerr, "inv::insert");
154 if ( INRANGE(list_id.ccode(), 0, 1) &&
155 id.ccode() != OID_LIST_CODE
158 update_component(index, id);
161 if ( list_id.ccode() != OID_LIST_CODE ) {
162 oid_list_handler y(OID_LIST_CODE, storage_ptr);
163 y -> insert_component(list_id);
164 update_component(index, y.its_oid());
165 y -> insert_component(id);
167 oid_list_handler y( list_id, storage_ptr);
168 y -> insert_component(id);
174 MMDB_BODIES(inv_lists)
175 HANDLER_BODIES(inv_lists)