全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド ページ
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-2013 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 
27 namespace bzs
28 {
29 namespace db
30 {
31 namespace protocol
32 {
33 namespace tdap
34 {
35 namespace client
36 {
37 
38 class nsdatabase;
39 class nstable;
40 class bulkInsert;
41 
42 #define BULKBUFSIZE USHRT_MAX - 1000
43 
44 class DLLLIB nstable
45 {
46  friend class nsdatabase; // for destroy()
47  friend class filter;
48 
49 public:
51  {
54  changeInKey
55  };
56  enum eFindType
57  {
60  findContinue
61  };
62  static const bool inkey = true;
63 
64 private:
65  struct nstimpl* m_impl;
66 
67  nstable(const nstable&);
68  const nstable& operator=(const nstable&);
69  void doUpdate(eUpdateType type);
70  ushort_td doInsert(bool ncc);
71  static _TCHAR* getErrorMessage(int errorCode, _TCHAR* buf, size_t size);
72 
73 protected:
74  void* m_pdata;
75  uint_td m_buflen;
76  uint_td m_datalen;
77  void* m_keybuf;
78  ushort_td m_op;
79  keylen_td m_keybuflen;
80  keylen_td m_keylen;
81  mutable short_td m_stat;
82  char_td m_keynum;
83 
84  union
85  {
86  struct
87  {
88  uchar_td m_read : 1;
89  uchar_td m_write : 1;
90  uchar_td m_insart : 1;
91  uchar_td m_delete : 1;
92  uchar_td m_reserverd : 4;
93  };
94  uchar_td m_curd;
95  };
96 
97  virtual ~nstable();
98  const _TCHAR* uri() const;
99  const uchar_td* posblk() const;
100  void setIsOpen(bool v);
101 
102  bulkInsert* bulkIns() const;
103  virtual bool isUniqeKey(char_td keynum)
104  {
105  return false;
106  } // for chacek updates deletes at key
107  virtual void writeRecordData() = 0;
108  virtual int onInsertBefore()
109  {
110  writeRecordData();
111  return 0;
112  };
113  virtual void onInsertAfter(int beforeResult);
114  virtual bool onUpdateCheck(eUpdateType type) { return true; };
115  virtual int onUpdateBefore()
116  {
117  writeRecordData();
118  return 0;
119  };
120  virtual void onUpdateAfter(int beforeResult){};
121  virtual bool onDeleteCheck(bool in_key) { return true; };
122  virtual void doDel(bool inkey);
123  virtual keylen_td writeKeyData() { return 0; };
124  virtual void onReadAfter() = 0;
125  virtual uint_td doGetWriteImageLen() { return m_buflen; };
126  virtual void doOpen(const _TCHAR* name, char_td mode,
127  const _TCHAR* ownername);
128  virtual void doClose();
129  virtual void doCreateIndex(bool specifyKeyNum);
130  virtual uint_td doRecordCount(bool estimate, bool fromCurrent);
131  virtual short_td doBtrvErr(HWND hWnd, _TCHAR* retbuf);
132  virtual ushort_td doCommitBulkInsert(bool autoCommit);
133  virtual void doAbortBulkInsert();
134  inline void open(const _TCHAR* uri, char_td mode = 0,
135  const _TCHAR* ownerName = NULL)
136  {
137  doOpen(uri, mode, ownerName);
138  }
139 
140  /*
141  This method is ignore refarence count of nstable and force delete.
142  Use in nsdatabase::reset()
143  */
144  void destroy();
145  void setShared();
146  void seekByBookmark(bookmark_td* bm, ushort_td lockBias = LOCK_BIAS_DEFAULT);
147 public:
148  explicit nstable(nsdatabase* pbe);
149  void addref(void);
150  void release();
151  int refCount() const;
152  nsdatabase* nsdb() const;
153  short tableid() const;
154  void setTableid(short v);
155  bool isOpen() const;
156  bool isUseTransactd() const;
157  inline void setAccessRights(unsigned char curd) { m_curd = curd; };
158  inline const void* data() const { return m_pdata; }
159  inline void setData(void* v) { m_pdata = v; }
160  inline uint_td buflen() const { return m_buflen; }
161  inline void setBuflen(uint_td v) { m_buflen = v; }
162  inline uint_td datalen() const { return m_datalen; }
163  inline short_td stat() const { return m_stat; }
164  inline void setStat(short_td v) { m_stat = v; }
165  inline char_td keyNum() const { return m_keynum; }
166  inline void setKeyNum(char_td v) { m_keynum = v; }
167  inline bool canRead() const { return (bool)m_read; }
168  inline bool canWrite() const { return (bool)m_write; }
169  inline bool canInsert() const { return (bool)m_insart; }
170  inline bool canDelete() const { return (bool)m_delete; }
171  inline uint_td getWriteImageLen() { return doGetWriteImageLen(); };
172  inline void close() { doClose(); }
173  inline void update(eUpdateType type = changeCurrentCc) { doUpdate(type); }
174  inline void del(bool in_key = false) { doDel(in_key); }
175  inline ushort_td insert(bool ncc = false) { return doInsert(ncc); };
176  inline void createIndex(bool specifyKeyNum = false)
177  {
178  doCreateIndex(specifyKeyNum);
179  }
180  void dropIndex(bool norenumber = false);
181  inline uint_td recordCount(bool estimate = true, bool fromCurrent = false)
182  {
183  return doRecordCount(estimate, fromCurrent);
184  }
185  inline short_td tdapErr(HWND hWnd, _TCHAR* retbuf = NULL)
186  {
187  return doBtrvErr(hWnd, retbuf);
188  }
189  inline _TCHAR* statMsg(_TCHAR* retbuf)
190  {
191  doBtrvErr(0, retbuf);
192  return retbuf;
193  }
194 
195  void beginBulkInsert(int maxBuflen);
196  void abortBulkInsert() { doAbortBulkInsert(); }
197  inline ushort_td commitBulkInsert(bool autoCommit = false)
198  {
199  return doCommitBulkInsert(autoCommit);
200  }
201  void tdap(ushort_td op);
202  void seekFirst(ushort_td lockBias = LOCK_BIAS_DEFAULT);
203  void seekLast(ushort_td lockBias = LOCK_BIAS_DEFAULT);
204  void seekPrev(ushort_td lockBias = LOCK_BIAS_DEFAULT);
205  void seekNext(ushort_td lockBias = LOCK_BIAS_DEFAULT);
206  void seek(ushort_td lockBias = LOCK_BIAS_DEFAULT);
207  void seekGreater(bool orEqual, ushort_td lockBias = LOCK_BIAS_DEFAULT);
208  void seekLessThan(bool orEqual, ushort_td lockBias = LOCK_BIAS_DEFAULT);
209  void stepFirst(ushort_td lockBias = LOCK_BIAS_DEFAULT);
210  void stepLast(ushort_td lockBias = LOCK_BIAS_DEFAULT);
211  void stepPrev(ushort_td lockBias = LOCK_BIAS_DEFAULT);
212  void stepNext(ushort_td lockBias = LOCK_BIAS_DEFAULT);
213  ushort_td bookmarkLen() const ;
214  bookmark_td bookmark();
215  void seekByBookmark(bookmark_td& bm, ushort_td lockBias = LOCK_BIAS_DEFAULT);
216  void seekByBookmark();
217  percentage_td getPercentage();
218  percentage_td getPercentage(bookmark_td& bm);
219  void seekByPercentage();
220  void seekByPercentage(percentage_td pc);
221  void setOwnerName(const _TCHAR* name, char_td enctype = 0);
222  void clearOwnerName();
223  ushort_td recordLength();
224  void stats(void* databuffer, uint_td buflen, bool estimate = true);
225  void unlock(bookmark_td& bm);
226  void unlock();
227  char_td mode() const;
228  static _TCHAR* getFileName(const _TCHAR* uri, _TCHAR* retbuf);
229  static short_td tdapErr(HWND hWnd, short_td status,
230  const _TCHAR* tableName = NULL,
231  _TCHAR* retbuf = NULL);
232  static void throwError(const _TCHAR* caption, short statusCode);
233  static void throwError(const _TCHAR* caption, nstable* tb);
234  static _TCHAR* getDirURI(const _TCHAR* uri, _TCHAR* retbuf);
235  static bool existsFile(const _TCHAR* filename);
236  /** @cond INTERNAL */
237  static bool test(nstable* p);
238  /** @endcond*/
239 };
240 
241 } // namespace client
242 } // namespace tdap
243 } // namespace protocol
244 } // namespace db
245 } // namespace bzs
246 
247 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_NSTABLE_H
void * m_keybuf
Definition: nsTable.h:77
const _TCHAR * protocol(const _TCHAR *uri)
Definition: uri.h:42
void setBuflen(uint_td v)
Definition: nsTable.h:161
short_td tdapErr(HWND hWnd, _TCHAR *retbuf=NULL)
Definition: nsTable.h:185
void del(bool in_key=false)
Definition: nsTable.h:174
bool canWrite() const
Definition: nsTable.h:168
void abortBulkInsert()
Definition: nsTable.h:196
const void * data() const
Definition: nsTable.h:158
char_td m_keynum
Definition: nsTable.h:82
uint_td m_datalen
Definition: nsTable.h:76
virtual int onInsertBefore()
Definition: nsTable.h:108
keylen_td m_keylen
Definition: nsTable.h:80
ushort_td commitBulkInsert(bool autoCommit=false)
Definition: nsTable.h:197
bool canRead() const
Definition: nsTable.h:167
データベースアクセス基本クラス (nocopyable)
Definition: nsDatabase.h:55
void setKeyNum(char_td v)
Definition: nsTable.h:166
_TCHAR * statMsg(_TCHAR *retbuf)
Definition: nsTable.h:189
virtual bool isUniqeKey(char_td keynum)
Definition: nsTable.h:103
eFindType
findオペレーションで検索の方向を示すタイプ
Definition: nsTable.h:56
void setStat(short_td v)
Definition: nsTable.h:164
uint_td m_buflen
Definition: nsTable.h:75
bool canDelete() const
Definition: nsTable.h:170
テーブルアクセスの基本クラス (abstruct nocopyable)
Definition: nsTable.h:44
short_td m_stat
Definition: nsTable.h:81
short_td stat() const
Definition: nsTable.h:163
uint_td recordCount(bool estimate=true, bool fromCurrent=false)
Definition: nsTable.h:181
virtual bool onDeleteCheck(bool in_key)
Definition: nsTable.h:121
uint_td getWriteImageLen()
Definition: nsTable.h:171
virtual keylen_td writeKeyData()
Definition: nsTable.h:123
keylen_td m_keybuflen
Definition: nsTable.h:79
virtual void onUpdateAfter(int beforeResult)
Definition: nsTable.h:120
uint_td buflen() const
Definition: nsTable.h:160
uchar_td m_curd
Definition: nsTable.h:94
ushort_td insert(bool ncc=false)
Definition: nsTable.h:175
void createIndex(bool specifyKeyNum=false)
Definition: nsTable.h:176
uint_td datalen() const
Definition: nsTable.h:162
void open(const _TCHAR *uri, char_td mode=0, const _TCHAR *ownerName=NULL)
Definition: nsTable.h:134
void close()
Definition: nsTable.h:172
ushort_td m_op
Definition: nsTable.h:78
void * m_pdata
Definition: nsTable.h:74
bool canInsert() const
Definition: nsTable.h:169
eUpdateType
更新オペレーションの対象とカレント移動のタイプ
Definition: nsTable.h:50
void update(eUpdateType type=changeCurrentCc)
Definition: nsTable.h:173
char_td keyNum() const
Definition: nsTable.h:165
virtual bool onUpdateCheck(eUpdateType type)
Definition: nsTable.h:114
void setAccessRights(unsigned char curd)
Definition: nsTable.h:157
virtual int onUpdateBefore()
Definition: nsTable.h:115
virtual uint_td doGetWriteImageLen()
Definition: nsTable.h:125
void setData(void *v)
Definition: nsTable.h:159

Transactd SDK 2015年09月08日(火) 19時13分35秒 doxygen