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

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