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: dlp_hd.cc /main/4 1996/06/11 17:28:37 cde-hal $
26 * Copyright (c) 1992 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 "oliasdb/dlp_hd.h"
53 handler* dlp::get_component(int index)
56 throw(boundaryException(1, 1, index));
58 return new handler(/*c,*/ f_oid, storage_ptr);
61 io_status dlp::asciiOut(ostream& out)
63 //////////////////////////////////////////////
64 // qfc: cause dlp trouble to find end nodes.
65 //////////////////////////////////////////////
67 if ( BIT_TEST(pos_status, BEG) )
71 io_status ok = node_oid.asciiOut(out);
74 if ( BIT_TEST(pos_status, TERM) )
81 // format for a book section:
89 // a dlp stream is (book_section)+
91 io_status dlp::asciiIn(istream& in)
93 set_mode(UPDATE, true);
95 pos_status = NOT_BEG_TERM;
102 in.putback(char(plus));
104 io_status ok = node_oid.asciiIn(in);
106 int minus = in.get();
108 if ( minus == '-' ) {
110 if ( in.get() != '\n' )
111 throw(stringException("should be a newline"));
113 in.putback(char(minus));
115 //debug(cerr, int(BEG));
116 //debug(cerr, int(TERM));
117 //debug(cerr, int(pos_status));
118 //debug(cerr, node_oid);
123 int dlp::cdr_sizeof()
125 return dl_list_cell::cdr_sizeof() + node_oid.cdr_sizeof() + sizeof(pos_status);
128 io_status dlp::cdrOut(buffer& buf)
130 dl_list_cell::cdrOut(buf);
131 node_oid.cdrOut(buf);
136 io_status dlp::cdrIn(buffer& buf)
138 dl_list_cell::cdrIn(buf);
139 node_oid.cdrIn(buf, OLIAS_NODE_CODE);
147 ///////////////////////////////////
149 ///////////////////////////////////
152 dlp_smart_ptr(info_lib* lib_ptr,
153 const char* info_base_name, const oid_t& id):
154 smart_ptr(lib_ptr, info_base_name, DLP_LIST_POS,
155 managers::query_mgr -> form_oid_handler(
156 oid_t(OLIAS_NODE_CODE, id.icode())
158 ////////////////////////////////////////////////////////////
159 // to keep backward compatibility
160 // up to 2.2: position is specified by BASE_COMPONENT_INDEX
161 // 2.3 and higher: position is specified by THIS
162 ////////////////////////////////////////////////////////////
163 (lib_ptr->get_info_base(info_base_name)->
164 get_list(DLP_LIST_POS)->its_store()->
165 get_db_version() < mm_version(2,3)) ? BASE_COMPONENT_INDEX : THIS,
172 dlp_smart_ptr(info_base* bs_ptr, const oid_t& id) :
173 smart_ptr(bs_ptr, DLP_LIST_POS,
174 managers::query_mgr -> form_oid_handler(
175 oid_t(OLIAS_NODE_CODE, id.icode())
177 ////////////////////////////////////////////////////////////
178 // to keep backward compatibility
179 // up to 2.2: position is specified by BASE_COMPONENT_INDEX
180 // 2.3 and higher: position is specified by THIS
181 ////////////////////////////////////////////////////////////
182 (bs_ptr-> get_list(DLP_LIST_POS)->its_store()->
183 get_db_version() < mm_version(2,3)) ? BASE_COMPONENT_INDEX : THIS,
190 dlp_smart_ptr(dlp_smart_ptr& dsp, const oid_t& dlp_id)
192 smart_ptr::_init(dlp_id, dsp.its_store());
195 ///////////////////////////////////
197 ///////////////////////////////////
198 const oid_t dlp_smart_ptr::node_id()
200 dlp* x = (dlp*)(handler::operator->());
201 return oid_t( x -> node_oid );
204 dlp_smart_ptr* dlp_smart_ptr::prev()
206 oid_t back_cell_oid(prev_dlp_oid());
208 if ( back_cell_oid.icode() == 0 )
212 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
214 dlp_smart_ptr* back_cell_hd = (dlp_smart_ptr*)
215 new smart_ptr(cell_hd->its_store(), back_cell_oid);
217 if ( back_cell_hd -> node_id().icode() == 0 ) {
225 dlp_smart_ptr* dlp_smart_ptr::next()
227 oid_t next_cell_oid(next_dlp_oid());
229 if ( next_cell_oid.icode() == 0 )
233 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
235 dlp_smart_ptr* next_cell_hd = (dlp_smart_ptr*)
236 new smart_ptr(cell_hd->its_store(), next_cell_oid);
238 if ( next_cell_hd -> node_id().icode() == 0 ) {
246 oid_t dlp_smart_ptr::next_node_oid()
248 dlp_smart_ptr* x = next();
251 //return oid_t(x -> node_id());
252 oid_t z(x -> node_id());
260 oid_t dlp_smart_ptr::prev_node_oid()
262 dlp_smart_ptr* x = prev();
265 oid_t z(x -> node_id());
273 oid_t dlp_smart_ptr::prev_dlp_oid()
275 if ( BIT_TEST(((dlp*)(handler::operator->())) -> pos_status, dlp::BEG) ) {
278 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
279 return oid_t((*cell_hd) -> get_backward_ptr());
283 oid_t dlp_smart_ptr::next_dlp_oid()
285 //debug(cerr, *((dlp*)(handler::operator->())));
286 if ( BIT_TEST(((dlp*)(handler::operator->())) -> pos_status, dlp::TERM) )
289 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
290 return oid_t((*cell_hd) -> get_forward_ptr());