2 * $XConsortium: dlp_hd.cc /main/4 1996/06/11 17:28:37 cde-hal $
4 * Copyright (c) 1992 HAL Computer Systems International, Ltd.
5 * All rights reserved. Unpublished -- rights reserved under
6 * the Copyright Laws of the United States. USE OF A COPYRIGHT
7 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
10 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
11 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
12 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
13 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
16 * RESTRICTED RIGHTS LEGEND
17 * Use, duplication, or disclosure by the Government is subject
18 * to the restrictions as set forth in subparagraph (c)(l)(ii)
19 * of the Rights in Technical Data and Computer Software clause
20 * at DFARS 252.227-7013.
22 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
29 #include "oliasdb/dlp_hd.h"
31 handler* dlp::get_component(int index)
34 throw(boundaryException(1, 1, index));
36 return new handler(/*c,*/ f_oid, storage_ptr);
39 io_status dlp::asciiOut(ostream& out)
41 //////////////////////////////////////////////
42 // qfc: cause dlp trouble to find end nodes.
43 //////////////////////////////////////////////
45 if ( BIT_TEST(pos_status, BEG) )
49 io_status ok = node_oid.asciiOut(out);
52 if ( BIT_TEST(pos_status, TERM) )
59 // format for a book section:
67 // a dlp stream is (book_section)+
69 io_status dlp::asciiIn(istream& in)
71 set_mode(UPDATE, true);
73 pos_status = NOT_BEG_TERM;
80 in.putback(char(plus));
82 io_status ok = node_oid.asciiIn(in);
88 if ( in.get() != '\n' )
89 throw(stringException("should be a newline"));
91 in.putback(char(minus));
93 //debug(cerr, int(BEG));
94 //debug(cerr, int(TERM));
95 //debug(cerr, int(pos_status));
96 //debug(cerr, node_oid);
101 int dlp::cdr_sizeof()
103 return dl_list_cell::cdr_sizeof() + node_oid.cdr_sizeof() + sizeof(pos_status);
106 io_status dlp::cdrOut(buffer& buf)
108 dl_list_cell::cdrOut(buf);
109 node_oid.cdrOut(buf);
114 io_status dlp::cdrIn(buffer& buf)
116 dl_list_cell::cdrIn(buf);
117 node_oid.cdrIn(buf, OLIAS_NODE_CODE);
125 ///////////////////////////////////
127 ///////////////////////////////////
130 dlp_smart_ptr(info_lib* lib_ptr,
131 const char* info_base_name, const oid_t& id):
132 smart_ptr(lib_ptr, info_base_name, DLP_LIST_POS,
133 managers::query_mgr -> form_oid_handler(
134 oid_t(OLIAS_NODE_CODE, id.icode())
136 ////////////////////////////////////////////////////////////
137 // to keep backward compatibility
138 // up to 2.2: position is specified by BASE_COMPONENT_INDEX
139 // 2.3 and higher: position is specified by THIS
140 ////////////////////////////////////////////////////////////
141 (lib_ptr->get_info_base(info_base_name)->
142 get_list(DLP_LIST_POS)->its_store()->
143 get_db_version() < mm_version(2,3)) ? BASE_COMPONENT_INDEX : THIS,
150 dlp_smart_ptr(info_base* bs_ptr, const oid_t& id) :
151 smart_ptr(bs_ptr, DLP_LIST_POS,
152 managers::query_mgr -> form_oid_handler(
153 oid_t(OLIAS_NODE_CODE, id.icode())
155 ////////////////////////////////////////////////////////////
156 // to keep backward compatibility
157 // up to 2.2: position is specified by BASE_COMPONENT_INDEX
158 // 2.3 and higher: position is specified by THIS
159 ////////////////////////////////////////////////////////////
160 (bs_ptr-> get_list(DLP_LIST_POS)->its_store()->
161 get_db_version() < mm_version(2,3)) ? BASE_COMPONENT_INDEX : THIS,
168 dlp_smart_ptr(dlp_smart_ptr& dsp, const oid_t& dlp_id)
170 smart_ptr::_init(dlp_id, dsp.its_store());
173 ///////////////////////////////////
175 ///////////////////////////////////
176 const oid_t dlp_smart_ptr::node_id()
178 dlp* x = (dlp*)(handler::operator->());
179 return oid_t( x -> node_oid );
182 dlp_smart_ptr* dlp_smart_ptr::prev()
184 oid_t back_cell_oid(prev_dlp_oid());
186 if ( back_cell_oid.icode() == 0 )
190 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
192 dlp_smart_ptr* back_cell_hd = (dlp_smart_ptr*)
193 new smart_ptr(cell_hd->its_store(), back_cell_oid);
195 if ( back_cell_hd -> node_id().icode() == 0 ) {
203 dlp_smart_ptr* dlp_smart_ptr::next()
205 oid_t next_cell_oid(next_dlp_oid());
207 if ( next_cell_oid.icode() == 0 )
211 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
213 dlp_smart_ptr* next_cell_hd = (dlp_smart_ptr*)
214 new smart_ptr(cell_hd->its_store(), next_cell_oid);
216 if ( next_cell_hd -> node_id().icode() == 0 ) {
224 oid_t dlp_smart_ptr::next_node_oid()
226 dlp_smart_ptr* x = next();
229 //return oid_t(x -> node_id());
230 oid_t z(x -> node_id());
238 oid_t dlp_smart_ptr::prev_node_oid()
240 dlp_smart_ptr* x = prev();
243 oid_t z(x -> node_id());
251 oid_t dlp_smart_ptr::prev_dlp_oid()
253 if ( BIT_TEST(((dlp*)(handler::operator->())) -> pos_status, dlp::BEG) ) {
256 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
257 return oid_t((*cell_hd) -> get_backward_ptr());
261 oid_t dlp_smart_ptr::next_dlp_oid()
263 //debug(cerr, *((dlp*)(handler::operator->())));
264 if ( BIT_TEST(((dlp*)(handler::operator->())) -> pos_status, dlp::TERM) )
267 dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
268 return oid_t((*cell_hd) -> get_forward_ptr());