WIL説明書(C++)  3.0.0
FvMultiData.h
[詳解]
1 // $Revision: 1.1 $
2 /*
3  @file FvMultiData.h
4  @brief CFvMultiData template class
5  @author FAST Corporation
6 */
7 
8 #ifndef _FVMULTIDATA_H_INCLUDED_
9 #define _FVMULTIDATA_H_INCLUDED_
10 
11 #include "FvMacros.h"
12 #include "FvDefs.h"
13 #include "FvDebug.h"
14 #include "FvErrors.h"
15 #include "FvObject.h"
16 #include "FvException.h"
17 
18 #include "FvAllocator.h"
19 #include "FvIterator.h"
20 
21 #pragma pack(push,_FVCL_PACKING)
22 
23 namespace FVCL
24 {
25 
26 // /////////////////////////////////////////////////////////////////
27 // DEFINE
28 //
29 
30 // /////////////////////////////////////////////////////////////////
31 // TYPEDEF
32 //
33 
34 // /////////////////////////////////////////////////////////////////
35 // CLASS
36 template<class TYPE> class CFvMultiData : public CFvObject
37 {
38 public:
39  typedef TYPE* pointer;
40  typedef const TYPE* const_pointer;
41  typedef TYPE& reference;
42  typedef const TYPE& const_reference;
43  typedef UINT size_type;
45  typedef const iterator const_iterator;
46 
47 public:
48  // ===================================================================
50  {
51  this->m_alloc = NULL;
52  }
53 
54  // ===================================================================
56  {
58  }
59 
60  // ===================================================================
61  virtual ~CFvMultiData()
62  {
63  }
64 
65  // ===================================================================
66  virtual INT GetDataID() const = 0;
67 
68  // ===================================================================
69  virtual bool GetPointer( INT id, void** val ) const = 0;
70 
71  //
72  // METHOD
73  //
74 
75  // ===================================================================
76  virtual reference at( size_type _Pos )
77  {
78  return this->m_alloc->GetItem(_Pos);
79  }
80 
81  // ===================================================================
82  virtual const_reference at( size_type _Pos ) const
83  {
84  return this->m_alloc->GetItem(_Pos);
85  }
86 
87  // ===================================================================
88  virtual reference front()
89  {
90  return this->m_alloc->GetItem( 0 );
91  }
92 
93  // ===================================================================
94  virtual const_reference front() const
95  {
96  return this->m_alloc->GetItem( 0 );
97  }
98 
99  // ===================================================================
100  virtual reference back()
101  {
102  return this->m_alloc->GetItem( this->m_alloc->GetBack() );
103  }
104 
105  // ===================================================================
106  virtual const_reference back() const
107  {
108  return this->m_alloc->GetItem( this->m_alloc->GetBack() );
109  }
110 
111  // ===================================================================
112  virtual iterator begin()
113  {
114  return iterator( 0, this->m_alloc );
115  }
116 
117  // ===================================================================
118  virtual const_iterator begin() const
119  {
120  return iterator( 0, this->m_alloc );
121  }
122 
123  // ===================================================================
124  virtual iterator end()
125  {
126  return iterator( this->m_alloc->GetCount(), this->m_alloc );
127  }
128 
129  // ===================================================================
130  virtual const_iterator end() const
131  {
132  return iterator( this->m_alloc->GetCount(), this->m_alloc );
133  }
134 
135  // ===================================================================
136  virtual size_type capacity() const
137  {
138  return this->m_alloc->GetCapacity();
139  }
140 
141  // ===================================================================
142  virtual void clear()
143  {
144  this->m_alloc->Clear();
145  }
146 
147  // ===================================================================
148  virtual bool empty() const
149  {
150  return (this->m_alloc->GetCount()==0 ? true : false);
151  }
152 
153  // ===================================================================
154  virtual iterator erase( iterator _First, iterator _Last )
155  {
156  size_type uiPos = _First.GetIndex();
157  if( this->m_alloc->Erase( _First.GetIndex(), _Last.GetIndex() ) )
158  return iterator( uiPos, this->m_alloc );
159  else
160  return end();
161  }
162 
163  // ===================================================================
164  virtual iterator erase( iterator _Where )
165  {
166  return erase( _Where, _Where );
167  }
168 
169  // ===================================================================
171  {
172  return *this->m_alloc;
173  }
174 
175  // ===================================================================
176  virtual const CFvAllocator<TYPE>& get_allocator() const
177  {
178  return *this->m_alloc;
179  }
180 
181  // ===================================================================
182  virtual void insert( iterator _Where, size_type _Count, const_reference _Val )
183  {
184  this->m_alloc->Insert( _Where.GetIndex(), _Count, _Val );
185  }
186 
187  // ===================================================================
188  virtual iterator insert( iterator _Where, const_reference _Val )
189  {
190  size_type uiPos = _Where.GetIndex();
191  this->m_alloc->Insert( uiPos, 1, _Val );
192  return iterator( uiPos, this->m_alloc );
193  }
194 
195  // ===================================================================
196  virtual bool push_back( const_reference _Val )
197  {
198  return this->m_alloc->PushBack( _Val );
199  }
200 
201  // ===================================================================
202  virtual bool pop_back()
203  {
204  return this->m_alloc->PopBack();
205  }
206 
207  // ===================================================================
208  virtual bool resize( size_type _Newsize, const_reference _Val )
209  {
210  return this->m_alloc->Resize( _Newsize, &_Val );
211  }
212 
213  // ===================================================================
214  virtual bool resize( size_type _Newsize )
215  {
216  return this->m_alloc->Resize( _Newsize, NULL );
217  }
218 
219  // ===================================================================
220  virtual void reserve( size_type _Count )
221  {
222  this->m_alloc->Reserve( _Count );
223  }
224 
225  // ===================================================================
226  virtual size_type size() const
227  {
228  return this->m_alloc->GetCount();
229  }
230 
231 public:
232  // ===================================================================
233  virtual bool ChangeOrder( iterator _Where, INT _Order )
234  {
235  CFvAllocator<TYPE>* alloc = _Where.GetAllocator();
236  if( alloc == NULL ) return false;
237  if( alloc != this->m_alloc ) return false;
238 
239  return this->m_alloc->ChangeOrder( _Where.GetIndex(), _Order );
240  }
241 
242  // ===================================================================
243  virtual bool SwapItem( iterator _Where1, iterator _Where2 )
244  {
245  CFvAllocator<TYPE>* alloc1 = _Where1.GetAllocator();
246  CFvAllocator<TYPE>* alloc2 = _Where2.GetAllocator();
247  if( alloc1 == NULL ) return false;
248  if( alloc2 == NULL ) return false;
249  if( alloc1 != this->m_alloc ) return false;
250  if( alloc2 != this->m_alloc ) return false;
251 
252  return this->m_alloc->SwapItem( _Where1.GetIndex(), _Where2.GetIndex() );
253  }
254 
255 public:
256  // ===================================================================
257  virtual reference operator [] ( size_type uiIndex )
258  {
259  return this->m_alloc->GetItem( uiIndex );
260  }
261 
262  // ===================================================================
263  virtual const_reference operator [] ( size_type uiIndex ) const
264  {
265  return this->m_alloc->GetItem( uiIndex );
266  }
267 
268  // ===================================================================
270  {
272  if( this->m_alloc->GetCount() != ope.m_alloc->GetCount() )
273  if( !this->m_alloc->Resize( ope.m_alloc->GetCount() ) )
275 
276  if( this->m_alloc->GetCapacity() < ope.m_alloc->GetCapacity() )
277  {
278  size_type uiCapacity = 0;
279  uiCapacity = ope.m_alloc->GetCapacity() - this->m_alloc->GetCapacity();
280  if( !this->m_alloc->Reserve( uiCapacity ) )
282  }
283 
284  for( size_type iCnt=0 ; iCnt<this->m_alloc->GetCount() ; iCnt++ )
285  this->m_alloc->SetItem( iCnt, ope.m_alloc->GetItem( iCnt ) );
286  return *this;
287  }
288 
289 protected:
290  // OBJECT
292 };
293 
294 } // FVCL
295 
296 #pragma pack(pop)
297 
298 #endif // _FVMULTIDATA_H_INCLUDED_
virtual bool push_back(const_reference _Val)
配列への要素の追加
Definition: FvMultiData.h:196
virtual INT GetDataID() const =0
データIDの取得
virtual CFvObject & operator=(const CFvObject &src)
代入オペレータ
virtual void clear()
配列の開放
Definition: FvMultiData.h:142
配列走査テンプレートクラス
virtual void reserve(size_type _Count)
配列容量の追加
Definition: FvMultiData.h:220
配列確保テンプレートクラスの基本クラス
Definition: FvAllocator.h:34
FVCLのネームスペース
Definition: EVCbasicDeclare.txt:9
領域確保不可例外クラス
Definition: FveBadAllocException.h:18
virtual void insert(iterator _Where, size_type _Count, const_reference _Val)
配列への要素の挿入
Definition: FvMultiData.h:182
FVCLの基底クラス
Definition: FvObject.h:23
CFvMultiData(const CFvMultiData< TYPE > &object)
コピーコンストラクタ
Definition: FvMultiData.h:55
TYPE & reference
参照型
Definition: FvMultiData.h:41
const INT FAILED_TO_ALLOCATE
メモリの確保に失敗しました。
Definition: FvErrors.h:15
int INT
整数型(32ビット)
Definition: FvDefs.h:36
配列走査テンプレートクラス
Definition: FvIterator.h:38
virtual size_type capacity() const
配列の許容量の取得
Definition: FvMultiData.h:136
マクロ定義
virtual bool SwapItem(iterator _Where1, iterator _Where2)
配列要素の位置入れ替え
Definition: FvMultiData.h:243
virtual iterator end()
配列末尾の次の位置の取得
Definition: FvMultiData.h:124
virtual const_iterator begin() const
配列の先頭位置の取得
Definition: FvMultiData.h:118
virtual bool resize(size_type _Newsize, const_reference _Val)
配列の再確保
Definition: FvMultiData.h:208
virtual bool empty() const
要素の存在の確認
Definition: FvMultiData.h:148
virtual const_reference back() const
配列末尾の要素の取得
Definition: FvMultiData.h:106
virtual bool ChangeOrder(iterator _Where, INT _Order)
配列要素の順序入れ替え
Definition: FvMultiData.h:233
CFvIterator< TYPE > iterator
イテレータ型
Definition: FvMultiData.h:44
virtual CFvAllocator< TYPE > & get_allocator()
アロケータクラスの取得
Definition: FvMultiData.h:170
const TYPE & const_reference
参照型(const付き)
Definition: FvMultiData.h:42
CFvAllocator< TYPE > * m_alloc
アロケータクラスのオブジェクトへのポインタ
Definition: FvMultiData.h:291
エラーコード定義
const iterator const_iterator
イテレータ型(const付き)
Definition: FvMultiData.h:45
const TYPE * const_pointer
ポインタ型(const付き)
Definition: FvMultiData.h:40
virtual iterator begin()
配列の先頭位置の取得
Definition: FvMultiData.h:112
virtual iterator erase(iterator _Where)
要素の削除
Definition: FvMultiData.h:164
CFvAllocator< TYPE > * GetAllocator() const
配列確保クラスの取得
Definition: FvIterator.h:79
virtual ~CFvMultiData()
デストラクタ
Definition: FvMultiData.h:61
virtual iterator erase(iterator _First, iterator _Last)
要素の削除
Definition: FvMultiData.h:154
unsigned int UINT
整数型(32ビット)[符号なし]
Definition: FvDefs.h:37
size_type GetIndex() const
配列指標の取得
Definition: FvIterator.h:85
配列テンプレートクラスの基本クラス
Definition: FvMultiData.h:36
virtual bool resize(size_type _Newsize)
配列の再確保
Definition: FvMultiData.h:214
virtual reference at(size_type _Pos)
配列の任意の位置の要素取得
Definition: FvMultiData.h:76
virtual reference operator[](size_type uiIndex)
添字オペレータ
Definition: FvMultiData.h:257
virtual const_reference at(size_type _Pos) const
配列の任意の位置の要素取得
Definition: FvMultiData.h:82
CFvObject クラスのインターフェース
UINT size_type
サイズ型
Definition: FvMultiData.h:43
virtual bool pop_back()
配列末尾の要素の削除
Definition: FvMultiData.h:202
CFvMultiData()
コンストラクタ
Definition: FvMultiData.h:49
virtual CFvMultiData< TYPE > & operator=(const CFvMultiData< TYPE > &ope)
代入オペレータ(=)
Definition: FvMultiData.h:269
TYPE * pointer
ポインタ型
Definition: FvMultiData.h:39
virtual reference back()
配列末尾の要素の取得
Definition: FvMultiData.h:100
配列確保テンプレートクラスの基本クラス
virtual iterator insert(iterator _Where, const_reference _Val)
配列への要素の挿入
Definition: FvMultiData.h:188
virtual reference front()
配列の先頭の要素取得
Definition: FvMultiData.h:88
変数型と定数の定義
デバッグ用関数のインターフェース
例外発行関数のインターフェース
virtual const_reference front() const
配列の先頭の要素取得
Definition: FvMultiData.h:94
virtual bool GetPointer(INT id, void **val) const =0
インスタンスのthisポインタの取得
virtual size_type size() const
配列の要素数の取得
Definition: FvMultiData.h:226
virtual const_iterator end() const
配列末尾の次の位置の取得
Definition: FvMultiData.h:130
virtual const CFvAllocator< TYPE > & get_allocator() const
アロケータクラスの取得
Definition: FvMultiData.h:176

Documentation copyright © 2007 FAST Corporation. [B-001864]
Generated on 2023年11月02日(木) 10時12分53秒 for WIL説明書(C++) by doxygen 1.8.11