全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 ページ
nsTable.h
1 #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_NSTABLE_H
2 #define BZS_DB_PROTOCOL_TDAP_CLIENT_NSTABLE_H
3 /* =================================================================
4  Copyright (C) 2000-2016 BizStation Corp All rights reserved.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20  ================================================================= */
21 #include <bzs/db/protocol/tdap/tdapcapi.h>
22 #include <bzs/env/tstring.h>
23 #include <bzs/db/protocol/tdap/tdapSchema.h>
24 #include <bzs/rtl/exception.h>
25 #include "export.h"
26 #include <limits.h>
27 
28 namespace bzs
29 {
30 namespace db
31 {
32 namespace protocol
33 {
34 namespace tdap
35 {
36 namespace client
37 {
38 
39 class nsdatabase;
40 class nstable;
41 class bulkInsert;
42 
43 #define BULKBUFSIZE USHRT_MAX - 1000
44 
45 class DLLLIB nstable
46 {
47  friend class nsdatabase; // for destroy()
48  friend class filter;
49 
50 public:
52  {
55  changeInKey
56  };
57  enum eFindType
58  {
61  findContinue
62  };
63  static const bool inkey = true;
64 
65 private:
66  struct nstimpl* m_impl;
67 
68  nstable(const nstable&);
69  const nstable& operator=(const nstable&);
70  void doUpdate(eUpdateType type);
71  ushort_td doInsert(bool ncc);
72  static _TCHAR* getErrorMessage(int errorCode, _TCHAR* buf, size_t size);
73 
74 protected:
75  void* m_pdata;
76  void* m_keybuf;
77  uint_td m_buflen;
78  uint_td m_datalen;
79  ushort_td m_op;
80  keylen_td m_keybuflen;
81  keylen_td m_keylen;
82  mutable short_td m_stat;
83  char_td m_keynum;
84 
85  union
86  {
87  struct
88  {
89  uchar_td m_read : 1;
90  uchar_td m_write : 1;
91  uchar_td m_insart : 1;
92  uchar_td m_delete : 1;
93  uchar_td m_reserverd : 4;
94  };
95  uchar_td m_curd;
96  };
97 
98  virtual ~nstable();
99  const _TCHAR* uri() const;
100  const uchar_td* posblk() const;
101  void setIsOpen(bool v);
102  void setMode(char_td v); //For dbdef in noschema mode.
103 
104  bulkInsert* bulkIns() const;
105  virtual bool isUniqeKey(char_td keynum)
106  {
107  return false;
108  } // for chacek updates deletes at key
109  virtual void writeRecordData() = 0;
110  virtual int onInsertBefore()
111  {
112  writeRecordData();
113  return 0;
114  };
115  virtual void onInsertAfter(int beforeResult);
116  virtual bool onUpdateCheck(eUpdateType type) { return true; };
117  virtual int onUpdateBefore()
118  {
119  writeRecordData();
120  return 0;
121  };
122  virtual void onUpdateAfter(int beforeResult){};
123  virtual bool onDeleteCheck(bool in_key) { return true; };
124  virtual void doDel(bool inkey);
125  virtual keylen_td writeKeyData() { return 0; };
126  virtual void onReadAfter() = 0;
127  virtual uint_td doGetWriteImageLen() { return m_buflen; };
128  virtual void doOpen(const _TCHAR* name, char_td mode,
129  const _TCHAR* ownername);
130  virtual void doClose();
131  virtual void doCreateIndex(bool specifyKeyNum);
132  virtual uint_td doRecordCount(bool estimate, bool fromCurrent);
133  virtual short_td doBtrvErr(HWND hWnd, _TCHAR* retbuf);
134  virtual ushort_td doCommitBulkInsert(bool autoCommit);
135  virtual void doAbortBulkInsert();
136  virtual __int64 getUpdateStampValue() const {return 0;}
137  virtual bool getUpdateStampEnable() const {return false;}
138  inline void open(const _TCHAR* uri, char_td mode = 0,
139  const _TCHAR* ownerName = NULL)
140  {
141  doOpen(uri, mode, ownerName);
142  }
143 
144  /*
145  This method is ignore refarence count of nstable and force delete.
146  Use in nsdatabase::reset()
147  */
148  void destroy();
149  void setShared();
150  void seekByBookmark(bookmark_td* bm, ushort_td lockBias = LOCK_BIAS_DEFAULT);
151  const bzs::db::blobHeader* getBlobHeader();
152 public:
153  explicit nstable(nsdatabase* pbe);
154  void addref(void);
155  void release();
156  int refCount() const;
157  nsdatabase* nsdb() const;
158  short tableid() const;
159  void setTableid(short v);
160  bool isOpen() const;
161  bool isUseTransactd() const;
162  inline void setAccessRights(unsigned char curd) { m_curd = curd; };
163  inline const void* data() const { return m_pdata; }
164  inline void setData(void* v) { m_pdata = v; }
165  inline uint_td buflen() const { return m_buflen; }
166  inline void setBuflen(uint_td v) { m_buflen = v; }
167  inline uint_td datalen() const { return m_datalen; }
168  inline short_td stat() const { return m_stat; }
169  inline void setStat(short_td v) { m_stat = v; }
170  inline char_td keyNum() const { return m_keynum; }
171  inline void setKeyNum(char_td v) { m_keynum = v; }
172  inline bool canRead() const { return (bool)m_read; }
173  inline bool canWrite() const { return (bool)m_write; }
174  inline bool canInsert() const { return (bool)m_insart; }
175  inline bool canDelete() const { return (bool)m_delete; }
176  inline uint_td getWriteImageLen() { return doGetWriteImageLen(); };
177  inline void close() { doClose(); }
178  inline void update(eUpdateType type = changeCurrentCc) { doUpdate(type); }
179  inline void del(bool in_key = false) { doDel(in_key); }
180  inline ushort_td insert(bool ncc = false) { return doInsert(ncc); };
181  inline void createIndex(bool specifyKeyNum = false)
182  {
183  doCreateIndex(specifyKeyNum);
184  }
185  void dropIndex(bool norenumber = false);
186  inline uint_td recordCount(bool estimate = true, bool fromCurrent = false)
187  {
188  return doRecordCount(estimate, fromCurrent);
189  }
190  inline short_td tdapErr(HWND hWnd, _TCHAR* retbuf = NULL)
191  {
192  return doBtrvErr(hWnd, retbuf);
193  }
194  inline _TCHAR* statMsg(_TCHAR* retbuf)
195  {
196  doBtrvErr(0, retbuf);
197  return retbuf;
198  }
199 
200  void beginBulkInsert(int maxBuflen=BULKBUFSIZE);
201  void abortBulkInsert() { doAbortBulkInsert(); }
202  inline ushort_td commitBulkInsert(bool autoCommit = false)
203  {
204  return doCommitBulkInsert(autoCommit);
205  }
206  void tdap(ushort_td op);
207  void seekFirst(ushort_td lockBias = LOCK_BIAS_DEFAULT);
208  void seekLast(ushort_td lockBias = LOCK_BIAS_DEFAULT);
209  void seekPrev(ushort_td lockBias = LOCK_BIAS_DEFAULT);
210  void seekNext(ushort_td lockBias = LOCK_BIAS_DEFAULT);
211  void seek(ushort_td lockBias = LOCK_BIAS_DEFAULT);
212  void seekGreater(bool orEqual, ushort_td lockBias = LOCK_BIAS_DEFAULT);
213  void seekLessThan(bool orEqual, ushort_td lockBias = LOCK_BIAS_DEFAULT);
214  void stepFirst(ushort_td lockBias = LOCK_BIAS_DEFAULT);
215  void stepLast(ushort_td lockBias = LOCK_BIAS_DEFAULT);
216  void stepPrev(ushort_td lockBias = LOCK_BIAS_DEFAULT);
217  void stepNext(ushort_td lockBias = LOCK_BIAS_DEFAULT);
218  ushort_td bookmarkLen() const ;
219  bookmark_td bookmark();
220  void seekByBookmark(bookmark_td& bm, ushort_td lockBias = LOCK_BIAS_DEFAULT);
221  void seekByBookmark();
222  percentage_td getPercentage();
223  percentage_td getPercentage(bookmark_td& bm);
224  void seekByPercentage();
225  void seekByPercentage(percentage_td pc);
226  void setOwnerName(const _TCHAR* name, char_td enctype = 0);
227  void clearOwnerName();
228  ushort_td recordLength();
229  void stats(void* databuffer, uint_td buflen, bool estimate = true);
230  char* getCreateSql(char* retbuf, uint_td* size);
231  void unlock(bookmark_td& bm);
232  void unlock();
233  char_td mode() const;
234  void setTimestampMode(int mode);
235  bool setUpdateConflictCheck(bool v);
236  bool updateConflictCheck() const;
237  static _TCHAR* getFileName(const _TCHAR* uri, _TCHAR* retbuf);
238  static short_td tdapErr(HWND hWnd, short_td status,
239  const _TCHAR* tableName = NULL,
240  _TCHAR* retbuf = NULL);
241  static void throwError(const _TCHAR* caption, short statusCode);
242  static void throwError(const _TCHAR* caption, nstable* tb);
243  static _TCHAR* getDirURI(const _TCHAR* uri, _TCHAR* retbuf);
244  static bool existsFile(const _TCHAR* filename);
245  /** @cond INTERNAL */
246  static bool test(nstable* p);
247  void test_store(const char* values);
248  /** @endcond*/
249 };
250 
251 } // namespace client
252 } // namespace tdap
253 } // namespace protocol
254 } // namespace db
255 } // namespace bzs
256 
257 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_NSTABLE_H
void * m_keybuf
Definition: nsTable.h:76
void setBuflen(uint_td v)
Definition: nsTable.h:166
short_td tdapErr(HWND hWnd, _TCHAR *retbuf=NULL)
Definition: nsTable.h:190
void del(bool in_key=false)
Definition: nsTable.h:179
bool canWrite() const
Definition: nsTable.h:173
void abortBulkInsert()
Definition: nsTable.h:201
const void * data() const
Definition: nsTable.h:163
char_td m_keynum
Definition: nsTable.h:83
uint_td m_datalen
Definition: nsTable.h:78
virtual int onInsertBefore()
Definition: nsTable.h:110
keylen_td m_keylen
Definition: nsTable.h:81
ushort_td commitBulkInsert(bool autoCommit=false)
Definition: nsTable.h:202
bool canRead() const
Definition: nsTable.h:172
virtual __int64 getUpdateStampValue() const
Definition: nsTable.h:136
BOOKMARK構造体
Definition: tdapcapi.h:37
データベースアクセス基本クラス (nocopyable)
Definition: nsDatabase.h:85
void setKeyNum(char_td v)
Definition: nsTable.h:171
_TCHAR * statMsg(_TCHAR *retbuf)
Definition: nsTable.h:194
virtual bool isUniqeKey(char_td keynum)
Definition: nsTable.h:105
eFindType
findオペレーションで検索の方向を示すタイプ
Definition: nsTable.h:57
void setStat(short_td v)
Definition: nsTable.h:169
uint_td m_buflen
Definition: nsTable.h:77
bool canDelete() const
Definition: nsTable.h:175
テーブルアクセスの基本クラス (abstruct nocopyable)
Definition: nsTable.h:45
short_td m_stat
Definition: nsTable.h:82
short_td stat() const
Definition: nsTable.h:168
uint_td recordCount(bool estimate=true, bool fromCurrent=false)
Definition: nsTable.h:186
virtual bool onDeleteCheck(bool in_key)
Definition: nsTable.h:123
uint_td getWriteImageLen()
Definition: nsTable.h:176
virtual keylen_td writeKeyData()
Definition: nsTable.h:125
virtual bool getUpdateStampEnable() const
Definition: nsTable.h:137
keylen_td m_keybuflen
Definition: nsTable.h:80
virtual void onUpdateAfter(int beforeResult)
Definition: nsTable.h:122
uint_td buflen() const
Definition: nsTable.h:165
uchar_td m_curd
Definition: nsTable.h:95
ushort_td insert(bool ncc=false)
Definition: nsTable.h:180
void createIndex(bool specifyKeyNum=false)
Definition: nsTable.h:181
uint_td datalen() const
Definition: nsTable.h:167
void open(const _TCHAR *uri, char_td mode=0, const _TCHAR *ownerName=NULL)
Definition: nsTable.h:138
void close()
Definition: nsTable.h:177
ushort_td m_op
Definition: nsTable.h:79
void * m_pdata
Definition: nsTable.h:75
bool canInsert() const
Definition: nsTable.h:174
eUpdateType
更新オペレーションの対象とカレント移動のタイプ
Definition: nsTable.h:51
void update(eUpdateType type=changeCurrentCc)
Definition: nsTable.h:178
char_td keyNum() const
Definition: nsTable.h:170
virtual bool onUpdateCheck(eUpdateType type)
Definition: nsTable.h:116
void setAccessRights(unsigned char curd)
Definition: nsTable.h:162
virtual int onUpdateBefore()
Definition: nsTable.h:117
virtual uint_td doGetWriteImageLen()
Definition: nsTable.h:127
void setData(void *v)
Definition: nsTable.h:164

Transactd SDK 2018年07月31日(火) 19時40分22秒 doxygen