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: mark.cc /main/6 1996/07/18 14:47:10 drk $
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.
52 #include "oliasdb/mark.h"
54 umark::umark() : tuple(2, USER_MARK_CODE)
62 mark_smart_ptr(mark_base* uptr, const char* node_locator) :
64 v_loct_hd(0), v_mark_hd(0)
66 #ifdef INTERCEPT_MARK_CALLS
67 MESSAGE(cerr, "mark_smart_ptr::cstr (1)");
68 debug(cerr, uptr -> get_base_name());
69 debug(cerr, node_locator);
72 mark_set_hd_ptr = uptr->mark_set_hd;
75 mbase -> trans().begin();
77 abs_storage* marks_store = mark_set_hd_ptr -> its_store();
83 tuple_handler* x = (tuple_handler*)
84 (new handler(USER_MARK_CODE, marks_store));
88 new pstring_handler(node_locator, strlen(node_locator), marks_store);
90 //(v_loct_hd->operator->())->asciiOut(cerr);
93 new pstring_handler("", 0, marks_store);
95 debug(cerr, v_loct_hd -> its_oid());
96 debug(cerr, *v_loct_hd);
97 debug(cerr, int(v_loct_hd));
98 debug(cerr, v_mark_hd -> its_oid());
99 debug(cerr, *v_mark_hd);
100 debug(cerr, int(v_mark_hd));
103 (*x) -> pinned_insert(BASE_COMPONENT_INDEX, v_loct_hd -> its_oid());
104 (*x) -> pinned_insert(BASE_COMPONENT_INDEX+1, v_mark_hd -> its_oid());
107 /////////////////////
109 /////////////////////
111 smart_ptr::_init(x->its_oid(), marks_store);
113 ////////////////////////
114 // insert into mark set
115 ////////////////////////
116 v_loct_hd -> commit(); // commit it so that the locator
117 // can be seen inside insert_object().
118 (*mark_set_hd_ptr) -> insert_object( *x );
120 mark_set_hd_ptr -> commit();
122 //debug(cerr, x -> its_oid());
126 mbase -> trans().end();
129 mcatch (beginTransException&, e)
131 smart_ptr::_init(ground, 0); // mark the mark obsolete
134 mcatch (commitTransException&, e)
136 smart_ptr::_init(ground, 0); // mark the mark obsolete
139 mcatch (mmdbException&, e)
141 smart_ptr::_init(ground, 0); // mark the mark obsolete
142 mbase -> trans().rollback();
149 mark_smart_ptr(mark_base* uptr, const oid_t& mark_id) :
150 smart_ptr(uptr->mark_set_hd->its_store(), mark_id),
151 mbase(uptr), mark_set_hd_ptr(uptr -> mark_set_hd)
153 #ifdef INTERCEPT_MARK_CALLS
154 MESSAGE(cerr, "mark_smart_ptr::cstr (2)");
155 debug(cerr, uptr -> get_base_name());
156 debug(cerr, mark_id);
161 v_loct_hd = (pstring_handler*)
162 get_handler(BASE_COMPONENT_INDEX, STRING_CODE);
163 v_mark_hd = (pstring_handler*)
164 get_handler(BASE_COMPONENT_INDEX+1, STRING_CODE);
167 mcatch (mmdbException&, e)
169 smart_ptr::_init(ground, 0); // mark the mark obsolete
176 mark_smart_ptr::~mark_smart_ptr()
182 void mark_smart_ptr::update_usermark(const pstring& new_mark)
184 update_usermark(((pstring&)new_mark).get(), ((pstring&)new_mark).size());
187 void mark_smart_ptr::update_usermark(const char* new_mark_str,
191 mbase -> trans().begin();
193 (*v_mark_hd) -> update(new_mark_str, new_mark_str_sz);
194 v_mark_hd -> commit();
196 mbase -> trans().end();
199 mcatch (beginTransException&, e)
203 mcatch (commitTransException&, e)
207 mcatch (mmdbException&, e)
209 mbase -> trans().rollback();
215 void mark_smart_ptr::remove_from_db()
218 mbase -> trans().begin();
220 (*mark_set_hd_ptr) -> remove_component(its_oid());
221 mark_set_hd_ptr -> commit();
223 mbase -> trans().end();
226 mcatch (beginTransException&, e)
230 mcatch (commitTransException&, e)
234 mcatch (mmdbException&, e)
236 mbase -> trans().rollback();
242 const char* mark_smart_ptr::node_locator()
244 return (*v_loct_hd) -> get();
247 pstring* mark_smart_ptr::mark_value()
250 pstring *z = v_mark_hd -> operator->();
251 debug(cerr, z -> size());
254 return v_mark_hd -> operator->();
257 ostream& operator <<(ostream& out, mark_smart_ptr& umark)
259 const char* x = umark.node_locator();
261 out << "node_locator: " << x << "\n";
263 out << "mark_value: ";
265 umark.mark_value() -> asciiOut(out);