Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / index / index.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  * $XConsortium: index.h /main/7 1996/08/21 15:52:20 drk $
25  *
26  * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27  * All rights reserved.  Unpublished -- rights reserved under
28  * the Copyright Laws of the United States.  USE OF A COPYRIGHT
29  * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
30  * OR DISCLOSURE.
31  * 
32  * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33  * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.  USE,
34  * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35  * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
36  * INTERNATIONAL, LTD.
37  * 
38  *                         RESTRICTED RIGHTS LEGEND
39  * Use, duplication, or disclosure by the Government is subject
40  * to the restrictions as set forth in subparagraph (c)(l)(ii)
41  * of the Rights in Technical Data and Computer Software clause
42  * at DFARS 252.227-7013.
43  *
44  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
45  *                  1315 Dell Avenue
46  *                  Campbell, CA  95008
47  * 
48  */
49
50
51 #ifndef _index_h
52 #define _index_h 1
53
54 #ifdef C_API
55 #include "utility/c_strstream.h"
56 #else
57 #include <strstream.h>
58 #endif
59
60 #include "object/oid_list.h"
61 #include "index/inv_lists.h"
62
63 class c_index : public composite
64 {
65    
66 public:
67    c_index(c_code_t = INDEX_CODE);
68    virtual ~c_index() {} ;
69
70    void init_persistent_info(persistent_info* x);
71
72
73    void set_selector(int cmp) { v_cmp_selector = cmp; };
74
75 // iteration functions
76    virtual oid_list_handler* operator()(int index);
77    virtual oid_t first_of_invlist(int ind) ;
78    virtual oid_t first_of_invlist(const handler&);
79
80 // insert index functions
81    virtual Boolean batch_index_begin() { return true; };
82    virtual Boolean batch_index_end() { return true; };
83    virtual Boolean insert_key_loc(const handler&, const oid_t&) = 0;
84    virtual Boolean insert_key_loc(const oid_t&, const oid_t&) = 0;
85    virtual Boolean load(const char*) { return true; };
86
87 // remove index functions
88    virtual Boolean remove_loc(handler&, const oid_t&) = 0;
89    virtual Boolean remove_loc(const oid_t&, const oid_t&) = 0;
90
91 // update index function
92    virtual Boolean update_streampos(handler& old_obj,     
93                                     handler& new_obj,
94                                     mmdb_pos_t pos
95                                    ) = 0;
96
97 // retreval functions
98    virtual oid_list_handler* get_loc_list(const oid_t&)=0;
99    virtual oid_list_handler* get_loc_list(const handler&)=0;
100    virtual int invlist_length(handler&) = 0;
101
102 // translate a query to an index of an inv_list
103    virtual int handler_to_inv_idx(const handler& query) = 0;
104
105 // status inquiry functions
106    int bound_to() const { return v_cmp_selector; } ;
107    virtual Boolean sorted() const = 0;
108
109    virtual int cdr_sizeof();
110    virtual io_status cdrOut(buffer&);
111    virtual io_status cdrIn(buffer&);
112    void commit();
113
114 // i/o function
115    friend ostream& operator <<(ostream& s, c_index& t) ;
116
117 #ifdef C_API
118    friend void initialize_MMDB();
119    friend void quit_MMDB();
120 #endif
121
122 protected:
123    Boolean get_key_string(const handler&) const;
124    Boolean get_key_string(const oid_t&) const;
125
126 protected:
127
128 #ifdef C_API
129    static key_type* v_static_key_ptr;
130 #else
131    static key_type v_static_key;
132 #endif
133
134    int v_cmp_selector;
135    inv_lists_handler *v_inv_lists_hd;
136 };
137
138 typedef c_index* indexPtr;
139
140 HANDLER_SIGNATURES(c_index)
141
142 #endif