Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
XCOMM $XConsortium: Imakefile /main/10 1996/08/21 15:52:28 drk $
XCOMM ** WARNING **
XCOMM
XCOMM The files named here may appear in many different Imakefiles.
XCOMM If you add or remove a file, be sure to update all locations.
XCOMM It's unfortunate, but all this redundancy serves a purpose.
XCOMM
XCOMM Other possible locations are:
XCOMM .../lib/DtMmdb/Imakefile
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
XCOMM .../programs/dtinfo/mmdb/Imakefile
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
#define DoNormalLib NormalLibDtMmdb
#define DoSharedLib SharedLibDtMmdb
#define DoDebugLib DebugLibDtMmdb
#define DoProfileLib ProfileLibDtMmdb
#define LibName DtMmdb
#define SoRev SODTMMDBREV
#define LibHeaders NO
#define LibCreate NO
#define LargePICTable YES
#define CplusplusSource YES
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
XCOMM In DtMmdb we compile as C_API sources.
DEFINES = -DC_API -DPORTABLE_DB
INCLUDES = -I.. $(EXCEPTIONS_INCLUDES)
SRCS = composite.C compressed_pstring.C cset.C \
dl_list.C dl_list_cell.C handler.C \
integer.C long_pstring.C oid.C \
oid_list.C oid_t.C primitive.C \
pstring.C random_gen.C root.C \
short_list.C tuple.C
OBJS = $(SRCS:.C=.o)
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -0,0 +1,88 @@
/*
* $XConsortium: c_codes.h /main/3 1996/06/11 17:23:29 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _class_h
#define _class_h 1
// class code for system classes
#define ROOT_CODE 2
#define PRIMITIVE_CODE 3
#define INTEGER_CODE 4
#define FLOAT_CODE 5
#define STRING_CODE 6
#define OID_CODE 7
#define LONG_STRING_CODE 8
#define OID_T_CODE 9
#define DL_LIST_CELL_CODE 10
#define COMPRESSED_STRING_CODE 11
#define COMPOSITE_CODE 101
#define TUPLE_CODE 102
#define SET_CODE 103
#define STATIC_SET_CODE 104
#define SHORT_LIST_CODE 105
#define OID_LIST_CODE 106
#define STATIC_RECORDS_CODE 107
#define DL_LIST_CODE 108
#define HASH_CODE 201
#define STATIC_HASH_CODE 202
#define DYN_HASH_CODE 203
#define FAST_MPHF_CODE 204
#define GRAPH_OPMPHF_CODE 206
#define INV_LISTS_CODE 207
#define INDEX_CODE 208
#define MPHF_INDEX_CODE 209
#define IDMAP_MPHF_INDEX_CODE 210
#define DYN_INDEX_CODE 211
#define DYN_MEMORY_INDEX_CODE 212
#define DYN_DISK_INDEX_CODE 213
#define DYN_MEMORY_HASH_CODE 214
#define DYN_DISK_HASH_CODE 215
#define BTREE_CODE 216
#define BTREE_INDEX_CODE 217
#define ABS_STORAGE_CODE 301
#define UNIX_STORAGE_CODE 302
#define PAGE_STORAGE_CODE 303
#define MEM_STORAGE_CODE 304
#define NODE_CODE 401
#define ARC_CODE 402
#define LABELNODE_CODE 403
#define NODE_NODES_CODE 404
#define HUFFMAN_AGENT_CODE 501
#define GZIP_AGENT_CODE 502
#define DICT_AGENT_CODE 503
#endif

View File

@@ -0,0 +1,134 @@
/*
* $XConsortium: composite.cc /main/5 1996/07/18 14:40:37 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/composite.h"
composite::composite(c_code_t c_id) : root(c_id)
{
//init_persistent_info();
v_sz = 0;
}
composite::composite(const composite& x) : root(x)
{
//init_persistent_info();
v_sz = x.v_sz;
}
int composite::first() const
{
if ( v_sz == 0 )
return 0;
else
return 1;
}
void composite::next(int& index) const
{
if INRANGE( index, 1, v_sz - 1 )
index ++;
else
index = 0;
}
handler* composite::get_component(int)
{
throw(stringException("composite::get_component() can't be called"));
return 0;
}
void composite::set_mode(obj_mode_t mode, Boolean option)
{
root::set_mode(mode, option);
}
Boolean composite::test_io_mode(int mode)
{
if ( storage_ptr )
return storage_ptr -> io_mode(mode);
else
return false;
}
int composite::cdr_sizeof()
{
return root::cdr_sizeof() + sizeof(v_sz);
}
io_status composite::cdrOut(buffer& buf)
{
root::cdrOut(buf);
buf.put(v_sz);
return done;
}
io_status composite::cdrIn(buffer& buf)
{
root::cdrIn(buf);
buf.get(v_sz);
return done;
}
MMDB_BODIES(composite)
NEW_AND_DELETE_BODIES(composite)
composite_handler::composite_handler(const oid_t& v_oid, storagePtr _store):
handler(v_oid, _store)
{
}
composite_handler::~composite_handler()
{
}
composite* composite_handler::operator ->()
{
return (composite*)handler::operator->();
}
handler* composite_handler::_get_component(int i)
{
handler* x = 0;
if ( i == THIS )
x = this;
else {
x = ((composite*)handler::operator->()) -> get_component(i);
}
if ( x == 0 )
throw(stringException("NULL component handler ptr"));
return x;
}

View File

@@ -0,0 +1,105 @@
/*
* $XConsortium: composite.h /main/4 1996/06/11 17:23:39 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _composite_h
#define _composite_h 1
#include "object/root.h"
#include "storage/page_storage.h"
#include "object/handler.h"
/******************************************
* composite object class
*******************************************/
class composite: public root
{
public:
NEW_AND_DELETE_SIGNATURES(composite);
composite(c_code_t c_id = COMPOSITE_CODE);
composite(const composite& x);
virtual ~composite() {};
// iteration over components
virtual int first() const;
virtual handler* get_component(int) ;
//virtual handler* get_component(oid_t&) ;
virtual void next(int& index) const;
// number of components
virtual int count() const { return v_sz; };
MMDB_SIGNATURES(composite);
// insert a component
virtual Boolean insert_component(const oid_t&) {
return true; };
// update a component
virtual Boolean update_component(int, const oid_t&) {
return true;
};
void set_mode(obj_mode_t, Boolean);
Boolean test_io_mode(int mode);
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
Boolean swap_order() {
return (storage_ptr) ? storage_ptr -> swap_order() : false;
};
protected:
unsigned int v_sz; // number of components
};
typedef composite* compositePtr;
class composite_handler : public handler
{
public:
composite_handler() {};
composite_handler(const oid_t&, storagePtr = 0);
virtual ~composite_handler();
composite* operator ->();
handler* _get_component(int i);
};
#endif

View File

@@ -0,0 +1,186 @@
/*
* $XConsortium: compressed_pstring.cc /main/4 1996/06/11 17:23:44 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/compressed_pstring.h"
#ifdef C_API
buffer* compressed_pstring::working_buffer_ptr;
buffer* compressed_pstring::v_cp_io_buf_ptr;
#define working_buffer (*working_buffer_ptr)
#define v_cp_io_buf (*v_cp_io_buf_ptr)
// for pstring's buffer
#define v_io_buf (*v_io_buf_ptr)
#else
buffer compressed_pstring::working_buffer(LBUFSIZ);
buffer compressed_pstring::v_cp_io_buf(LBUFSIZ);
#endif
compressed_pstring::compressed_pstring(c_code_t c_id) :
pstring(c_id), agent(0), v_uncompressed_sz(0)
{
}
compressed_pstring::~compressed_pstring()
{
}
MMDB_BODIES(compressed_pstring)
char* compressed_pstring::get(buffer& string_buffer)
{
//MESSAGE(cerr, "compressed_pstring::get()");
//debug(cerr, v_uncompressed_sz);
string_buffer.reset();
string_buffer.expand_chunk(v_uncompressed_sz+1);
pstring::get(working_buffer);
// use cached version of compression agent
//debug(cerr, compress_agent_id);
if ( (storage_ptr -> my_oid()).ccode() == MEM_STORAGE_CODE )
agent = (compress_agent_handler*)
(new handler(DICT_AGENT_CODE, storage_ptr));
else
agent = new compress_agent_handler(compress_agent_id, storage_ptr);
(*agent) -> decompress(working_buffer, string_buffer);
delete agent;
string_buffer.get_base()[v_uncompressed_sz] = 0;
//MESSAGE(cerr, "compressed_pstring::get() done");
return string_buffer.get_base();
}
io_status compressed_pstring::asciiIn(istream& in)
{
compress_agent_id.asciiIn(in); // compress agent oid part
//debug(cerr, compress_agent_id);
return this -> _asciiIn(in);
}
io_status compressed_pstring::asciiIn(const char* buf, int size, const oid_t& id)
{
compress_agent_id.become(id); // compress agent oid part
return this -> _asciiIn(buf, size);
}
io_status compressed_pstring::asciiIn(const char* buf, int size)
{
return pstring::asciiIn(buf, size);
}
io_status compressed_pstring::_asciiIn(istream& in)
{
// use cached version of compression agent
if ( (storage_ptr -> my_oid()).ccode() == MEM_STORAGE_CODE )
agent = (compress_agent_handler*)
(new handler(DICT_AGENT_CODE, storage_ptr));
else
agent = new compress_agent_handler(compress_agent_id, storage_ptr);
pstring::_asciiIn(in);
_compress();
return done;
}
io_status compressed_pstring::_asciiIn(const char* buf, int size)
{
// use cached version of compression agent
if ( (storage_ptr -> my_oid()).ccode() == MEM_STORAGE_CODE )
agent = (compress_agent_handler*)
(new handler(DICT_AGENT_CODE, storage_ptr));
else
agent = new compress_agent_handler(compress_agent_id, storage_ptr);
pstring::asciiIn(buf, size); // uncompress data part
_compress();
return done;
}
void compressed_pstring::_compress()
{
v_uncompressed_sz = v_io_buf.content_sz();
if ( v_uncompressed_sz > 0 ) {
working_buffer.reset();
(*agent) -> compress(v_io_buf, working_buffer);
//debug(cerr, v_uncompressed_sz);
//debug(cerr, working_buffer.content_sz());
pstring::update(working_buffer.get_base(), working_buffer.content_sz());
}
set_mode(UPDATE, true);
delete agent;
}
int compressed_pstring::size() const
{
return v_uncompressed_sz;
}
int compressed_pstring::cdr_sizeof()
{
return pstring::cdr_sizeof() + sizeof(v_uncompressed_sz) +
compress_agent_id.cdr_sizeof();
}
io_status compressed_pstring::cdrOut(buffer& buf)
{
//MESSAGE(cerr, "compressed_pstring: cdrOut()");
//debug(cerr, compress_agent_id);
pstring::cdrOut(buf);
buf.put(v_uncompressed_sz);
return compress_agent_id.cdrOut(buf);
}
io_status compressed_pstring::cdrIn(buffer& buf)
{
pstring::cdrIn(buf);
buf.get(v_uncompressed_sz);
return compress_agent_id.cdrIn(buf);
}
HANDLER_BODIES(compressed_pstring)

View File

@@ -0,0 +1,102 @@
/*
* $XConsortium: compressed_pstring.h /main/4 1996/06/11 17:23:49 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _compressed_pstring_h
#define _compressed_pstring_h 1
#include "object/pstring.h"
#include "compression/abs_agent.h"
/***************************************
* compressed string class.
****************************************/
class compressed_pstring: public pstring
{
protected:
#ifdef C_API
static buffer* v_cp_io_buf_ptr;
static buffer* working_buffer_ptr;
#else
static buffer v_cp_io_buf;
static buffer working_buffer;
#endif
oid_t compress_agent_id;
unsigned int v_uncompressed_sz;
compress_agent_handler* agent;
protected:
void _compress();
public:
compressed_pstring(c_code_t = COMPRESSED_STRING_CODE);
virtual ~compressed_pstring();
// get uncompresed version
#ifdef C_API
char* get(buffer& optional_buffer = *v_cp_io_buf_ptr);
#else
char* get(buffer& optional_buffer = v_cp_io_buf);
#endif
int size() const; // get uncompressed data size
MMDB_SIGNATURES(compressed_pstring);
// asciiIn function
virtual io_status _asciiIn(istream&) ; // read in string part
virtual io_status _asciiIn(const char* buf, int size) ;
virtual io_status asciiIn(istream&) ; // read in compress agent id and then
virtual io_status asciiIn(const char* buf, int size, const oid_t&) ;
virtual io_status asciiIn(const char* buf, int size) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
friend class compressed_pstring_handler;
#ifdef C_API
friend void initialize_MMDB();
friend void quit_MMDB();
#endif
private:
};
HANDLER_SIGNATURES(compressed_pstring)
#endif

View File

@@ -0,0 +1,47 @@
// $XConsortium: convert.cc /main/3 1996/06/11 17:23:53 cde-hal $
#include <iostream.h>
/*****************************************/
//Note: convert node.dat file to new format
/*****************************************/
#define BUFSIZ 100
main()
{
int sz;
int buf_sz = BUFSIZ;
char *buf = new char[BUFSIZ];
while ( cin.getline(buf, BUFSIZ) ) { // read in '100L'
cout << "102 0\n";
cout << "4\n";
for ( int i=0; i<4; i++ ) {
cin >> sz;
/*
cout << "***";
cout << sz;
cout << "***\n";
*/
cin.get();
if ( buf_sz < sz ) {
buf_sz = sz;
buf = new char[buf_sz];
}
cin.read(buf, sz);
cin.get(); // skip '\n'
cout << "5\t0" << "\n";
cout << sz << "\t";
cout.write(buf, sz);
cout << "\n";
}
}
delete buf;
}

View File

@@ -0,0 +1,356 @@
/*
* $XConsortium: cset.cc /main/5 1996/06/11 17:23:58 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/cset.h"
#include "utility/xtime.h"
cset::cset(c_code_t c_cd): composite(c_cd)
{
num_indices = 0;
indices = 0;
set_mode(SWAP_ALLOWED, false);
}
void cset::init_data_member(c_index_handlerPtr* index_arrray,
int iptrs
)
{
indices = index_arrray;
num_indices = iptrs;
set_mode(HEALTH, true);
#ifdef MEMORY_MAPPED
set_mode(UPDATE, true);
#endif
}
cset::~cset()
{
/*
MESSAGE(cerr, "~cset() called.");
debug(cerr, my_oid());
debug(cerr, num_indices);
debug(cerr, int(this));
MESSAGE(cerr, "~cset() called.");
debug(cerr, num_indices);
*/
delete indices;
}
handler* cset::get_component(int index)
{
if ( indices[0] == 0 )
return 0;
oid_t id_ptr = (*indices[0]) -> first_of_invlist(index);
handler* y = new handler(id_ptr, storage_ptr);
return y;
}
oid_list_handler* cset::get_locs(handler& query, int index)
{
if ( !INRANGE(index, 0, num_indices-1) ) {
MESSAGE(cerr, "cset::get_locs(): invalid index");
throw(boundaryException(0, num_indices-1, index));
}
if ( indices[index] == 0 ) {
MESSAGE(cerr, "cset::get_locs(): invalid index");
throw(stringException("NULL index ptr"));
}
return (*indices[index]) -> get_loc_list(query);
}
oid_t cset::get_first_oid(const handler& query, int index)
{
if ( !INRANGE(index, 0, num_indices-1) ) {
MESSAGE(cerr, "cset::get_first_oid(): invalid index");
throw(boundaryException(0, num_indices-1, index));
}
if ( indices[index] == 0 ) {
MESSAGE(cerr, "cset::get_first_oid(): invalid index");
throw(stringException("NULL index ptr"));
}
return (*indices[index]) -> first_of_invlist(query);
}
c_index_handler* cset::get_index_ptr(int index)
{
if ( !INRANGE(index, 0, num_indices-1) ) {
MESSAGE(cerr, "cset::get_index_ptr(): invalid index");
throw(boundaryException(0, num_indices-1, index));
}
return indices[index];
}
void cset::batch_index_begin()
{
for ( int i=0; i<num_indices; i++ ) {
if ( indices[i] != 0 ) {
(*indices[i]) -> batch_index_begin();
}
}
}
void cset::batch_index_end()
{
for ( int i=0; i<num_indices; i++ ) {
if ( indices[i] != 0 ) {
(*indices[i]) -> batch_index_end();
}
}
}
io_status cset::asciiIn(istream& in)
{
batch_index_begin();
io_status ok = batch_asciiIn(in);
batch_index_end();
return ok;
}
io_status cset::batch_asciiIn(istream& in)
{
handler* root_hd_ptr = 0;
#ifdef DEBUG
xtime tmr;
float f1;
long f2;
tmr.start();
#endif
char ccode_buf[LBUFSIZ];
int c;
//fprintf(stderr, "batch_asciiIn() : start looping \n");
while ( (c = in.get()) != EOF ) {
in.putback(c);
in.getline(ccode_buf, LBUFSIZ);
//fprintf(stderr, "ccode_buf=%s\n", ccode_buf);
char* x = strrchr(ccode_buf, 'L');
if ( x ) *x = 0;
int ccode;
sscanf(ccode_buf, "%u", &ccode);
//in >> ccode ;
//fprintf(stderr, "ccode=%d\n", ccode);
root_hd_ptr = new handler(ccode, storage_ptr);
if ( filter::assigned() == false )
(*root_hd_ptr) -> asciiIn(in);
else
(*root_hd_ptr) -> asciiIn(filter::filter_func()(in));
root_hd_ptr->commit();
insert_object(*root_hd_ptr);
/*
#ifdef DEBUG
if ( v_sz % 1000 == 0 && v_sz != 0 ) {
tmr.stop(f1, f2);
debug(cerr, f1);
debug(cerr, f2);
debug(cerr, v_sz);
tmr.start();
}
#endif
*/
//(*root_hd_ptr)-> asciiOut(cerr);
/*
(root_hd_ptr -> its_oid()).asciiOut(cerr);
storage_ptr -> asciiOut(cerr);
MESSAGE(cerr, "\n========");
*/
delete root_hd_ptr;
}
return done;
}
io_status cset::asciiOut(ostream&)
{
return done;
}
Boolean
cset::insert_object(const handler& new_object)
{
/*
MESSAGE(cerr, "in insert_object()");
new_object.its_oid().asciiOut(cerr); cerr << "\n";
*/
if ( indices[0] != 0 ) {
#ifdef A16_BROWSER
handler* zz = (handler*)&new_object;
(*indices[0]) -> insert_key_loc(new_object, zz -> its_oid());
#else
(*indices[0]) -> insert_key_loc(new_object, new_object.its_oid());
#endif
}
for ( int i = 1; i < num_indices; i++ ) {
if ( indices[i] == 0 )
continue;
handler* y = (*(composite_handler*)&new_object)
-> get_component(i);
if ( y == 0 ) continue;
#ifdef A16_BROWSER
handler* ww = (handler*)&new_object;
(*indices[i]) -> insert_key_loc(*y, ww -> its_oid());
#else
(*indices[i]) -> insert_key_loc(*y, new_object.its_oid());
#endif
if ( !(y -> its_oid() == new_object.its_oid()) )
delete y;
}
v_sz++;
set_mode(UPDATE, true);
return true;
}
Boolean cset::remove_component(const oid_t& x_oid)
{
handler* x = new handler(x_oid, storage_ptr);
for ( int i = 1; i < num_indices; i++ ) {
if ( indices[i] == 0 )
continue;
handler* y = (*(composite_handler*)x) -> get_component(i);
(*indices[i]) -> remove_loc(*y, x_oid);
y -> destroy();
delete y;
}
x -> destroy();
delete x;
v_sz--;
set_mode(UPDATE, true);
return true;
}
// update old component object 'old_comp_obj' to new
// component object 'new_comp_obj'.
// variable 'index' holds the index of the index object
// effected. 'obj_pos' is the id of the
// main object, of which old_comp_obj is a part.
Boolean
cset::update_index(handler* old_comp_obj, handler* new_comp_obj,
int index,
oid_t& main_obj_oid)
{
if ( !INRANGE(index, 1, num_indices-1) ) {
throw(boundaryException(1, num_indices-1, index));
}
if ( indices[index] ) {
return (*indices[index]) -> update_streampos
(
*old_comp_obj,
*new_comp_obj,
main_obj_oid.icode()
);
} else
return true;
}
int cset::cdr_sizeof()
{
return composite::cdr_sizeof() + sizeof(num_indices);
}
io_status cset::cdrOut(buffer& buf)
{
composite::cdrOut(buf);
buf.put(num_indices);
return done;
}
io_status cset::cdrIn(buffer& buf)
{
composite::cdrIn(buf);
buf.get(num_indices);
return done;
}
void cset::commit()
{
for ( int i = 1; i < num_indices; i++ ) {
if ( indices[i] )
indices[i] -> commit();
}
}
MMDB_BODIES(cset)
HANDLER_BODIES(cset)

View File

@@ -0,0 +1,124 @@
/*
* $XConsortium: cset.h /main/5 1996/06/11 17:24:03 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _cset_h
#define _cset_h 1
#include "utility/filter.h"
#include "object/composite.h"
#include "index/index.h"
/***************************************
* a set class.
****************************************/
class cset: public composite
{
protected:
c_index_handlerPtr *indices;
unsigned int num_indices;
public:
// indices[] array elements:
// [0]: oid index;
// [1]: whole object index;
// [2]: component 1 index;
// [3]: component 2 index;
// ... ...
// [n+1]: component n object index.
cset( c_code_t c_id = SET_CODE );
virtual ~cset();
void init_data_member(c_index_handlerPtr* indices,
int num_indices
);
MMDB_SIGNATURES(cset);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// iteration over components
// no delete to returned component if comp is zero when passed in.
virtual handler* get_component(int index) ;
// get a set of locs for element objects satisfying a 'query'
// 'index' indicates the index to be used.
virtual oid_list_handler* get_locs(handler& query, int index);
virtual oid_t get_first_oid(const handler& query, int index);
// get a pointer to an index
virtual c_index_handler* get_index_ptr(int index);
// insert/remove a component
virtual Boolean insert_object(const handler&) ;
virtual Boolean remove_component(const oid_t&) ;
// update a component
virtual Boolean update_index( handler* old_comp_obj,
handler* new_comp_obj,
int index,
oid_t& main_obj_oid
);
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
void commit(); // for commit all components
// init/quit batch index
void batch_index_begin();
void batch_index_end();
// read in a set of object instances. Used with
// batch_index_begin() and batch_index_end() to
// load a mixed object stream
io_status batch_asciiIn(istream& s);
// object instance in/out function
io_status asciiIn(istream& s) ;
io_status asciiOut(ostream& s) ;
};
typedef cset* csetPtr;
HANDLER_SIGNATURES(cset)
#endif

View File

@@ -0,0 +1,11 @@
/* $XConsortium: db_new.h /main/3 1996/06/11 17:24:08 cde-hal $ */
#include <new.h>
#include "stoorage/abs_storage.h"
void* operator new ( size_t );
void* operator new ( size_t, abs_storage* );
void operator delete( void* );
void operator delete( void*, size_t );

View File

@@ -0,0 +1,525 @@
/*
* $XConsortium: dl_list.cc /main/5 1996/06/11 17:24:12 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/dl_list.h"
dl_list::dl_list(c_code_t c_cd) : composite(c_cd)
{
v_num_indices = 0;
v_indices = 0;
set_mode(SWAP_ALLOWED, false);
}
dl_list::dl_list(const dl_list& x) : composite(x)
{
throw(stringException("dl_list(const dl_list&) not done yet"));
}
dl_list::~dl_list()
{
/*
MESSAGE(cerr, "in ~dl_list()");
debug(cerr, v_num_indices);
*/
delete v_indices;
}
void dl_list::init_data_member(c_index_handlerPtr* index_arrray,
int iptrs
)
{
v_indices = index_arrray;
v_num_indices = iptrs;
set_mode(HEALTH, true);
#ifdef MEMORY_MAPPED
set_mode(UPDATE, true);
#endif
}
//
//Boolean dl_list::value_LS(root& x, Boolean safe) const
//{
// if ( safe == true &&
// ( my_oid().ccode() != DL_LIST_CODE ||
// x.my_oid().ccode() != DL_LIST_CODE
// )
// )
// return false;
//
// dl_list &y = *(dl_list*)&x;
//
// if ( sz != y.sz )
// return false;
//
///************************************************/
//// Note: the components are indexed from 1 to sz
///************************************************/
//
// for ( int i=1; i<=sz; i++ ) {
//
// handler* rootPtr1 = get_component(i);
// handler* rootPtr2 = y.get_component(i);
//
// if ( (*rootPtr1) -> value_LS( *rootPtr2 ) == true ) {
// return true;
// }
//
// if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false ) {
// return false;
// }
// }
//
// return false;
//}
//
//Boolean dl_list::value_EQ(root& x, Boolean safe) const
//{
// if ( safe == true &&
// ( my_oid().ccode() != DL_LIST_CODE ||
// x.my_oid().ccode() != DL_LIST_CODE
// )
// )
// return false;
//
// dl_list &y = *(dl_list*)&x;
//
// if ( sz != y.sz )
// return false;
//
///************************************************/
//// Note: the components are index from 1 to sz
///************************************************/
//
// for ( int i=1; i<=sz; i++ ) {
//
// handler* rootPtr1 = get_component(i);
// handler* rootPtr2 = y.get_component(i);
//
// if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false ) {
// return false;
// }
// }
//
// return true;
//}
handler* dl_list::get_component(int index)
{
if ( v_sz == 0 )
return 0;
const oid_t* cell_ptr = &v_dl_list_head;
for ( int i=1; i<index-1; i++ ) {
if ( cell_ptr == 0 || cell_ptr -> icode() == 0 )
throw(stringException("broken chain"));
dl_list_cell_handler cell(*cell_ptr, storage_ptr);
cell_ptr = &cell -> get_forward_ptr();
}
return new handler (*cell_ptr, storage_ptr);
}
oid_list_handler* dl_list::get_locs(handler& query, int index)
{
if ( !INRANGE(index, 0, v_num_indices-1) )
throw(boundaryException(0, v_num_indices-1, index));
if ( v_indices[index] == 0 )
throw(stringException("NULL index handler ptr"));
return (*v_indices[index]) -> get_loc_list(query);
}
oid_t dl_list::first_cell_oid() const
{
return v_dl_list_head;
}
oid_t dl_list::last_cell_oid() const
{
return v_dl_list_tail;
}
Boolean
dl_list::insert_before(dl_list_cell_handler& new_cell,
dl_list_cell_handler& old_cell
)
{
oid_t prev_oid(old_cell -> get_backward_ptr());
new_cell -> set_forward_ptr(old_cell.its_oid());
old_cell -> set_backward_ptr(new_cell.its_oid());
if ( prev_oid.icode() != 0 ) {
// NOTE: non-new-list-head case
dl_list_cell_handler prev_cell_hd(prev_oid, storage_ptr);
new_cell -> set_backward_ptr(prev_cell_hd.its_oid());
prev_cell_hd -> set_forward_ptr(new_cell.its_oid());
} else {
// NOTE: new-list-head case
v_dl_list_head.become(new_cell.its_oid());
}
v_sz++;
set_mode(HEALTH, true);
insert_to_indices(new_cell);
return true;
}
Boolean
dl_list::insert_after(dl_list_cell_handler& new_cell,
dl_list_cell_handler& old_cell
)
{
oid_t next_oid(old_cell -> get_forward_ptr());
new_cell -> set_backward_ptr(old_cell.its_oid());
old_cell -> set_forward_ptr(new_cell.its_oid());
if ( next_oid.icode() != 0 ) {
// NOTE: non-new-list-tail case
dl_list_cell_handler next_cell_hd(next_oid, storage_ptr);
new_cell -> set_forward_ptr(next_cell_hd.its_oid());
next_cell_hd -> set_backward_ptr(new_cell.its_oid());
} else {
// NOTE: new-list-tail case
new_cell -> get_forward_ptr().become(ground);
v_dl_list_tail.become(new_cell.its_oid());
}
v_sz++;
set_mode(HEALTH, true);
insert_to_indices(new_cell);
return true;
}
Boolean
dl_list::insert_as_head(const dl_list_cell_handler& new_cell)
{
#ifdef A16_BROWSER
dl_list_cell_handler* z = 0;
#endif
if ( v_dl_list_head.icode() != 0 ) {
dl_list_cell_handler first_cell(v_dl_list_head,
storage_ptr
);
#ifdef A16_BROWSER
z = (dl_list_cell_handler*)&new_cell;
first_cell -> set_backward_ptr(z -> its_oid());
#else
first_cell -> set_backward_ptr(new_cell.its_oid());
#endif
}
((dl_list_cell_handler&)new_cell) -> set_forward_ptr(v_dl_list_head);
#ifdef A16_BROWSER
v_dl_list_head.become(z -> its_oid());
#else
v_dl_list_head.become(new_cell.its_oid());
#endif
if ( v_dl_list_tail.icode() == 0 )
v_dl_list_tail.become(v_dl_list_head);
v_sz++;
set_mode(HEALTH, true);
insert_to_indices(new_cell);
return true;
}
Boolean
dl_list::insert_as_tail(dl_list_cell_handler& new_cell)
{
if ( v_dl_list_tail.icode() != 0 ) {
dl_list_cell_handler last_cell(v_dl_list_tail,
storage_ptr
);
last_cell -> set_forward_ptr(new_cell.its_oid());
}
new_cell -> set_backward_ptr(v_dl_list_tail);
v_dl_list_tail.become(new_cell.its_oid());
if ( v_dl_list_head.icode() == 0 )
v_dl_list_head.become(v_dl_list_tail);
v_sz++;
set_mode(HEALTH, true);
new_cell -> set_mode(UPDATE, true);
insert_to_indices(new_cell);
return true;
}
io_status dl_list::asciiOut(ostream& out)
{
/*
MESSAGE(cerr, "HEAD");
v_dl_list_head.asciiOut(out); cerr << "\n";
MESSAGE(cerr, "TAIL");
v_dl_list_tail.asciiOut(out); cerr << "\n";
*/
out << "OID_T:\n";
my_oid().asciiOut(out);
out << "\n";
if ( v_sz == 0 ) return done;
oid_t* cell_ptr = &v_dl_list_head;
for ( int i=1; i<=v_sz; i++ ) {
if ( cell_ptr == 0 ) {
throw(stringException("broken chain"));
}
if ( cell_ptr -> icode() == 0 ) {
debug(cerr, i);
debug(cerr, v_sz);
throw(stringException("dl_list::get_component(): broken chain"));
}
dl_list_cell_handler cell(*cell_ptr, storage_ptr);
cell -> asciiOut(cerr); cerr << "\n";
cell_ptr = &cell -> get_forward_ptr();
}
return done;
}
void dl_list::batch_index_begin()
{
for ( int i=0; i<v_num_indices; i++ ) {
if ( v_indices[i] != 0 ) {
(*v_indices[i]) -> batch_index_begin();
}
}
}
void dl_list::batch_index_end()
{
for ( int i=0; i<v_num_indices; i++ ) {
if ( v_indices[i] != 0 ) {
(*v_indices[i]) -> batch_index_end();
}
}
}
io_status dl_list::asciiIn(istream& in)
{
batch_index_begin();
io_status ok = batch_asciiIn(in);
batch_index_end();
return ok;
}
io_status dl_list::batch_asciiIn(istream& in)
{
char ccode_buf[LBUFSIZ];
int c;
handler* hd_ptr = 0;
while ( (c = in.get()) != EOF ) {
in.putback(c);
in.getline(ccode_buf, LBUFSIZ);
char* x = strrchr(ccode_buf, 'L');
if ( x ) *x = 0;
int ccode;
sscanf(ccode_buf, "%u", &ccode);
hd_ptr = new handler(ccode, storage_ptr);
if ( filter::assigned() == false )
(*hd_ptr) -> asciiIn(in);
else
(*hd_ptr) -> asciiIn(filter::filter_func()(in));
/*
MESSAGE(cerr, "dllist: ID read in");
hd_ptr -> its_oid().asciiOut(cerr); cerr << "\n";
*/
insert_as_tail(*(dl_list_cell_handler*)hd_ptr) ;
delete hd_ptr;
}
return done;
}
Boolean
dl_list::insert_to_indices(const dl_list_cell_handler& new_object)
{
#ifdef A16_BROWSER
dl_list_cell_handler* z = (dl_list_cell_handler*)&new_object;
#endif
if ( v_indices[0] != 0 ) {
#ifdef A16_BROWSER
(*v_indices[0]) -> insert_key_loc(new_object, z -> its_oid());
#else
(*v_indices[0]) -> insert_key_loc(new_object, new_object.its_oid());
#endif
}
for ( int i = 1; i < v_num_indices; i++ ) {
if ( v_indices[i] == 0 ) continue;
handler* y = (*(composite_handler*)&new_object)
-> get_component(i);
/*
MESSAGE(cerr, "dlist: comp id:");
y -> its_oid().asciiOut(cerr); cerr << "\n";
MESSAGE(cerr, "obj id: (its_oid and my_oid)");
new_object.its_oid().asciiOut(cerr); cerr << "\n";
(*(dl_list_cell_handler*)&new_object) -> my_oid().asciiOut(cerr); cerr << "\n";
*/
if ( y == 0 ) continue;
// A16 backward compatible
#ifdef A16_BROWSER
(*v_indices[i]) -> insert_key_loc(*y, z -> its_oid());
#else
(*v_indices[i]) -> insert_key_loc(*y, new_object.its_oid());
#endif
//debug(cerr, y -> its_oid());
//debug(cerr, new_object.its_oid());
if ( !(y -> its_oid() == new_object.its_oid()) )
delete y;
}
set_mode(HEALTH, true);
return true;
}
int dl_list::cdr_sizeof()
{
return composite::cdr_sizeof() +
v_dl_list_head.cdr_sizeof() +
v_dl_list_tail.cdr_sizeof() +
sizeof(v_num_indices);
}
io_status dl_list::cdrOut(buffer& buf)
{
composite::cdrOut(buf);
v_dl_list_head.cdrOut(buf);
v_dl_list_tail.cdrOut(buf);
buf.put(v_num_indices);
return done;
}
io_status dl_list::cdrIn(buffer& buf)
{
composite::cdrIn(buf);
v_dl_list_head.cdrIn(buf);
v_dl_list_tail.cdrIn(buf);
buf.get(v_num_indices);
return done;
}
oid_t dl_list::get_first_oid(const handler& query, int index)
{
if ( !INRANGE(index, 0, v_num_indices-1) ) {
MESSAGE(cerr, "cset::get_first_oid(): invalid index");
throw(boundaryException(0, v_num_indices-1, index));
}
if ( v_indices[index] == 0 ) {
throw(stringException("cset::get_first_oid(): NULL index ptr"));
}
return (*v_indices[index]) -> first_of_invlist(query);
}
void dl_list::commit()
{
for ( int i = 1; i < v_num_indices; i++ )
{
if ( v_indices[i] )
v_indices[i] -> commit() ;
}
}
MMDB_BODIES(dl_list)
HANDLER_BODIES(dl_list)

View File

@@ -0,0 +1,124 @@
/*
* $XConsortium: dl_list.h /main/5 1996/06/11 17:24:17 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _dl_list_h
#define _dl_list_h 1
#include "utility/filter.h"
#include "object/composite.h"
#include "index/index.h"
#include "object/oid_list.h"
#include "object/dl_list_cell.h"
/***************************************
* dl_list class.
****************************************/
class dl_list: public composite
{
public:
dl_list(c_code_t = DL_LIST_CODE);
dl_list(const dl_list&);
virtual ~dl_list();
void init_data_member(c_index_handlerPtr* indices,
int num_indices
);
MMDB_SIGNATURES(dl_list);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
virtual oid_t get_first_oid(const handler& query, int index);
// insert component functions. new_cell and old_cell
// are handlers to dl_list_cells already existing on
// the store
Boolean insert_before(dl_list_cell_handler& new_cell,
dl_list_cell_handler& old_cell
);
Boolean insert_after(dl_list_cell_handler& new_cell,
dl_list_cell_handler& old_cell
);
// insert as head/tail cell. new_cell is a handler to a
// del_list_cell already existing on the store
Boolean insert_as_head(const dl_list_cell_handler& new_cell);
Boolean insert_as_tail(dl_list_cell_handler& new_cell);
// iteration over components
virtual handler* get_component(int index) ;
// get a set of locs for element objects satisfying a 'query'
// 'index' indicates the index to be used.
virtual oid_list_handler* get_locs(handler& query, int index)
;
// first/last cell's oid.
oid_t first_cell_oid() const ;
oid_t last_cell_oid() const ;
// init/quit batch index
void batch_index_begin();
void batch_index_end();
// read in a set of object instances. Used with
// batch_index_begin() and batch_index_end() to
// load a mixed object stream
io_status batch_asciiIn(istream& s);
// instance in/out function
virtual io_status asciiOut(ostream&) ;
virtual io_status asciiIn(istream&) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
void commit();
protected:
Boolean insert_to_indices(const dl_list_cell_handler& new_cell);
protected:
oid_t v_dl_list_head;
oid_t v_dl_list_tail;
c_index_handlerPtr *v_indices;
unsigned int v_num_indices;
};
HANDLER_SIGNATURES(dl_list)
#endif

View File

@@ -0,0 +1,154 @@
/*
* $XConsortium: dl_list_cell.cc /main/4 1996/06/11 17:24:22 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/dl_list_cell.h"
dl_list_cell::dl_list_cell(c_code_t c_id) : composite(c_id)
{
v_forward_ptr.become(ground);
v_backward_ptr.become(ground);
}
dl_list_cell::dl_list_cell(const dl_list_cell& x) :
composite(x),
v_backward_ptr(x.v_backward_ptr),
v_forward_ptr(x.v_forward_ptr)
{
}
dl_list_cell::~dl_list_cell()
{
}
void dl_list_cell::set_backward_ptr(const oid_t& x)
{
v_backward_ptr.become(x);
set_mode(UPDATE, true);
}
void dl_list_cell::set_forward_ptr(const oid_t& x)
{
v_forward_ptr.become(x);
set_mode(UPDATE, true);
}
oid_t& dl_list_cell::get_backward_ptr()
{
return v_backward_ptr;
}
oid_t& dl_list_cell::get_forward_ptr()
{
return v_forward_ptr;
}
/*
boolean dl_list_cell::value_LS(root& x, boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != DL_LIST_CELL_CODE ||
x.my_oid().ccode() != DL_LIST_CELL_CODE
)
)
return false;
dl_list_cell &y = *(dl_list_cell*)&x;
if ( v_backward_ptr.ls(y.v_backward_ptr) == true ||
( v_backward_ptr.eq(y.v_backward_ptr) == true &&
v_forward_ptr.ls(y.v_forward_ptr) == true
)
)
return true;
else
return false;
}
boolean dl_list_cell::value_EQ(root& x, boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != DL_LIST_CELL_CODE ||
x.my_oid().ccode() != DL_LIST_CELL_CODE
)
)
return false;
dl_list_cell &y = *(dl_list_cell*)&x;
if ( v_backward_ptr.eq(y.v_backward_ptr) == true )
return true;
else
return false;
}
*/
io_status dl_list_cell::asciiOut(ostream& out)
{
out << "OID_T:\n";
my_oid().asciiOut(out);
out << "\n";
v_backward_ptr.asciiOut(out);
out << "\n";
v_forward_ptr.asciiOut(out);
return done;
}
io_status dl_list_cell::asciiIn(istream& in)
{
v_backward_ptr.asciiIn(in);
v_forward_ptr.asciiIn(in);
set_mode(UPDATE, true);
return done;
}
int dl_list_cell::cdr_sizeof()
{
return composite::cdr_sizeof() + v_backward_ptr.cdr_sizeof() +
v_forward_ptr.cdr_sizeof();
}
io_status dl_list_cell::cdrOut(buffer& buf)
{
composite::cdrOut(buf);
v_backward_ptr.cdrOut(buf);
v_forward_ptr.cdrOut(buf);
return done;
}
io_status dl_list_cell::cdrIn(buffer& buf)
{
composite::cdrIn(buf);
v_backward_ptr.cdrIn(buf);
v_forward_ptr.cdrIn(buf);
return done;
}
MMDB_BODIES(dl_list_cell)
HANDLER_BODIES(dl_list_cell)

View File

@@ -0,0 +1,81 @@
/*
* $XConsortium: dl_list_cell.h /main/5 1996/07/18 14:41:01 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _dl_list_cell_h
#define _dl_list_cell_h 1
#include "object/composite.h"
#include "object/oid_t.h"
/***************************************
* Integer class.
****************************************/
class dl_list_cell: public composite
{
public:
dl_list_cell(c_code_t c_id = DL_LIST_CELL_CODE);
dl_list_cell(const dl_list_cell&);
virtual ~dl_list_cell();
MMDB_SIGNATURES(dl_list_cell);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// ascii IO function
virtual io_status asciiOut(ostream& s) ;
virtual io_status asciiIn(istream&) ;
// set/retrieval dl_list_cell functions
void set_backward_ptr(const oid_t&);
void set_forward_ptr(const oid_t&);
oid_t& get_backward_ptr();
oid_t& get_forward_ptr();
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
protected:
oid_t v_backward_ptr; // backward ptr
oid_t v_forward_ptr; // forward ptr
};
HANDLER_SIGNATURES(dl_list_cell)
#endif

View File

@@ -0,0 +1,163 @@
/*
* $XConsortium: handler.cc /main/5 1996/07/18 14:41:25 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/handler.h"
#include "mgrs/managers.h"
//memory_pool handler::handler_space_pool;
extern memory_pool g_memory_pool;
handler::handler() :
store(0), obj_id(ground), obj_ptr(0)
{
}
handler::handler(const oid_t& id, abs_storage* s) :
store(s), obj_id(id), obj_ptr(0)
{
}
handler::handler(c_code_t cod, abs_storage* s) :
store(s), obj_id(cod, 0), obj_ptr(0)
{
if ( s )
operator->(); // to init the object from the store
}
handler::handler(rootPtr ptr, abs_storage* s) :
store(s), obj_id(ptr -> my_oid()), obj_ptr(ptr)
{
}
void handler::set(rootPtr ptr, abs_storage* s)
{
store = (abs_storage*)s;
if ( ptr )
obj_id.become(ptr -> my_oid());
obj_ptr = ptr;
}
handler::~handler()
{
if ( store ) {
managers::template_mgr -> quit_obj(store, obj_ptr);
} else
delete obj_ptr;
// commit();
// delete obj_ptr;
}
void handler::destroy()
{
if ( store )
managers::template_mgr -> destroy_obj(store, obj_ptr);
else
delete obj_ptr;
}
void handler::sync()
{
if ( store ) store -> sync();
}
void handler::commit()
{
if ( store ) {
if ( obj_ptr )
obj_ptr -> commit(); // save all its handler components
managers::template_mgr -> commit_obj(store, obj_ptr);
}
}
root* handler::operator ->()
{
if ( store ) {
if ( obj_ptr == 0 ) {
/*
(obj_ptr && obj_id.eq(obj_ptr -> my_oid()) == false )
MESSAGE(cerr, "handler::operator ->()");
debug(cerr, (void*)obj_ptr);
debug(cerr, obj_id);
if ( obj_ptr -> get_mode(SWAP_ALLOWED) == true )
//r_obj_cache.promote_object(store, obj_ptr);
*/
//obj_ptr = r_obj_cache.init_object(store, obj_id);
if ( obj_id.icode() ) {
managers::template_mgr -> init_obj(store, obj_id.icode(), obj_ptr);
} else {
managers::template_mgr -> create_obj(store, obj_id.ccode(), obj_ptr);
}
///////////////////////////////////////////////////////////////////
// update the handler side object id. Its class code may not
// be initialized as class code of a oid_t is not saved on the disk.
// We do not expect this check will degrade the performance as
// this init_object block is only called once for the operator->().
// Subsequent calls will bypass it as obj_ptr is not 0.
///////////////////////////////////////////////////////////////////
obj_id.become(obj_ptr -> my_oid());
}
}
if ( store && obj_ptr == 0 ) {
debug(cerr, long(store));
debug(cerr, its_oid());
throw(stringException("null obj ptr"));
};
return obj_ptr;
}
handler::operator root&()
{
return *(this -> operator->());
}
void* handler::operator new( size_t x )
{
//return (void*)g_memory_pool.alloc(x);
return ::operator new(x);
}
void handler::operator delete( void* ptr )
{
//g_memory_pool.free((char*)ptr);
::operator delete(ptr);
}

View File

@@ -0,0 +1,109 @@
/*
* $XConsortium: handler.h /main/4 1996/07/18 14:41:47 drk $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _handler_h
#define _handler_h 1
#include "dstr/memory_pool.h"
#include "storage/page_storage.h"
#include "object/root.h"
#include "mgrs/template_mgr.h"
class handler : public Destructable
{
public:
handler() ;
handler(const oid_t& id, abs_storage* store = 0);
handler(c_code_t class_code, abs_storage* store);
handler(rootPtr ptr, abs_storage* store);
virtual ~handler();
// a light-weight way to resue handler resouce
void set(rootPtr ptr, abs_storage* store);
virtual void sync();
virtual void commit();
virtual void destroy();
void* operator new( size_t );
void operator delete( void* );
root* operator ->();
operator root&();
#ifdef A16_BROWSER
oid_t& its_oid() { return obj_id; } ;
#else
const oid_t& its_oid() const { return obj_id; } ;
#endif
abs_storage* its_store() const { return store; } ;
protected:
//static memory_pool handler_space_pool;
protected:
rootPtr obj_ptr;
abs_storage* store;
oid_t obj_id;
};
#define HANDLER_SIGNATURES(class_name) \
class class_name ## _handler : public handler \
{ \
\
public: \
class_name ## _handler(const oid_t&, storagePtr = 0); \
virtual ~class_name ## _handler(); \
\
class_name * operator ->(); \
}; \
\
typedef class_name ## _handler* class_name ## _handlerPtr;
#define HANDLER_BODIES(class_name) \
\
class_name ## _handler::class_name ## _handler(const oid_t& v_oid, storagePtr _store): \
handler(v_oid, _store) \
{ \
} \
\
class_name ## _handler::~class_name ## _handler() \
{ \
} \
\
class_name* class_name ## _handler::operator ->() \
{ \
return (class_name*)handler::operator->(); \
}
#endif

View File

@@ -0,0 +1,147 @@
/*
* $XConsortium: integer.cc /main/4 1996/06/11 17:24:32 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/integer.h"
integer::integer(c_code_t c_id) : primitive(c_id)
{
v_intRep = 0;
}
integer::integer(const integer& x) : primitive(x)
{
v_intRep = x.v_intRep;
}
integer::~integer()
{
}
void integer::set(const int i)
{
v_intRep = i;
set_mode(UPDATE, true);
}
int integer::get()
{
return v_intRep;
}
/*
Boolean integer::copy(int selector, root*& x) const
{
if ( f_oid.ccode() != INTEGER_CODE || selector != VALUE)
return false;
else {
x = new integer(*this);
return true;
}
}
*/
/*
Boolean integer::value_LS(root& x, Boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != INTEGER_CODE ||
x.my_oid().ccode() != INTEGER_CODE
)
)
return false;
integer &y = *(integer*)&x;
if ( v_intRep < y.v_intRep )
return true;
else
return false;
}
Boolean integer::value_EQ(root& x, Boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != INTEGER_CODE ||
x.my_oid().ccode() != INTEGER_CODE
)
)
return false;
integer &y = *(integer*)&x;
if ( v_intRep == y.v_intRep )
return true;
else
return false;
}
*/
io_status integer::asciiOut(ostream& out)
{
out << v_intRep;
return done;
}
io_status integer::asciiIn(istream& in)
{
if ( ! cc_is_digit(in) )
throw (stringException("a digit expected"));
in >> v_intRep;
if ( in.get() != '\n' ) {
throw (stringException("'\\n' expected"));
}
set_mode(UPDATE, true);
return done;
}
int integer::cdr_sizeof()
{
return primitive::cdr_sizeof() + sizeof(v_intRep);
}
io_status integer::cdrOut(buffer& buf)
{
primitive::cdrOut(buf);
buf.put((unsigned int)v_intRep);
return done;
}
io_status integer::cdrIn(buffer& buf)
{
primitive::cdrIn(buf);
buf.get(*(unsigned int*)&v_intRep);
return done;
}
MMDB_BODIES(integer)
HANDLER_BODIES(integer)

View File

@@ -0,0 +1,76 @@
/*
* $XConsortium: integer.h /main/5 1996/07/18 14:42:16 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _integer_h
#define _integer_h 1
#include "object/primitive.h"
/***************************************
* Integer class.
****************************************/
class integer: public primitive
{
public:
integer(c_code_t c_id = INTEGER_CODE);
integer(const integer&);
virtual ~integer();
MMDB_SIGNATURES(integer);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// ascii IO function
virtual io_status asciiOut(ostream& s) ;
virtual io_status asciiIn(istream&) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
// set/retrieval integer functions
void set(const int x);
int get();
protected:
int v_intRep; // int representation
};
HANDLER_SIGNATURES(integer)
#endif

View File

@@ -0,0 +1,143 @@
/*
* $XConsortium: long_pstring.cc /main/4 1996/06/11 17:24:42 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/long_pstring.h"
/****************************************************/
// long_pstring member funcions: CONS/DEST
/****************************************************/
long_pstring::long_pstring(c_code_t c_id) : pstring(c_id), v_str_index(0)
{
set_mode(SWAP_ALLOWED, false);
}
long_pstring::long_pstring(char* x, int leng, c_code_t c_id) : pstring(x, leng, c_id), v_str_index(0)
{
}
long_pstring::long_pstring(long_pstring& x) : pstring(x)
{
v_str_index = 0;
}
long_pstring::~long_pstring()
{
delete v_str_index;
}
/****************************************************/
// long_pstring member funcions: OTHERS
/****************************************************/
Boolean
long_pstring::extract(int left, int right, char* sink)
{
//debug(cerr, left);
//debug(cerr, right);
//debug(cerr, int(v_str_ptr.loc));
if ( left > right || right - left > v_sz ) {
throw(boundaryException(left, right, v_sz));
}
if ( get_mode(PERSISTENT) == true ) {
if ( v_str_index == 0 &&
get_mode(OLD_OBJECT) == true && v_sz > PAGSIZ
)
v_str_index = new chunks_index(storage_ptr, v_str_ptr.loc);
if ( v_str_index ) {
str_index_record_t* anchor = v_str_index -> chunk_location(left);
//debug(cerr, left - anchor -> str_offset);
storage_ptr ->
readString(anchor -> loc, sink,
right-left, left - anchor -> str_offset
);
} else
//debug(cerr, left);
storage_ptr -> readString(v_str_ptr.loc, sink, right-left, left);
} else {
memcpy(sink, v_str_ptr.p + left, right - left);
}
//for ( int i=0;i<right-left; i++)
// cerr << int(sink[i]) << " ";
//cerr << "\n";
return true;
}
/*
Boolean long_pstring::value_LS(root& x, Boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != LONG_STRING_CODE ||
x.my_oid().ccode() != LONG_STRING_CODE
)
)
return false;
return pstring::value_LS(x, false);
}
Boolean long_pstring::value_EQ(root& x, Boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != LONG_STRING_CODE ||
x.my_oid().ccode() != LONG_STRING_CODE
)
)
return false;
return pstring::value_EQ(x, false);
}
*/
io_status long_pstring::asciiIn(istream& in)
{
if ( pstring::asciiIn(in) == done ) {
v_str_index = ( get_mode(PERSISTENT) == true && v_sz > PAGSIZ ) ?
new chunks_index(storage_ptr, v_str_ptr.loc) :
0;
return done;
} else
return fail;
}
MMDB_BODIES(long_pstring)
HANDLER_BODIES(long_pstring)

View File

@@ -0,0 +1,71 @@
/*
* $XConsortium: long_pstring.h /main/5 1996/07/18 14:42:33 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _long_pstring_h
#define _long_pstring_h 1
#include "object/pstring.h"
#include "utility/ostring.h"
#include "storage/page_storage.h"
#include "storage/chunks_index.h"
/***************************************
* long string class.
****************************************/
class long_pstring: public pstring
{
public:
long_pstring(long_pstring&);
long_pstring(c_code_t = LONG_STRING_CODE);
long_pstring(char* string, int sz, c_code_t = LONG_STRING_CODE);
virtual ~long_pstring();
MMDB_SIGNATURES(long_pstring);
// export function
Boolean extract(int left, int right, char* sink);
/*
// comparison functions
Boolean value_LS(root& x, Boolean safe) const;
Boolean value_EQ(root& x, Boolean safe) const;
*/
// print function
virtual io_status asciiIn(istream&) ;
protected:
chunks_index *v_str_index;
};
HANDLER_SIGNATURES(long_pstring)
#endif

View File

@@ -0,0 +1,73 @@
/*
* $XConsortium: new_delete.h /main/4 1996/06/11 17:24:51 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _new_delete_h
#define _new_delete_h 1
#include "new_delete_simple.h"
#ifdef C_API
#include <stdlib.h>
#else
#include <new.h>
#endif
#define NEW_AND_DELETE_BODIES(class_name) \
\
void* class_name::operator new( size_t sz )\
{\
return ::operator new(sz); \
}\
\
void* class_name::operator new( size_t sz, void* ptr )\
{\
return (void*)ptr; \
}\
\
void class_name::operator delete( void* p )\
{\
::operator delete(p); \
}
#define MMDB_SIGNATURES(class_name) \
virtual root* cast_to(char* str); \
static int cdr_size; \
virtual int mem_sizeof() { return sizeof(class_name); }; \
virtual void set_cdr_size(int sz) { class_name::cdr_size = sz; }; \
virtual int get_cdr_size() { return class_name::cdr_size; }
#define MMDB_BODIES(class_name) \
int class_name::cdr_size = 0; \
root* class_name::cast_to(char* str)\
{\
return new (str) class_name;\
}
#endif

View File

@@ -0,0 +1,120 @@
/*
* $XConsortium: oid.cc /main/4 1996/06/11 17:24:56 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/oid.h"
oid::oid(c_code_t c_id) : primitive(c_id)
{
}
oid::oid(const oid_t& x) : primitive(OID_CODE), v_oid(x)
{
}
oid::oid(const oid& x) : primitive(x), v_oid(x.v_oid)
{
}
/* inline
void oid::set(const oid_t& x)
{
v_oid.become(x);
}
*/
/*
Boolean oid::value_EQ(root& x, Boolean safe) const
{
if ( safe == true &&
( x.my_oid().c_code != OID_CODE ||
f_oid.c_code != OID_CODE
)
)
return false;
return v_oid.eq(((oid*)&x) -> v_oid);
}
Boolean oid::value_LS(root& x, Boolean safe) const
{
if ( safe == true &&
( x.my_oid().c_code != OID_CODE ||
f_oid.c_code != OID_CODE
)
)
return false;
return v_oid.ls(((oid*)&x) -> v_oid);
}
*/
io_status oid::asciiIn(istream& in)
{
set_mode(UPDATE, true);
return ( v_oid.asciiIn(in) );
}
io_status oid::asciiOut(ostream& out)
{
v_oid.asciiOut(out);
return done;
}
/* inline
oid_t& oid::my_coid()
{
return v_oid;
}
*/
int oid::cdr_sizeof()
{
return primitive::cdr_sizeof() + v_oid.cdr_sizeof() +
sizeof(v_oid.v_c_code);
}
io_status oid::cdrOut(buffer& buf)
{
primitive::cdrOut(buf);
v_oid.cdrOut(buf);
buf.put(v_oid.v_c_code);
return done;
}
io_status oid::cdrIn(buffer& buf)
{
primitive::cdrIn(buf);
v_oid.cdrIn(buf);
buf.get(v_oid.v_c_code);
return done;
}
MMDB_BODIES(oid)
HANDLER_BODIES(oid)

View File

@@ -0,0 +1,80 @@
/*
* $XConsortium: oid.h /main/5 1996/07/18 14:42:55 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _oid_h
#define _oid_h 1
#include "object/primitive.h"
/*************************************/
// The oid class
// containing an oid of some object.
/*************************************/
class oid : public primitive
{
public:
oid(c_code_t c_id = OID_CODE);
oid(const oid_t&);
oid(const oid&) ;
virtual ~oid() {};
void set(const oid_t& x) { v_oid.become(x); } ;
MMDB_SIGNATURES(oid);
/*
// comparison functions: value comparison
virtual Boolean value_LS(root&, Boolean safe = true) const ;
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
*/
// export functions
virtual io_status asciiOut(ostream&) ;
virtual io_status asciiIn(istream&) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
// get the oid
oid_t& my_coid() { return v_oid; };
protected:
oid_t v_oid;
};
typedef oid* oidPtr;
HANDLER_SIGNATURES(oid)
#endif

View File

@@ -0,0 +1,498 @@
/*
* $XConsortium: oid_list.cc /main/5 1996/07/18 14:43:28 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/oid_list.h"
void oid_list::init_persistent_info(persistent_info* x)
{
ostring* u = list_ptr.p;
root::init_persistent_info(x);
if ( get_mode(OLD_OBJECT) == false ) {
//MESSAGE(cerr, "oid_list::init_persistent_info");
//debug(cerr, (void*)this);
//debug(cerr, my_oid());
char* w = 0;
int v= 0;
//MESSAGE(cerr, "oid_list::init_persistent_info(), new object case");
//debug(cerr, (void*)this);
//debug(cerr, (void*)list_ptr.p);
if (u) {
w = u -> get();
v = u -> size();
}
if ( storage_ptr )
storage_ptr -> insertString(list_ptr.loc, w, v);
//debug(cerr, list_ptr.loc);
//debug(cerr, v_sz);
}
delete u;
}
oid_list::oid_list(c_code_t c_id) : composite(c_id),
f_internal_index(false), chk_index(0)
{
list_ptr.loc = 0;
init_data_member(0);
}
oid_list::oid_list(int num_oids, c_code_t c_id) : composite(c_id),
f_internal_index(false), chk_index(0)
{
list_ptr.loc = 0;
init_data_member(num_oids);
}
oid_list::oid_list(oid_list& x) :
composite(x), chk_index(0)
{
list_ptr.loc = 0;
init_data_member(x.v_sz);
for ( int i=1; i<=v_sz; i++ )
update_component(i, x(i));
}
oid_list::~oid_list()
{
if ( get_mode(PERSISTENT) == false ) {
delete list_ptr.p;
}
delete chk_index;
}
void oid_list::init_data_member(int leng)
{
int char_leng = leng * OID_T_SZ ;
char* ptr = new char[char_leng];
oid_t x(ground);
char* y = ptr;
for ( int i=0; i<leng; i++ ) {
x.to_char_string(y, false);
y += OID_T_SZ;
}
list_ptr.loc = 0; // to please purify
list_ptr.p = new ostring(ptr, char_leng);
//MESSAGE(cerr, "oid_list::init_data_member(int leng)");
//debug(cerr, (void*)this);
//debug(cerr, (void*)list_ptr.p);
delete ptr;
v_sz = leng;
set_mode(UPDATE, true);
}
void oid_list::build_internal_index()
{
if ( get_mode(OLD_OBJECT) == true &&
get_mode(PERSISTENT) == true &&
v_sz > 1000
)
chk_index = new chunks_index(storage_ptr, list_ptr.loc);
else
chk_index = 0;
}
void oid_list::reqest_build_internal_index()
{
f_internal_index = true;
}
Boolean oid_list::expand_space(int extra_oids)
{
/*
MESSAGE(cerr, "in expand_space()");
debug(cerr, my_oid());
debug(cerr, extra_oids);
debug(cerr, v_sz);
debug(cerr, int(list_ptr.loc));
debug(cerr, int(&list_ptr.loc));
*/
Boolean ok;
int extra_char_leng = extra_oids * OID_T_SZ;
if ( get_mode(PERSISTENT) == true ) {
int total_char_leng = extra_char_leng + v_sz * OID_T_SZ;
char* ptr = new char[total_char_leng];
memset(ptr, (char)0, total_char_leng);
if ( list_ptr.loc == 0 ) {
storage_ptr -> insertString(list_ptr.loc, ptr, total_char_leng);
} else {
storage_ptr -> appendString(list_ptr.loc, ptr, total_char_leng);
}
delete ptr;
ok = true;
} else {
ok = list_ptr.p -> expand( extra_char_leng );
}
v_sz += extra_oids;
set_mode(UPDATE, true);
return ok;
}
io_status oid_list::asciiOut(ostream& out)
{
if ( !out )
return fail;
out << v_sz << '\n';
int ind = first();
while (ind ) {
oid_t x = (*this)(ind);
if ( x.eq(ground) == false ) {
x.asciiOut(out);
out << "\n";
}
next(ind);
}
return done;
}
oid_t oid_list::operator()(int ind)
{
/*
MESSAGE(cerr, "oid_list::operator()");
debug(cerr, my_oid());
debug(cerr, ind);
debug(cerr, v_sz);
debug(cerr, int(this));
debug(cerr, int(list_ptr.p));
*/
if ( !INRANGE(ind, 1, v_sz) ) {
MESSAGE(cerr, "oid_list::opeartor(): out of range");
throw(boundaryException(1, v_sz, ind));
}
char z[OID_T_SZ];
int offset = (ind - 1) * OID_T_SZ;
if ( get_mode(PERSISTENT) == true )
{
if ( list_ptr.loc == 0 )
throw(stringException("zero loc value"));
if ( f_internal_index == true && chk_index == 0 ) {
build_internal_index();
}
if ( chk_index ) {
str_index_record_t* anchor =
chk_index -> chunk_location(offset);
storage_ptr ->
readString(anchor -> loc, z, OID_T_SZ,
offset - anchor -> str_offset);
} else
storage_ptr ->
readString(list_ptr.loc, z, OID_T_SZ, offset);
} else {
if ( list_ptr.p == 0 )
throw(stringException("zero list_ptr.p value"));
memcpy(z, list_ptr.p -> get() + offset, OID_T_SZ);
}
//MESSAGE(cerr, "oid_list::operator() done");
#ifdef PORTABLE_DB
return oid_t(z, false, swap_order());
#else
return oid_t(z, false, false);
#endif
}
Boolean
oid_list::insert_component(const oid_t& new_comp_oid)
{
/*
MESSAGE(cerr, "oid_list::insert_component");
debug(cerr, v_sz);
debug(cerr, (void*)this);
debug(cerr, int(list_ptr.p));
new_comp_oid.asciiOut(cerr); cerr << "\n";
*/
char z[OID_T_SZ];
new_comp_oid.to_char_string(z, swap_order());
if ( get_mode(PERSISTENT) == true ) {
if ( list_ptr.loc == 0 ) {
storage_ptr ->
insertString(list_ptr.loc, z, OID_T_SZ);
} else {
storage_ptr ->
appendString(list_ptr.loc, z, OID_T_SZ);
}
} else {
list_ptr.p -> append(z, OID_T_SZ);
}
v_sz++;
set_mode(UPDATE, true);
return true;
}
Boolean
oid_list::update_component(int index, const oid_t& new_oid)
{
//MESSAGE(cerr, "oid_list::update_component()");
//debug(cerr, my_oid());
if ( !INRANGE(index, 1, v_sz) ) {
MESSAGE(cerr, "oid_list update(): out of range");
throw(boundaryException(1, v_sz, index));
}
char z[OID_T_SZ];
Boolean swap;
if ( get_mode(PERSISTENT) == true && swap_order() == true )
swap = true;
else
swap = false;
new_oid.to_char_string(z, swap);
if ( get_mode(PERSISTENT) == true ) {
if ( list_ptr.loc == 0 )
throw(stringException("zero list_ptr.p value"));
storage_ptr ->
updateString(list_ptr.loc, z,
OID_T_SZ, (index-1) * OID_T_SZ
);
} else {
//MESSAGE(cerr, "oid_list::update_component(): vm update");
if ( list_ptr.p == 0 )
throw(stringException("zero list_ptr.p value"));
list_ptr.p -> update(z, OID_T_SZ, (index-1)*OID_T_SZ);
}
//MESSAGE(cerr, "oid_list::update_component() done");
return true;
}
io_status oid_list::asciiIn(istream& in)
{
//MESSAGE(cerr, "oid_list::asciiIn()");
if ( in.get() != LIST_MARK_CHAR )
throw(formatException("should be a LIST_MARK_CHAR"));
if ( in.get() != '\n' )
throw(formatException("should be a \n"));
handler* hd_ptr = 0;
dlist temp_list;
dlist_void_ptr_cell* y = 0;
char c;
while ( (c = in.get()) != LIST_MARK_CHAR ) {
in.putback(c);
oid_t *x = new oid_t(ground);
x -> asciiIn(in);
y = new dlist_void_ptr_cell(x);
temp_list.insert_as_tail(y);
v_sz++;
}
if ( in.get() != '\n' ) {
throw(formatException("bad oid_list input stream"));
}
int oid_array_sz = v_sz * OID_T_SZ;
char *oid_array = new char[oid_array_sz];
long ind = temp_list.first();
int i = 0;
char z[OID_T_SZ];
while ( ind ) {
y = (dlist_void_ptr_cell*)(ind);
((oid_t*)(y -> void_ptr())) ->
to_char_string(z, swap_order());
delete ((oid_t*)(y -> void_ptr()));
memcpy(oid_array + i * OID_T_SZ, z, OID_T_SZ);
i++;
temp_list.next(ind);
}
// save the list
if ( get_mode(PERSISTENT) == true ) {
if ( list_ptr.loc == 0 )
storage_ptr -> insertString(list_ptr.loc, oid_array, oid_array_sz);
else
storage_ptr -> updateString(list_ptr.loc, oid_array, oid_array_sz);
set_mode(UPDATE, true);
} else {
delete list_ptr.p;
list_ptr.p = new ostring(0);
list_ptr.p -> set(oid_array, v_sz);
}
delete oid_array;
return done;
}
Boolean oid_list::remove_component(const oid_t& x)
{
int ind = first();
while ( ind ) {
if ( (*this)(ind).eq(x) == true ) {
update_component(ind, ground);
set_mode(UPDATE, true);
return true;
}
next(ind);
}
return false;
}
int oid_list::cdr_sizeof()
{
return composite::cdr_sizeof() + sizeof(list_ptr.loc);
}
io_status oid_list::cdrOut(buffer& buf)
{
/*
MESSAGE(cerr, "oid_list::cdrOut()");
debug(cerr, (void*)this);
debug(cerr, (void*)list_ptr.loc);
debug(cerr, my_oid());
*/
composite::cdrOut(buf);
buf.put(list_ptr.loc);
return done;
}
io_status oid_list::cdrIn(buffer& buf)
{
//MESSAGE(cerr, "oid_list::cdrIn()");
//debug(cerr, (void*)this);
composite::cdrIn(buf);
buf.get(list_ptr.loc);
//debug(cerr, (void*)list_ptr.loc);
//debug(cerr, my_oid());
return done;
}
MMDB_BODIES(oid_list)
oid_list_handler::oid_list_handler(int num_oids, storagePtr store):
handler(OID_LIST_CODE, store)
{
((oid_list*)obj_ptr) -> init_data_member(num_oids);
}
oid_list_handler::oid_list_handler(const oid_t& v_oid, storagePtr store):
handler(v_oid, store)
{
}
oid_list_handler::~oid_list_handler()
{
}
oid_list* oid_list_handler::operator ->()
{
return (oid_list*)handler::operator->();
}

View File

@@ -0,0 +1,123 @@
/*
* $XConsortium: oid_list.h /main/5 1996/07/18 14:43:51 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _oid_list_h
#define _oid_list_h 1
#include "utility/ostring.h"
#include "dstr/dlist.h"
#include "dstr/dlist_void_ptr_cell.h"
#include "object/oid.h"
#include "object/composite.h"
#include "storage/page_storage.h"
#include "storage/chunks_index.h"
/***************************************
* Primitive string class.
****************************************/
class oid_list: public composite
{
protected:
chunks_index* chk_index;
Boolean f_internal_index;
union {
mmdb_pos_t loc;
ostring* p;
} list_ptr;
protected:
// init the list (memory resident) with sz dummy oid_ts
void init_data_member(int sz);
public:
void init_persistent_info(persistent_info* x);
oid_list(oid_list&);
oid_list(c_code_t = OID_LIST_CODE);
oid_list(int num_oids, c_code_t);
virtual ~oid_list();
// expand the list to include extra x oids.
// handle both the memory and disk list.
Boolean expand_space(int x);
void build_internal_index(); // set up an index on the list
void reqest_build_internal_index();
// request building an internal
// index in the operator()
MMDB_SIGNATURES(oid_list);
virtual oid_t operator()(int);
// insert a component
virtual Boolean insert_component(const oid_t&);
// update a component
virtual Boolean update_component(int index, const oid_t&);
// remove a component
virtual Boolean remove_component(const oid_t&);
// print function
virtual io_status asciiOut(ostream&) ;
virtual io_status asciiIn(istream&) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
friend class oid_list_handler;
};
typedef oid_list* oid_listPtr;
/*
#endif
#ifndef _oid_list_handler_h
#define _oid_list_handler_h 1
*/
class oid_list_handler : public handler
{
public:
oid_list_handler(int num_oids, storagePtr = 0);
oid_list_handler(const oid_t&, storagePtr = 0);
virtual ~oid_list_handler();
oid_list* operator ->();
};
#endif

View File

@@ -0,0 +1,266 @@
/*
* $XConsortium: oid_t.cc /main/4 1996/07/18 14:44:11 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/oid_t.h"
#ifdef C_API
oid_t* ground_ptr = 0;
#else
oid_t ground(c_code_t(0), i_code_t(0));
#endif
/* inline
oid_t::oid_t()
{
}
*/
/* inline
oid_t::oid_t(c_code_t c, i_code_t i) :
v_c_code(c), v_i_code(i), v_e_code(0)
{
}
*/
/* inline
oid_t::oid_t(const oid_t& x)
{
v_e_code = x.v_e_code;
v_c_code = x.v_c_code;
v_i_code = x.v_i_code;
}
*/
oid_t::oid_t(const char* source, Boolean ascii_format, Boolean swap_order)
{
if ( source == 0 )
throw(stringException("NULL string pointer"));
if ( ascii_format == false ) {
// 4/28/93. do not save c_code in an oid_t.
v_c_code = 1;
memcpy((char*)&v_i_code, source, sizeof(v_i_code));
if ( swap_order == true )
#ifdef __osf__
ORDER_SWAP_INT(v_i_code);
#else
ORDER_SWAP_LONG(v_i_code);
#endif
} else {
istrstream in((char*)source);
in >> v_c_code;
if ( in.get() == '\n') {
v_i_code = 0;
} else {
in >> v_i_code;
}
}
/*
MESSAGE(cerr, "constr oid_t using a string");
debug(cerr, c_code);
debug(cerr, i_code);
*/
}
/* inline
oid_t::~oid_t()
{
}
*/
/* inline
void oid_t::become(const oid_t& x)
{
v_e_code = x.v_e_code;
v_c_code = x.v_c_code;
v_i_code = x.v_i_code;
}
*/
Boolean oid_t::eq(const oid_t& x) const
{
if ( v_i_code == x.v_i_code ) {
if ( v_c_code == 1 || x.v_c_code == 1 )
return true;
else {
if ( v_c_code == x.v_c_code )
return true;
else
return false;
}
} else
return false;
}
Boolean oid_t::ls(const oid_t & x) const
{
if ( v_c_code != 1 && x.v_c_code != 1 && v_c_code >= x.v_c_code )
return false;
else
if ( v_i_code >= x.v_i_code )
return false;
else
return true;
}
// Static function to compute a hash code for an oid_t
unsigned oid_t::hash(const oid_t& id)
{
return unsigned(id.icode()) + unsigned(id.ccode());
}
io_status oid_t::asciiOut(ostream& out) const
{
out << v_c_code << "." ;
// for compacted disk store. need to revisit. not working.
// out << 0 << "." ;
out << v_i_code;
return done;
}
io_status oid_t::asciiIn(istream& in)
{
_asciiIn(in);
if ( in.get() != '\n' ) {
throw(stringException("'\\n' expected"));
}
return done;
}
io_status oid_t::_asciiIn(istream& in)
{
if ( ! cc_is_digit(in) )
throw (stringException("a digit is expected"));
if ( v_c_code == 0 )
in >> v_c_code;
else {
c_code_t y;
in >> y;
if ( v_c_code != y )
return fail;
}
int mid = in.get();
if ( mid == '\n') {
v_i_code = 0;
in.putback(char(mid));
} else {
if ( mid != '.' ) {
debug(cerr, v_c_code);
debug(cerr, mid);
throw(stringException("'.' expected"));
}
if ( ! cc_is_digit(in) )
throw (stringException("a digit expected"));
in >> v_i_code;
}
return done;
}
ostream& operator<<(ostream& out, const oid_t& id)
{
id.asciiOut(out);
return out;
}
void oid_t::to_char_string(char* sink, Boolean swap_order) const
{
if ( sink == 0 )
throw(stringException("NULL string pointer"));
////////////////////////////////////////////
// 4/28/93. Do not save c_code in an oid_t.
////////////////////////////////////////////
/*
//bcopy((char*)&c_code, sink, sizeof(c_code));
memcpy(sink, (char*)&c_code, sizeof(c_code));
//bcopy((char*)&i_code,
// sink+sizeof(c_code), sizeof(i_code));
memcpy(
sink+sizeof(c_code),
(char*)&i_code,
sizeof(i_code));
*/
if ( swap_order == true ) {
i_code_t x = v_i_code;
#ifdef __osf__
ORDER_SWAP_INT(x);
#else
ORDER_SWAP_LONG(x);
#endif
memcpy(sink, (char*)&x, sizeof(x));
} else
memcpy(sink, (char*)&v_i_code, sizeof(v_i_code));
}
int oid_t::cdr_sizeof()
{
//return sizeof(c_code) + sizeof(i_code);
// 4/30/93. save no c_code
return sizeof(v_i_code);
}
io_status oid_t::cdrOut(buffer& buf)
{
// 4/30/93. save no c_code
// buf.put(c_code);
buf.put(v_i_code);
return done;
}
io_status oid_t::cdrIn(buffer& buf, c_code_t c_code_to_use)
{
// 4/30/93. save no c_code
// buf.get(v_c_code);
buf.get(v_i_code);
v_c_code = c_code_to_use;
return done;
}

View File

@@ -0,0 +1,135 @@
/*
* $XConsortium: oid_t.h /main/6 1996/08/21 15:52:31 drk $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _oid_t_h
#define _oid_t_h 1
#ifdef C_API
#include "utility/c_strstream.h"
#else
#include <strstream.h>
#endif
#include "utility/funcs.h"
#include "utility/buffer.h"
typedef unsigned short e_code_t;
typedef unsigned short c_code_t;
typedef mmdb_pos_t i_code_t;
#define OID_T_SZ (sizeof(i_code_t))
/*************************************
// class code root
**************************************/
class oid_t
{
public:
oid_t() : v_c_code(0), v_i_code(0), v_e_code(0) {};
oid_t(c_code_t c, i_code_t i) : v_c_code(c), v_i_code(i), v_e_code(0) {};
oid_t(const char* source, Boolean ascii_format, Boolean swap_order);
oid_t(const oid_t& x) :
v_e_code(x.v_e_code), v_c_code(x.v_c_code), v_i_code(x.v_i_code) {};
~oid_t() {};
// oid_t equal and less test
Boolean eq(const oid_t&) const;
Boolean ls(const oid_t&) const;
operator==(const oid_t& arg) const { return eq(arg); };
// class code, oid type and instance code export functions
const c_code_t ccode() const { return v_c_code; } ;
const i_code_t& icode() const { return v_i_code; } ;
static unsigned hash(const oid_t&);
// in/out functions
io_status asciiIn(istream&) ;
io_status asciiOut(ostream&) const;
io_status _asciiIn(istream&) ; // a version of asciiIn that does not
// eat the trailing '\n'
friend ostream& operator<<(ostream&, const oid_t&) ;
// compacted disk representation In and Out functions
int cdr_sizeof();
io_status cdrOut(buffer&);
io_status cdrIn(buffer&, c_code_t c_code_to_use = 0);
// out to char strings
void to_char_string(char* sink, Boolean swap_order) const;
friend class root;
friend class oid;
friend class desc;
friend class dl_list_cell;
friend class dl_list;
friend class compressed_pstring;
friend class service_mgr_t;
friend class storage_mgr_t;
friend class handler;
friend class smart_ptr;
friend class template_mgr_t;
protected:
void become(const oid_t& x) {
v_e_code = x.v_e_code;
v_c_code = x.v_c_code;
v_i_code = x.v_i_code;
};
void set_c_code(c_code_t c) {
v_c_code = c;
}
void set_i_code(i_code_t i) {
v_i_code = i;
}
void set_e_code(e_code_t e) {
v_e_code = e;
}
protected:
e_code_t v_e_code; // extended code. Not used within this class.
// for using extra space purpose.
c_code_t v_c_code; // class code
i_code_t v_i_code; // instance code
};
typedef oid_t* oid_tPtr;
#ifdef C_API
extern oid_t* ground_ptr;
#define ground (*ground_ptr)
#else
extern oid_t ground;
#endif
#endif

View File

@@ -0,0 +1,51 @@
/*
* $XConsortium: primitive.cc /main/4 1996/06/11 17:25:26 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/primitive.h"
primitive::primitive(c_code_t c_id) : root(c_id)
{
//init_persistent_info();
}
primitive::primitive(const primitive& x) : root(x)
{
//init_persistent_info();
}
void primitive::set_mode(obj_mode_t mode, Boolean option)
{
root::set_mode(mode, option);
}
MMDB_BODIES(primitive)
NEW_AND_DELETE_BODIES(primitive)

View File

@@ -0,0 +1,58 @@
/*
* $XConsortium: primitive.h /main/4 1996/06/11 17:25:31 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _primitive_h
#define _primitive_h 1
#include "object/root.h"
#include "storage/page_storage.h"
#include "object/handler.h"
/******************************************
* primitive object class
*******************************************/
class primitive : public root
{
public:
NEW_AND_DELETE_SIGNATURES(primitive);
primitive(c_code_t c_id = PRIMITIVE_CODE);
primitive(const primitive& x) ;
virtual ~primitive() {};
void set_mode(obj_mode_t, Boolean);
Boolean swap_order() {
return (storage_ptr) ? storage_ptr -> swap_order() : false;
};
MMDB_SIGNATURES(primitive);
};
#endif

View File

@@ -0,0 +1,417 @@
/*
* $XConsortium: pstring.C /main/6 1996/09/16 14:26:44 mgreess $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/pstring.h"
#ifdef C_API
buffer* pstring::v_io_buf_ptr;
#define v_io_buf (*v_io_buf_ptr)
#else
buffer pstring::v_io_buf(LBUFSIZ);
#endif
void pstring::init_persistent_info(persistent_info* x)
{
root::init_persistent_info(x);
if ( get_mode(OLD_OBJECT) == false ) {
char* y = 0;
if ( storage_ptr )
storage_ptr -> insertString(v_str_ptr.loc, y, 0);
}
}
pstring::pstring(c_code_t c_id) : primitive(c_id),
v_sz(0)
{
//
// CDExc21900
// Make sure the entire union is initialized for 64bit architectures.
//
memset((char*) &v_str_ptr, 0, sizeof(v_str_ptr));
}
pstring::pstring(const char* x, int leng, c_code_t c_id) :
primitive(c_id)
{
_init(x, leng);
}
pstring::pstring(pstring& x) : primitive(x)
{
_init((const char*)x.get(), x.v_sz);
}
void pstring::_init(const char* x, int leng)
{
v_sz = leng;
if ( v_sz == 0 ) {
v_str_ptr.loc = 0;
return;
}
v_str_ptr.p = new char[leng+1];
memcpy(v_str_ptr.p, x, leng);
v_str_ptr.p[leng] = 0;
}
pstring::~pstring()
{
if ( get_mode(PERSISTENT) == false && NULL != v_str_ptr.p )
delete v_str_ptr.p;
}
// /////////////////////////////////////
// should not delete what get() returns!
// /////////////////////////////////////
char* pstring::get(buffer& string_buffer)
{
//MESSAGE(cerr, "get()");
if ( get_mode(PERSISTENT) == true ) {
/*
MESSAGE(cerr, "persistent");
debug(cerr, v_sz);
debug(cerr, v_str_ptr.loc);
debug(cerr, f_oid);
*/
string_buffer.reset();
string_buffer.expand_chunk(v_sz+1);
char* this_v_str_ptr = string_buffer.get_base();
storage_ptr ->
readString(v_str_ptr.loc, this_v_str_ptr, v_sz);
/*
for (int i=0; i<v_sz; i++)
{
cerr << int(this_v_str_ptr[i]) << " " ;
}
cerr << "\n";
*/
this_v_str_ptr[v_sz] = 0;
string_buffer.set_content_sz(v_sz);
return this_v_str_ptr;
} else {
return v_str_ptr.p;
}
}
/*
Boolean pstring::value_LS(root& x, Boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != STRING_CODE ||
x.my_oid().ccode() != STRING_CODE
)
)
return false;
Boolean ok;
char* this_v_str_ptr;
char* x_v_str_ptr;
if ( get_mode(PERSISTENT) == true ) {
this_v_str_ptr = new char[v_sz+1];
storage_ptr -> readString(v_str_ptr.loc, this_v_str_ptr, v_sz);
} else
this_v_str_ptr = v_str_ptr.p;
pstring &casted_x = *(pstring*)&x;
if ( casted_x.get_mode(PERSISTENT) == true ) {
x_v_str_ptr = new char[v_sz+1];
storage_ptr ->
readString(casted_x.v_str_ptr.loc, x_v_str_ptr, casted_x.v_sz);
} else
x_v_str_ptr = casted_x.v_str_ptr.p;
int min_len = MIN(v_sz, casted_x.v_sz);
for ( int i=0; i<min_len; i++ ) {
if ( this_v_str_ptr[i] < x_v_str_ptr[i] ) {
ok = true;
break;
}
if ( this_v_str_ptr[i] > x_v_str_ptr[i] ) {
ok = false;
break;
}
}
if ( i == min_len && v_sz < casted_x.v_sz )
ok = true;
else
ok = false;
if ( get_mode(PERSISTENT) == true )
delete this_v_str_ptr;
if ( casted_x.get_mode(PERSISTENT) == true )
delete x_v_str_ptr;
return ok;
}
Boolean pstring::value_EQ(root& x, Boolean safe) const
{
if ( safe == true &&
( f_oid.ccode() != STRING_CODE ||
x.my_oid().ccode() != STRING_CODE
)
)
return false;
pstring &casted_x = *(pstring*)&x;
if ( v_sz != casted_x.v_sz )
return false;
Boolean ok;
char* this_v_str_ptr;
char* x_v_str_ptr;
if ( get_mode(PERSISTENT) == true ) {
this_v_str_ptr = new char[v_sz+1];
storage_ptr -> readString(v_str_ptr.loc, this_v_str_ptr, v_sz);
} else
this_v_str_ptr = v_str_ptr.p;
if ( casted_x.get_mode(PERSISTENT) == true ) {
x_v_str_ptr = new char[v_sz+1];
storage_ptr ->
readString(casted_x.v_str_ptr.loc, x_v_str_ptr, casted_x.v_sz);
} else
x_v_str_ptr = casted_x.v_str_ptr.p;
//ok = ( bcmp(this_v_str_ptr, x_v_str_ptr, v_sz) == 0 ) ? true : false;
ok = ( memcmp(this_v_str_ptr, x_v_str_ptr, v_sz) == 0 ) ? true : false;
if ( get_mode(PERSISTENT) == true )
delete this_v_str_ptr;
if ( casted_x.get_mode(PERSISTENT) == true )
delete x_v_str_ptr;
return ok;
}
*/
io_status pstring::asciiOut(ostream& out)
{
/*
MESSAGE(cerr, "pstring::asciiOut():");
debug(cerr, v_sz);
debug(cerr, (void*)this);
my_oid().asciiOut(cerr);
cerr << "\n";
*/
const char* x = get();
out << v_sz << '\t';
for ( int i=0; i<v_sz; i++ )
out << x[i];
return done;
}
io_status pstring::asciiIn(istream& in)
{
/*
MESSAGE(cerr, "pstring::asciiIn():");
debug(cerr, (void*)this);
my_oid().asciiOut(cerr);
cerr << "\n";
*/
_asciiIn(in);
pstring::update(v_io_buf.get_base(), v_io_buf.content_sz());
return done;
}
io_status pstring::asciiIn(const char* buf, int size)
{
v_io_buf.reset();
v_io_buf.expand_chunk(size);
memcpy(v_io_buf.get_base(), buf, size);
v_io_buf.set_content_sz(size);
return done;
}
void pstring::_asciiIn(istream& in)
{
if ( ! cc_is_digit(in) )
throw (stringException("a digit expected"));
int len;
in >> len;
int tab = in.get(); // expect a '\t'
if ( tab != '\t' ) {
debug(cerr, len);
debug(cerr, tab);
throw(stringException("'\\t' expected"));
}
v_io_buf.reset();
v_io_buf.expand_chunk(len);
if ( len > 0 &&
( !in.read(v_io_buf.get_base(), len) || in.gcount() != len )
) {
debug(cerr, len);
debug(cerr, v_io_buf.get_base());
throw(stringException("pstring::asciiIn(): read failed"));
}
int ret = in.get(); // expect a '\n'
if ( ret != '\n' ) {
debug(cerr, ret);
throw(stringException(form("'\\n' expected. %c seen. (count=%d)", ret, len)));
}
v_io_buf.set_content_sz(len);
}
Boolean pstring::update(pstring& new_value)
{
return update((const char*)new_value.get(), new_value.v_sz);
}
Boolean pstring::update(const char* new_value, int new_value_sz)
{
/*
MESSAGE(cerr, "pstring:: update value:");
debug(cerr, v_str_ptr.loc);
debug(cerr, f_oid);
debug(cerr, v_sz);
debug(cerr, new_value_sz);
for (int i=0; i<new_value_sz; i++)
{
cerr << int(new_value[i]) << " " ;
}
cerr << "\n";
*/
int old_sz = v_sz;
v_sz = new_value_sz;
if ( get_mode(PERSISTENT) == true ) {
//MESSAGE(cerr, "persist case");
if ( v_str_ptr.loc == 0 ) {
storage_ptr -> insertString(v_str_ptr.loc, new_value, v_sz);
} else {
storage_ptr -> updateString(v_str_ptr.loc, new_value, v_sz);
}
} else {
if ( old_sz < new_value_sz ) {
delete v_str_ptr.p;
v_str_ptr.p = new char[v_sz+1];
}
memcpy(v_str_ptr.p, new_value, v_sz);
}
set_mode(UPDATE, true);
//debug(cerr, this -> get());
return true;
}
int pstring::cdr_sizeof()
{
return primitive::cdr_sizeof() +
sizeof(v_str_ptr.loc) +
sizeof(v_sz);
}
io_status pstring::cdrOut(buffer& buf)
{
primitive::cdrOut(buf);
buf.put(v_str_ptr.loc);
buf.put(v_sz);
return done;
}
io_status pstring::cdrIn(buffer& buf)
{
primitive::cdrIn(buf);
buf.get(v_str_ptr.loc);
buf.get(v_sz);
return done;
}
MMDB_BODIES(pstring)
pstring_handler::pstring_handler(const oid_t& v_oid, storagePtr _store) :
handler(v_oid, _store)
{
}
pstring_handler::pstring_handler(const char* str, int sz, storagePtr _store) :
handler(STRING_CODE, _store)
{
(this -> operator->()) -> update(str, sz);
}
pstring_handler::~pstring_handler()
{
}
pstring* pstring_handler::operator ->()
{
return (pstring*)handler::operator->();
}

View File

@@ -0,0 +1,127 @@
/*
* $XConsortium: pstring.h /main/5 1996/07/18 14:45:25 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _pstring_h
#define _pstring_h 1
#include "object/primitive.h"
#include "utility/buffer.h"
#include "storage/page_storage.h"
/***************************************
* Primitive string class.
****************************************/
class pstring: public primitive
{
protected:
#ifdef C_API
static buffer* v_io_buf_ptr;
#else
static buffer v_io_buf;
#endif
protected:
void _asciiIn(istream&) ; // get input to v_io_buf
public:
pstring(pstring&);
pstring(c_code_t = STRING_CODE);
pstring(const char* string, int sz, c_code_t = STRING_CODE);
virtual ~pstring();
virtual int size() const { return v_sz; };
#ifdef C_API
char* get(buffer& optional_buffer = *v_io_buf_ptr);
#else
char* get(buffer& optional_buffer = v_io_buf);
#endif
MMDB_SIGNATURES(pstring);
void init_persistent_info(persistent_info*);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// update function
virtual Boolean update(pstring& new_value);
virtual Boolean update(const char* new_value, int new_value_sz);
// print function
virtual io_status asciiOut(ostream& s) ;
virtual io_status asciiIn(istream&) ;
virtual io_status asciiIn(const char* buf, int size) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
friend class pstring_handler;
#ifdef C_API
friend void initialize_MMDB();
friend void quit_MMDB();
#endif
protected: // a union of disk/memory pointer
union {
mmdb_pos_t loc;
char* p;
} v_str_ptr;
unsigned int v_sz;
private:
void _init(const char*, int sz);
};
class pstring_handler : public handler
{
protected:
public:
pstring_handler(const oid_t&, storagePtr = 0);
pstring_handler(const char* str, int str_sz, storagePtr = 0);
virtual ~pstring_handler();
pstring* operator ->();
};
#endif

View File

@@ -0,0 +1,111 @@
// $XConsortium: random_gen.C /main/6 1996/08/21 15:56:48 drk $
#include <sys/time.h>
#include <sys/times.h>
#include "object/random_gen.h"
random_gen::~random_gen()
{
}
random_gen::random_gen()
{
#ifdef __uxp__
int seed;
struct tms tp;
if ((seed = (int)times(&tp)) < 0)
seed = 19;
#else
struct timeval tp;
struct timezone tzp;
int seed = ( gettimeofday(&tp, &tzp) == 0 ) ? int(tp.tv_sec) : 19;
#endif
#ifdef CONTROLLED_SEED
if ( getenv("SEED") )
seed = atoi(getenv("SEED"));
cerr << "seed=" << seed << "\n";
#endif
rand_gen.seed(seed);
}
static char char_set[] =
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '.', '_',
'+', '|', '=', '\\', '~'
};
void random_gen::random_string(ostream& out, int len)
{
out << len << "\t";
for ( int i=0; i<len; i++ )
out << char_set[rand_gen.rand() % sizeof(char_set)];
out << "\n";
}
static char* buf = 0;
static int buf_len = 0;
const char* random_gen::get_random_string(int low, int high)
{
int x = pick_a_value(low, high);
if ( buf_len < x ) {
buf_len = x;
delete buf;
buf = new char[buf_len+1];
}
for ( int i=0; i<buf_len; i++ )
buf[i] = char_set[rand_gen.rand() % sizeof(char_set)];
buf[i] = 0;
return buf;
}
int random_gen::pick_a_value(int low, int high)
{
return ( low < high ) ? rand_gen.rand() % (high - low) + low : low;
}
void random_gen::_random_string(ostream& out, int low, int high)
{
int l = pick_a_value(low, high);
random_string(out, l);
}
void random_gen::random_string(ostream& out, int low, int high, Boolean x)
{
if ( x == true )
out << "6\n";
_random_string(out, low, high);
}
void
random_gen::random_string_to_be_compressed(ostream& out, int l, int h, const oid_t& id)
{
out << "11\n";
out << id << "\n";
_random_string(out, l, h);
}
void random_gen::random_oid(ostream& out, int class_code, int instance_code)
{
out << "7\n";
out << class_code << "." << instance_code << "\n";
}
void random_gen::random_integer(ostream& out, int value)
{
out << "4\n";
out << value << "\n";
}

View File

@@ -0,0 +1,34 @@
/* $XConsortium: random_gen.h /main/3 1996/06/11 17:42:42 cde-hal $ */
#ifndef _random_gen_h
#define _random_gen_h
#include "utility/pm_random.h"
#include "object/oid_t.h"
class random_gen
{
protected:
pm_random rand_gen;
protected:
void _random_string(ostream& out, int low, int high);
public:
random_gen();
~random_gen();
pm_random& random_generator() { return rand_gen; };
int pick_a_value(int low, int high);
const char* get_random_string(int low, int high);
void random_string(ostream& out, int len);
void random_string(ostream& out, int low, int high,
Boolean out_string_code = true);
void random_string_to_be_compressed(ostream&, int l, int h, const oid_t& = ground);
void random_oid(ostream&, int class_code = 0, int instance_code = 0);
void random_integer(ostream&, int value = 0);
};
#endif

View File

@@ -0,0 +1,259 @@
/*
* $XConsortium: root.cc /main/5 1996/07/18 14:45:50 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/root.h"
#include "api/transaction.h"
persistent_info::persistent_info(abs_storage* s, c_code_t c,
mmdb_pos_t p, Boolean per, Boolean d)
{
cdr = false;
storage = s;
class_code = c;
position = p;
persistent = per;
old_object = d;
}
persistent_info transient_info;
root::root(c_code_t c_id) : f_oid(c_id, 0)
{
init_persistent_info();
}
root::root(const oid_t& x ) : f_oid(x)
{
init_persistent_info();
}
root::root(const root& x) : f_oid(x.f_oid), status(x.status)
{
init_persistent_info();
}
void root::init_persistent_info(persistent_info* pinfo)
{
/*
MESSAGE(cerr, "STATUS before set");
debug(cerr, int(get_mode(PERSISTENT)));
debug(cerr, int(get_mode(BASE_DATA_INITED)));
debug(cerr, int(storage_ptr));
*/
status.ok = TOBIT(true);
status.ref_count = 0;
storage_ptr = pinfo -> storage;
set_mode(CDR, pinfo -> cdr);
set_mode(PERSISTENT, pinfo -> persistent);
set_mode(SWAP_ALLOWED, true);
switch ( pinfo -> persistent ) {
case true: // disk object case
f_oid.v_i_code = pinfo -> position;
set_mode(OLD_OBJECT, pinfo -> old_object);
break;
case false: // vm object case
f_oid.v_i_code = 0;
set_mode(OLD_OBJECT, false);
break;
}
}
root::~root()
{
}
void root::set_c_code(c_code_t x)
{
f_oid.v_c_code = x;
}
void root::set_mode(obj_mode_t mode, Boolean v)
{
switch ( mode ) {
case HEALTH:
status.ok = TOBIT(v);
break;
case PERSISTENT:
status.persistent = TOBIT(v);
break;
case UPDATE:
if ( v == true && g_transac && storage_ptr ) {
g_transac -> book(f_oid, storage_ptr);
}
status.update= TOBIT(v);
break;
case OLD_OBJECT:
status.old_object= TOBIT(v);
break;
case CDR:
status.cdr= TOBIT(v);
break;
case SWAP_ALLOWED:
status.swap = TOBIT(v);
break;
}
}
Boolean root::get_mode(obj_mode_t mode) const
{
Boolean ok = false;
switch ( mode ) {
case HEALTH:
ok = TOBOOLEAN(status.ok);
break;
case PERSISTENT:
ok = TOBOOLEAN(status.persistent);
break;
case UPDATE:
ok = TOBOOLEAN(status.update);
break;
case OLD_OBJECT:
ok = TOBOOLEAN(status.old_object);
break;
case CDR:
ok = TOBOOLEAN(status.cdr);
break;
case SWAP_ALLOWED:
ok = TOBOOLEAN(status.swap);
break;
}
return ok;
}
void root::reset_ref_count()
{
status.ref_count = 0;
}
void root::set_ref_count(int delta)
{
status.ref_count += delta;
}
int root::get_ref_count()
{
return status.ref_count;
}
Boolean root::OK() const
{
return get_mode(HEALTH);
}
const oid_t& root::my_oid() const
{
return f_oid;
}
io_status root::asciiOut(ostream& out)
{
return f_oid.asciiOut(out);
}
ostream& operator<<(ostream& out, const root& rt)
{
(*(root*)&rt).asciiOut(out);
return out;
}
io_status root::asciiIn(istream& in)
{
return f_oid.asciiIn(in);
}
ostream& root::memory_layout(root* rt, ostream& out)
{
MESSAGE(cerr, "In memory_layout");
debug(cerr, long(rt));
debug(cerr, (int)sizeof(*rt));
long* p = (long*)rt;
int ptrs = sizeof(*rt)/sizeof(long);
for ( int i=0; i<ptrs; i++ )
out << long(p[i]) << " ";
out << "\n";
return out;
}
void* root::heap_alloc( size_t sz )
{
return (void*) new char[sz];
}
int root::cdr_sizeof()
{
return sizeof(char);
}
io_status root::cdrOut(buffer& buf)
{
unsigned int status_rep = 0;
lsb_putbits(status_rep, 3, 1, status.cdr);
lsb_putbits(status_rep, 2, 1, status.ok);
lsb_putbits(status_rep, 1, 1, status.persistent);
lsb_putbits(status_rep, 0, 1, status.update);
buf.put((char)status_rep);
return done;
}
io_status root::cdrIn(buffer& buf)
{
char char_status_rep = 0;
buf.get(char_status_rep);
unsigned int status_rep = char_status_rep;
status.cdr = lsb_getbits((unsigned)status_rep, 3, 1);
status.ok = lsb_getbits((unsigned)status_rep, 2, 1);
status.persistent = lsb_getbits((unsigned)status_rep, 1, 1);
status.update = lsb_getbits((unsigned)status_rep, 0, 1);
return done;
}
MMDB_BODIES(root)
#ifdef C_API
NEW_AND_DELETE_BODIES_SIMPLE(root)
#endif

View File

@@ -0,0 +1,183 @@
/*
* $XConsortium: root.h /main/6 1996/07/18 14:46:10 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _root_h
#define _root_h 1
#include "utility/funcs.h"
#include "utility/buffer.h"
#include "storage/rep_cell.h"
#include "storage/page.h"
#include "object/oid_t.h"
#include "object/c_codes.h"
#include "object/new_delete.h"
//#include "Exceptions.hh"
class abs_storage;
/************************************/
// constants used to name status bits
/************************************/
enum obj_mode_t { HEALTH,
SWAP_ALLOWED,
PERSISTENT,
UPDATE,
OLD_OBJECT,
CDR
};
/************************************/
// structure recording various status
// of an object
/************************************/
struct status_t
{
unsigned reserved: 10; //
unsigned swap: 1; // swapped out allowed? (true, or false)
unsigned cdr: 1; // compacted disk rep? (true, or false)
unsigned ok: 1; // in good shape ? (true, or false)
unsigned persistent: 1; // persistent ? (true, or false)
unsigned update: 1; // updated ? (true, or false)
unsigned old_object :1; // old object? (true, or false)
unsigned ref_count: 16; // reference count [0, 2^16 - 1];
};
/************************************/
// structure recording io information
/************************************/
class persistent_info
{
public:
persistent_info(abs_storage* s = 0, c_code_t = 0,
mmdb_pos_t = 0, Boolean =0, Boolean = 0);
~persistent_info() {};
Boolean cdr;
abs_storage* storage;
c_code_t class_code;
mmdb_pos_t position;
Boolean persistent; // true -> on persisent store
// false -> on memory
Boolean old_object; // true -> object has been created on store
};
extern persistent_info transient_info;
/*************************************/
// The root class
/*************************************/
#define THIS 0 // const to name this object
#define BASE_COMPONENT_INDEX 1 // const to name the 1st component
class root : public Destructable, public rep_cell
{
protected:
/***************************/
// instance-wise data
/***************************/
status_t status;
oid_t f_oid;
abs_storage* storage_ptr;
virtual void init_persistent_info(persistent_info* = &transient_info);
void set_c_code(c_code_t); // set class code
/***************************/
// static data and function
/***************************/
static void* heap_alloc( size_t sz );
public:
root(c_code_t c_id = ROOT_CODE);
root(const oid_t& );
root(const root&);
virtual ~root() ;
#ifdef C_API
NEW_AND_DELETE_SIGNATURES(root);
#endif
MMDB_SIGNATURES(root);
// status set and get functions
virtual void set_mode(obj_mode_t, Boolean);
Boolean get_mode(obj_mode_t) const;
// reference count set and get functions
void reset_ref_count();
void set_ref_count(int delta);
int get_ref_count();
abs_storage* get_store() { return storage_ptr; };
// status inquiry functions
virtual Boolean OK() const ; // in good shape ?
virtual ostream& memory_layout(root*, ostream& = cerr);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// export functions
const oid_t& my_oid() const ; // get oid
// ascii In and Out functions
virtual io_status asciiOut(ostream&) ; // output (ASCII)
virtual io_status asciiIn(istream&) ; // init from istream (ASCII)
friend ostream& operator<<(ostream&, const root&) ;
// compacted disk representation In and Out functions
virtual int cdr_sizeof();
virtual io_status cdrOut(buffer&);
virtual io_status cdrIn(buffer&);
virtual void commit() {}; // for commit all components
friend class template_mgr_t;
friend class service_mgr_t;
friend class oid;
#ifdef C_API
friend void initialize_MMDB();
friend void quit_MMDB();
#endif
};
typedef root* rootPtr;
#endif

View File

@@ -0,0 +1,229 @@
/*
* $XConsortium: short_list.cc /main/4 1996/06/11 17:25:56 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/short_list.h"
short_list::short_list(rootPtr t, c_code_t c_cd) :
oid_list(c_cd), v_tempt(t)
{
}
short_list::short_list(short_list& x) : oid_list(x)
{
v_tempt = x.v_tempt;
}
short_list::~short_list()
{
}
//
//Boolean short_list::value_LS(root& x, Boolean safe) const
//{
// if ( safe == true &&
// ( my_oid().ccode() != SHORT_LIST_CODE ||
// x.my_oid().ccode() != SHORT_LIST_CODE
// )
// )
// return false;
//
// short_list &y = *(short_list*)&x;
//
// if ( sz != y.sz )
// return false;
//
///************************************************/
//// Note: the components are indexed from 1 to sz
///************************************************/
//
// for ( int i=1; i<=sz; i++ ) {
//
// handler* rootPtr1 = get_component(i);
// handler* rootPtr2 = y.get_component(i);
//
// if ( (*rootPtr1) -> value_LS( *rootPtr2 ) == true )
// return true;
// if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false )
// return false;
// }
// return false;
//}
//
//Boolean short_list::value_EQ(root& x, Boolean safe) const
//{
// if ( safe == true &&
// ( my_oid().ccode() != SHORT_LIST_CODE ||
// x.my_oid().ccode() != SHORT_LIST_CODE
// )
// )
// return false;
//
// short_list &y = *(short_list*)&x;
//
// if ( sz != y.sz )
// return false;
//
///************************************************/
//// Note: the components are indexed from 1 to sz
///************************************************/
//
// for ( int i=1; i<sz; i++ ) {
//
// handler* rootPtr1 = get_component(i);
// handler* rootPtr2 = y.get_component(i);
//
// if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false )
// return false;
// }
// return true;
//}
handler* short_list::get_component(int index)
{
if ( !INRANGE(index, 1, v_sz) ) {
MESSAGE(cerr, "out of range in short_list::get_component()");
throw(boundaryException(1, v_sz, index));
}
oid_t x = oid_list::operator()(index);
handler *y = 0;
if ( x.icode() != 0 )
y = new handler(x, storage_ptr);
return y;
}
Boolean short_list::pinned_insert(int index, oid_t& val)
{
return oid_list::update_component(index, val);
}
io_status short_list::asciiOut(ostream& out)
{
out << "OID_T:\n";
my_oid().asciiOut(out);
out << "\n";
for ( int i=1; i<=v_sz; i++ ) {
handler* hd_ptr = get_component(i);
(*hd_ptr) -> asciiOut(out);
out << "\n";
delete hd_ptr;
}
return done;
}
#define OID_BUFFER_SIZE 40
io_status short_list::asciiIn(istream& in)
{
if ( in.get() != LIST_MARK_CHAR ) {
throw(formatException("short_list::asciiIn(): LIST_MARK_CHAR"));
}
if ( in.get() != '\n' ) {
throw(formatException("short_list::asciiIn(): \n"));
}
handler* hd_ptr = 0;
#ifndef C_API
oid_t oid_buffer[OID_BUFFER_SIZE];
int oid_buffer_level = 0;
#endif
char c;
int ct = 0;
while ( (c = in.get()) != LIST_MARK_CHAR ) {
in.putback(c);
c_code_t ccode;
in >> ccode; in.get();
hd_ptr = new handler (oid_t(ccode, 0), storage_ptr);
(*hd_ptr) -> asciiIn(in);
#ifndef C_API
if ( oid_buffer_level == OID_BUFFER_SIZE ) {
ct = oid_list::count();
oid_list::expand_space(OID_BUFFER_SIZE);
for ( int i=0; i<OID_BUFFER_SIZE; i++ ) {
oid_list::update_component(ct+i+1, oid_buffer[i]);
}
oid_buffer_level = 0;
}
oid_buffer[oid_buffer_level] = hd_ptr -> its_oid();
oid_buffer_level++;
#else
oid_list::insert_component(hd_ptr -> its_oid());
#endif
delete hd_ptr;
}
if ( in.get() != '\n' ) {
throw(formatException("short_list::asciiIn(): \n"));
}
#ifndef C_API
if ( oid_buffer_level > 0 ) {
ct = oid_list::count();
oid_list::expand_space(oid_buffer_level);
for ( int i=0; i<oid_buffer_level; i++ ) {
oid_list::update_component(ct+i+1, oid_buffer[i]);
}
}
#endif
return done;
}
rootPtr short_list::get_template()
{
return v_tempt ;
}
MMDB_BODIES(short_list)
HANDLER_BODIES(short_list)

View File

@@ -0,0 +1,77 @@
/*
* $XConsortium: short_list.h /main/5 1996/07/18 14:46:30 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _short_list_h
#define _short_list_h 1
#include "object/oid_list.h"
/***************************************
* short_list class.
****************************************/
class short_list: public oid_list
{
public:
short_list(rootPtr tempt = 0, c_code_t = SHORT_LIST_CODE);
short_list(short_list&);
virtual ~short_list();
MMDB_SIGNATURES(short_list);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// insert component function
Boolean pinned_insert(int index, oid_t&);
// iteration over components
virtual handler* get_component(int index) ;
//virtual handler* get_component(oid_t& comp_oid) ;
// get template
virtual rootPtr get_template();
// print function
virtual io_status asciiOut(ostream&) ;
virtual io_status asciiIn(istream&) ;
protected:
rootPtr v_tempt;
};
HANDLER_SIGNATURES(short_list)
#endif

View File

@@ -0,0 +1,170 @@
/*
* $XConsortium: tuple.cc /main/4 1996/06/11 17:26:06 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "object/tuple.h"
#define MAX_COMPS 50
tuple::tuple(c_code_t c_cd) : oid_list(c_cd)
{
}
tuple::tuple(int comps, c_code_t c_cd) : oid_list(comps, c_cd)
{
}
tuple::tuple(tuple& x) : oid_list(x)
{
}
tuple::~tuple()
{
}
handler* tuple::get_component(int index)
{
//MESSAGE(cerr, "in tuple():: get_component()");
//debug(cerr, index);
//debug(cerr, my_oid());
//debug(cerr, int(storage_ptr));
if (!INRANGE(index, 1, v_sz)) {
MESSAGE(cerr, "out of range in tuple::get_component()");
throw( boundaryException(1, v_sz, index) );
}
oid_t x = oid_list::operator()(index);
//debug(cerr, x);
//debug(cerr, x.ccode());
//debug(cerr, x.icode());
handler* y = 0;
if ( x.icode() != 0 )
y = new handler(x, storage_ptr);
return y;
}
Boolean tuple::pinned_insert(int index, const oid_t& val)
{
//MESSAGE(cerr, "in tuple():: pinned_component()");
//debug(cerr, index);
//debug(cerr, val);
return oid_list::update_component(index, val);
}
io_status tuple::asciiOut(ostream& out)
{
out << "OID_T:\n";
my_oid().asciiOut(out);
out << "\n";
// debug(cerr, v_sz);
for ( int i=1; i<=v_sz; i++ ) {
handler* hd_ptr = get_component(i);
if ( hd_ptr == 0 )
continue;
(*hd_ptr) -> asciiOut(out);
out << "\n";
delete hd_ptr;
}
return done;
}
io_status tuple::asciiIn(istream& in)
{
/*
MESSAGE(cerr, "in tuple asciiIn()");
my_oid().asciiOut(cerr);
MESSAGE(cerr, "\n");
*/
int comps; in >> comps;
if ( comps > MAX_COMPS ) {
debug(cerr, comps);
throw(stringException("exceed MAX_COMPS"));
}
//debug(cerr, comps);
int ret = in.get();
if ( ret != '\n' ) {
debug(cerr, ret);
throw(stringException("'\\n' expected"));
}
if ( comps > v_sz ) {
MESSAGE(cerr, "tuple asciiIn(): to expand space");
debug(cerr, comps);
debug(cerr, v_sz);
oid_list::expand_space(comps - v_sz);
v_sz = comps;
}
handler *hd_ptr = 0;
for ( int i=1; i<=comps; i++ ) {
c_code_t ccode;
in >> ccode;
if ( in.get() != '\n' ) {
throw(stringException("'\\n' expected"));
}
hd_ptr = new handler(ccode, storage_ptr);
(*hd_ptr) -> asciiIn(in);
pinned_insert(i, hd_ptr -> its_oid());
delete hd_ptr;
}
set_mode(UPDATE, true);
return done;
}
MMDB_BODIES(tuple)
HANDLER_BODIES(tuple)

View File

@@ -0,0 +1,70 @@
/*
* $XConsortium: tuple.h /main/5 1996/07/18 14:46:49 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _tuple_h
#define _tuple_h 1
#include "object/oid_list.h"
/***************************************
* tuple class.
****************************************/
class tuple: public oid_list
{
protected:
public:
tuple(c_code_t = TUPLE_CODE);
tuple(int num_comps, c_code_t);
tuple(tuple&);
virtual ~tuple();
MMDB_SIGNATURES(tuple);
/*
// value comparison functions
virtual Boolean value_EQ(root&, Boolean safe = true) const ;
virtual Boolean value_LS(root&, Boolean safe = true) const ;
*/
// insert component function
Boolean pinned_insert(int index, const oid_t&);
// iteration over components
virtual handler* get_component(int index) ;
//virtual handler* get_component(oid_t& comp_oid) ;
// print function
virtual io_status asciiOut(ostream&) ;
virtual io_status asciiIn(istream&) ;
};
HANDLER_SIGNATURES(tuple)
#endif