Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / storage / abs_storage.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: abs_storage.h /main/6 1996/07/18 14:52:29 drk $
25  *
26  * Copyright (c) 1992 HAL Computer Systems International, Ltd.
27  * All rights reserved.  Unpublished -- rights reserved under
28  * the Copyright Laws of the United States.  USE OF A COPYRIGHT
29  * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
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 _abs_storage_h
52 #define _abs_storage_h 1
53
54 #include "storage/rep_policy.h"
55 #include "utility/buffer.h"
56 #include "utility/types.h"
57 #include "object/root.h"
58 #include "storage/version.h"
59
60 /*****************************************
61 // abstract storage class
62 // this class provides a set of common
63 // member function signatures and a policy
64 // pointer for all derived storage classes. 
65 *****************************************/
66
67 typedef enum
68 {
69         mmdb_big_endian = 1,
70         mmdb_little_endian = 2
71 } mmdb_byte_order_t;
72
73
74 class abs_storage : public root 
75 {
76 public:
77    int index_num;
78
79    abs_storage( char* path, char* name, 
80                 c_code_t c_id, 
81                 rep_policy* rep_p = 0
82               );
83    virtual ~abs_storage() ;
84
85    void sync() {};
86    virtual void remove() = 0; // wipe all contents
87
88    // i/o functions
89    virtual int readString (mmdb_pos_t loc, char* base, int len, 
90                   int str_offset = 0) = 0;
91    virtual int insertString(mmdb_pos_t& loc, const char* base, int len, Boolean flush = false) = 0;
92    virtual int appendString(mmdb_pos_t loc, const char*, int len, 
93                             Boolean flush_opt = false) = 0;
94
95
96    virtual int get_str_ptr(mmdb_pos_t loc, char*&, int& len
97                           )  = 0;
98
99    virtual int updateString(mmdb_pos_t loc, const char* base, int len, 
100                     int string_ofst = 0, Boolean flush = false) = 0;
101    virtual int deleteString (mmdb_pos_t loc, Boolean flush = false) = 0;
102    virtual int allocString (mmdb_pos_t& loc, int len, 
103                             char*&, int mode = 0) = 0;
104 // status functions
105    virtual const char* my_path() { return path; };
106    virtual const char* my_name() { return name; };
107    virtual Boolean io_mode(int mode) = 0;
108
109 // return byte order of the machine with one of enums in MMDB_BYTE_ORDER
110    int byte_order();
111    virtual Boolean swap_order() { return v_swap_order; };
112
113    mm_version& get_db_version() { return f_version; };
114
115    friend class storage_mgr_t;
116
117 protected:
118    char path[PATHSIZ];
119    char name[PATHSIZ];
120    rep_policy *policy;
121    Boolean v_swap_order;
122
123    mm_version f_version;
124 };
125
126 typedef abs_storage* storagePtr;
127
128 #endif