vdkxdb 2.4.0
vdkxtable.h
1 /*
2  * ===========================
3  * VDK Visual Development Kit
4  * xdb subsystem
5  * Version 0.1
6  * Revision 0.0
7  * April 2000
8  * ===========================
9  *
10  * Copyright (C) 1998, Mario Motta
11  * Developed by Mario Motta <mmotta@guest.net>
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Library General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26  * 02111-1307, USA.
27  */
28 
29 #ifndef _vdkxdbtable_h
30 #define _vdkxdbtable_h
31 #include <vdk/vdkstring.h>
32 #include <vdk/vdkprops.h>
33 #include <vdk/dlist.h>
34 #include <xbase/dbf.h>
35 #include <xbase/ndx.h>
36 
37 // see into xdb/xdb/dbf.h
38 typedef xbSchema VDKXRecordTemplate ;
39 
40 class VDKXDatabase;
41 class VDKXTableIndex;
42 
43 
44 typedef VDKList<VDKXTableIndex> IndexList;
45 typedef VDKListIterator<VDKXTableIndex> IndexListIterator;
46 
47 
55 class VDKXTable: public xbDbf
56 {
57  protected:
59  VDKString name;
61  IndexList iList;
62  void SetOrder(xbShort ndx);
63  bool open;
64  VDKXTableIndex* activeIndex;
65  public:
66  /*
67  table properties
68  */
70  VDKReadOnlyValueProp<VDKXTable,xbLong> Size;
71 
76  VDKReadWriteValueProp<VDKXTable,xbShort> Order;
82  void SetOrder(char* name);
87  VDKReadWriteValueProp<VDKXTable,bool> ShowDeleted;
88  //---------------------------------------------
89  /*
90  Internal use only (mainly for builder)
91  User don't care.
92  */
93  VDKReadWriteValueProp<VDKXTable,bool> Active;
94  //---------------------------------------------
101  VDKXTable(VDKXDatabase* owner, char* name);
103  virtual ~VDKXTable();
105  VDKString Name() { return name; }
118  xbShort Create(VDKXRecordTemplate* tpl, bool overwrite = false);
128  xbShort Open(void);
135  xbShort Close(void);
141  bool RemoveIndex(char* name);
147  VDKXTableIndex* Index(char* name);
153  VDKXTableIndex* Index(xbShort order);
167  xbShort First();
181  xbShort Last();
195  xbShort Next();
209  xbShort Prev();
211  IndexList* NdxList() { return &iList; }
213  bool IsOpen() { return open; }
214 };
215 
220 class VDKXTableIndex: public xbNdx
221 {
222  protected:
223  VDKString name,key;
224  VDKXTable* table;
225  bool open;
226  public:
232  VDKXTableIndex(VDKXTable* owner, char* s);
234  virtual ~VDKXTableIndex();
250  xbShort Create(char* key,
251  bool unique = true ,
252  bool overwrite = false
253  );
255  xbShort Open(void);
262  xbShort Close(void);
264  VDKString Name() { return name; }
266  VDKString Key() { return key; }
268  bool IsOpen() { return open; }
269 };
270 
271 #endif
272