全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 ページ
memRecord.h
1 #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_MEMRECORD_H
2 #define BZS_DB_PROTOCOL_TDAP_CLIENT_MEMRECORD_H
3 /*=================================================================
4  Copyright (C) 2014 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 "fields.h"
22 
23 namespace bzs
24 {
25 namespace db
26 {
27 namespace protocol
28 {
29 namespace tdap
30 {
31 namespace client
32 {
33 
34 /** @cond INTERNAL */
35 
36 class autoMemory : public refarymem
37 {
38  void releaseMemory();
39 
40  autoMemory();
41  autoMemory(const autoMemory& p);
42  ~autoMemory();
43 public:
44  void setParams(unsigned char* p, size_t s, short* endIndex, bool own);
45 
46  autoMemory& operator=(const bzs::db::protocol::tdap::client::autoMemory& p);
47  void assignEndFieldIndex(short* p);
48  unsigned char* ptr;
49  short* endFieldIndex;
50  unsigned int size;
51  bool owner ;
52  static autoMemory* create(int n);
53  static autoMemory* create();
54 };
55 
56 /** @endcond */
57 
58 #pragma warning(disable : 4251)
59 #pragma warning(disable : 4275)
60 #define ROW_MEM_BLOCK_RESERVE 4
61 
62 #ifndef JOINLIMIT_PER_RECORD
63 #define JOINLIMIT_PER_RECORD 14
64 #endif
65 #if (JOINLIMIT_PER_RECORD < 1)
66 #define JOIN_UNLIMIT
67 #endif
68 
69 class DLLLIB memoryRecord : public fieldsBase
70 {
71  friend class multiRecordAlocatorImple;
72  friend class recordsetImple;
73  friend class recordsetQuery;
74 
75 #ifdef JOIN_UNLIMIT
76  std::vector<autoMemory*> m_memblock;
77 #else
78  autoMemory* m_memblock[JOINLIMIT_PER_RECORD];
79  int m_memblockSize;
80 #endif
81  mutable int m_blockIndexCache;
82  static memoryRecord* create(fielddefs& fdinfo, int n);
83  static memoryRecord* create(const memoryRecord& m, int n);
84 
85 
86  /** @cond INTERNAL */
87 
88  /* return memory block first address which not field ptr address */
89  inline unsigned char* ptr(int index) const
90  {
91  return nullPtr(index) + (*m_fns)[index].nullbytes();
92  }
93 
94  inline unsigned char* nullPtr(int index) const
95  {
96  return m_memblock[memoryBlockIndex(index)]->ptr;
97  }
98 
99  inline int memoryBlockIndex(int index) const
100  {
101  for (int i = 0; i < memBlockSize(); ++i)
102  if (*(m_memblock[i]->endFieldIndex) > index)
103  return m_blockIndexCache = i;
104  assert(0);
105  return 0;
106  }
107 
108  int memoryBlockIndexCache() const { return m_blockIndexCache;}
109 
110  inline const autoMemory& memBlockByField(int index) const
111  {
112  return *m_memblock[memoryBlockIndex(index)];
113  }
114 
115  inline const autoMemory& memBlock(int index) const
116  {
117  return *m_memblock[index];
118  }
119 #ifdef JOIN_UNLIMIT
120  inline int memBlockSize() const { return (int)m_memblock.size(); }
121 #else
122  inline int memBlockSize() const { return m_memblockSize; }
123 #endif
124 
125  void removeLastMemBlock()
126  {
127  if (memBlockSize())
128  {
129  m_memblock[memBlockSize()-1]->release();
130 #ifdef JOIN_UNLIMIT
131  m_memblock.pop_back();
132 #else
133  --m_memblockSize;
134 #endif
135  }
136  }
137 
138  inline void setInvalidMemblockLast()
139  {
140  int num = memBlockSize() -1;
141  m_InvalidFlags |= ((2L << num) | 1L);
142  }
143 
144  void releaseMemory();
145 
146 protected:
147  inline memoryRecord();
148  inline memoryRecord(fielddefs& fdinfo);
149  memoryRecord(const memoryRecord& r);
150  ~memoryRecord();
151  void copyToBuffer(table* tb, bool updateOnly = false) const;
152  inline void copyFromBuffer(const table* tb)
153  {
154  memcpy(nullPtr(0), tb->data(), m_fns->totalFieldLen());
155  }
156  void setRecordData(autoMemory* am, unsigned char* ptr, size_t size,
157  short* endFieldIndex, bool owner = false);
158 
159  /** @endcond */
160 public:
161  void clear(); // orverride
162  memoryRecord& operator=(const memoryRecord& r); // For SWIG
163  static memoryRecord* create(fielddefs& fdinfo); // For SWIG
164 };
165 
166 #pragma warning(default : 4275)
167 #pragma warning(default : 4251)
168 
169 /* non copyable*/
170 class DLLLIB writableRecord : public memoryRecord
171 {
172  friend class activeTableImple;
173 
174  fielddefs* m_fddefs;
175  table* m_tb;
176  short m_endIndex;
177 
178  static writableRecord* create(table* tb, const aliasMap_type* alias);
179  writableRecord(table* tb, const aliasMap_type* alias);
181  writableRecord& operator=(const writableRecord&);
182 
183  fielddefs* fddefs();
184  void releaseMemory();
185  ~writableRecord();
186 
187 public:
188 
189  bool read(bool KeysetAlrady = false);
190  bool read(bookmark_td& bm);
191  void insert();
192  void del(bool KeysetAlrady = false, bool noSeek = false);
193  void update(bool KeysetAlrady = false, bool noSeek = false);
194  void save();
195  void clear();// orverride
196 
197 };
198 
199 } // namespace client
200 } // namespace tdap
201 } // namespace protocol
202 } // namespace db
203 } // namespace bzs
204 
205 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_MEMRECORD_H
BOOKMARK構造体
Definition: tdapcapi.h:37
テーブルアクセスクラス (nocopyable)
Definition: table.h:91
fielddef のコレクションクラス
Definition: field.h:74
recordset フィルタリングクエリー
Definition: groupQuery.h:107
フィールドコレクションのベースクラス
Definition: fields.h:123
書き込み可能な行のクラスです。
Definition: memRecord.h:170
rowの実装クラス
Definition: memRecord.h:69

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