NCBI C++ ToolKit
continfo.inl
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #if defined(CONTINFO__HPP) && !defined(CONTINFO__INL)
2 #define CONTINFO__INL
3 
4 /* $Id: continfo.inl 79683 2017-10-03 13:21:50Z gouriano $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * !!! PUT YOUR DESCRIPTION HERE !!!
33 */
34 
35 inline
37 {
38  return m_ElementType.Get();
39 }
40 
41 inline
43 {
44  return m_RandomOrder;
45 }
46 
47 inline
49  : m_ContainerType(0), m_ContainerPtr(0), m_IteratorData(0)
50 {
51 }
52 
53 inline
55 {
56  const CContainerTypeInfo* containerType = m_ContainerType;
57  if ( containerType )
58  containerType->ReleaseIterator(*this);
59 }
60 
61 inline
62 const CContainerTypeInfo*
64 {
65  return m_ContainerType;
66 }
67 
68 inline
71 {
72  return m_ContainerPtr;
73 }
74 
75 inline
77 {
78  const CContainerTypeInfo* containerType = m_ContainerType;
79  if ( containerType ) {
80  containerType->ReleaseIterator(*this);
81  m_ContainerType = 0;
82  m_ContainerPtr = 0;
83  m_IteratorData = 0;
84  }
85 }
86 
87 inline
89  : m_ContainerType(0), m_ContainerPtr(0), m_IteratorData(0)
90 {
91 }
92 
93 inline
95 {
96  const CContainerTypeInfo* containerType = m_ContainerType;
97  if ( containerType )
98  containerType->ReleaseIterator(*this);
99 }
100 
101 inline
102 const CContainerTypeInfo*
104 {
105  return m_ContainerType;
106 }
107 
108 inline
111 {
112  return m_ContainerPtr;
113 }
114 
115 inline
117 {
118  const CContainerTypeInfo* containerType = m_ContainerType;
119  if ( containerType ) {
120  containerType->ReleaseIterator(*this);
121  m_ContainerType = 0;
122  m_ContainerPtr = 0;
123  m_IteratorData = 0;
124  }
125 }
126 
127 inline
128 bool CContainerTypeInfo::InitIterator(CConstIterator& it,
129  TConstObjectPtr obj) const
130 {
131  it.Reset();
132  it.m_ContainerType = this;
133  it.m_ContainerPtr = obj;
134  return m_InitIteratorConst(it);
135 }
136 
137 inline
138 void CContainerTypeInfo::ReleaseIterator(CConstIterator& it) const
139 {
140  _ASSERT(it.m_ContainerType == this);
142 }
143 
144 inline
145 void CContainerTypeInfo::CopyIterator(CConstIterator& dst,
146  const CConstIterator& src) const
147 {
148  _ASSERT(src.m_ContainerType == this);
149  if ( dst.m_ContainerType != this ) {
150  InitIterator(dst, src.m_ContainerPtr);
151  m_CopyIteratorConst(dst, src);
152  }
153  else {
154  dst.m_ContainerPtr = src.m_ContainerPtr;
155  m_CopyIteratorConst(dst, src);
156  }
157 }
158 
159 inline
160 bool CContainerTypeInfo::NextElement(CConstIterator& it) const
161 {
162  _ASSERT(it.m_ContainerType == this);
163  return m_NextElementConst(it);
164 }
165 
166 inline
168 CContainerTypeInfo::GetElementPtr(const CConstIterator& it) const
169 {
170  _ASSERT(it.m_ContainerType == this);
171  return m_GetElementPtrConst(it);
172 }
173 
174 inline
175 bool CContainerTypeInfo::InitIterator(CIterator& it,
176  TObjectPtr obj) const
177 {
178  it.Reset();
179  it.m_ContainerType = this;
180  it.m_ContainerPtr = obj;
181  return m_InitIterator(it);
182 }
183 
184 inline
185 void CContainerTypeInfo::ReleaseIterator(CIterator& it) const
186 {
187  _ASSERT(it.m_ContainerType == this);
188  m_ReleaseIterator(it);
189 }
190 
191 inline
192 void CContainerTypeInfo::CopyIterator(CIterator& dst,
193  const CIterator& src) const
194 {
195  _ASSERT(src.m_ContainerType == this);
196  if ( dst.m_ContainerType != this ) {
197  InitIterator(dst, src.m_ContainerPtr);
198  m_CopyIterator(dst, src);
199  }
200  else {
201  dst.m_ContainerPtr = src.m_ContainerPtr;
202  m_CopyIterator(dst, src);
203  }
204 }
205 
206 inline
207 bool CContainerTypeInfo::NextElement(CIterator& it) const
208 {
209  _ASSERT(it.m_ContainerType == this);
210  return m_NextElement(it);
211 }
212 
213 inline
214 TObjectPtr CContainerTypeInfo::GetElementPtr(const CIterator& it) const
215 {
216  _ASSERT(it.m_ContainerType == this);
217  return m_GetElementPtr(it);
218 }
219 
220 inline
221 bool CContainerTypeInfo::EraseElement(CIterator& it) const
222 {
223  _ASSERT(it.m_ContainerType == this);
224  return m_EraseElement(it);
225 }
226 
227 inline
228 void CContainerTypeInfo::EraseAllElements(CIterator& it) const
229 {
230  _ASSERT(it.m_ContainerType == this);
231  m_EraseAllElements(it);
232 }
233 
234 inline
236  TConstObjectPtr elementPtr,
237  ESerialRecursionMode how) const
238 {
239  return m_AddElement(this, containerPtr, elementPtr, how);
240 }
241 
242 inline
244  CObjectIStream& in) const
245 {
246  return m_AddElementIn(this, containerPtr, in);
247 }
248 
249 inline
250 size_t CContainerTypeInfo::GetElementCount(TConstObjectPtr containerPtr) const
251 {
252  return m_GetElementCount(this, containerPtr);
253 }
254 
255 inline
257 {
258  if (m_ReserveElements) {
259  m_ReserveElements(this, cPtr, count);
260  }
261 }
262 
263 inline
265  : m_ElementType(0), m_ElementIndex(kInvalidMember)
266 {
267 }
268 
269 inline
271  const CContainerTypeInfo* containerType)
272  : m_ElementType(containerType->GetElementType()), m_ElementIndex(kInvalidMember)
273 {
274  if (containerType->InitIterator(m_Iterator, containerPtr)) {
275  ++m_ElementIndex;
276  }
277 }
278 
279 inline
281  : m_ElementType(src.m_ElementType),
282  m_ElementIndex(src.m_ElementIndex)
283 {
284  const CContainerTypeInfo* containerType =
286  if ( containerType )
287  containerType->CopyIterator(m_Iterator, src.m_Iterator);
288 }
289 
290 inline
292 {
295  const CContainerTypeInfo* containerType =
297  if ( containerType )
298  containerType->CopyIterator(m_Iterator, src.m_Iterator);
299  else
300  m_Iterator.Reset();
302  return *this;
303 }
304 
305 inline
307  const CContainerTypeInfo* containerType)
308 {
310  m_Iterator.Reset();
311  m_ElementType = containerType->GetElementType();
312  if ( containerType->InitIterator(m_Iterator, containerPtr)) {
313  ++m_ElementIndex;
314  }
315 }
316 
317 inline
319 {
320  return m_ElementType;
321 }
322 
323 inline
324 bool CContainerElementIterator::Valid(void) const
325 {
326  return m_ElementIndex != kInvalidMember;
327 }
328 
329 inline
331 {
332  return m_ElementIndex;
333 }
334 
335 inline
337 {
338  _ASSERT(Valid());
341 }
342 
343 inline
345 {
346  _ASSERT(Valid());
348  --m_ElementIndex;
349  }
350 }
351 
352 inline
354 {
355  if ( Valid() ) {
358  }
359 }
360 
361 inline
362 pair<TObjectPtr, TTypeInfo> CContainerElementIterator::Get(void) const
363 {
364  _ASSERT( Valid() );
366  GetElementType());
367 }
368 
369 inline
371  : m_ElementType(0), m_ElementIndex(kInvalidMember)
372 {
373 }
374 
375 inline
377  const CContainerTypeInfo* containerType)
378  : m_ElementType(containerType->GetElementType()), m_ElementIndex(kInvalidMember)
379 {
380  if ( containerType->InitIterator(m_Iterator, containerPtr)) {
381  ++m_ElementIndex;
382  }
383 }
384 
385 inline
387  : m_ElementType(src.m_ElementType),
388  m_ElementIndex(src.m_ElementIndex)
389 {
390  const CContainerTypeInfo* containerType =
392  if ( containerType )
393  containerType->CopyIterator(m_Iterator, src.m_Iterator);
394 }
395 
396 inline
399 {
402  const CContainerTypeInfo* containerType =
404  if ( containerType )
405  containerType->CopyIterator(m_Iterator, src.m_Iterator);
406  else
407  m_Iterator.Reset();
409  return *this;
410 }
411 
412 inline
414  const CContainerTypeInfo* containerType)
415 {
417  m_Iterator.Reset();
418  m_ElementType = containerType->GetElementType();
419  if ( containerType->InitIterator(m_Iterator, containerPtr)) {
420  ++m_ElementIndex;
421  }
422 }
423 
424 inline
426 {
427  return m_ElementType;
428 }
429 
430 inline
432 {
433  return m_ElementIndex != kInvalidMember;
434 }
435 
436 inline
438 {
439  return m_ElementIndex;
440 }
441 
442 inline
444 {
445  _ASSERT( Valid() );
448 }
449 
450 inline
452 {
454 }
455 
456 inline
457 pair<TConstObjectPtr, TTypeInfo> CConstContainerElementIterator::Get(void) const
458 {
459  _ASSERT( Valid() );
461  GetElementType());
462 }
463 
464 #endif /* def CONTINFO__HPP && ndef CONTINFO__INL */
CObjectIStream –.
Definition: objistr.hpp:93
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
Definition: serialdef.hpp:191
void * TObjectPtr
Definition: serialdef.hpp:55
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
const TMemberIndex kInvalidMember
Special value returned from FindMember.
Definition: serialdef.hpp:237
const void * TConstObjectPtr
Definition: serialdef.hpp:59
TTypeInfo Get(void) const
TReleaseIteratorConst m_ReleaseIteratorConst
Definition: continfo.hpp:193
TObjectPtr GetContainerPtr(void) const
void ReleaseIterator(CConstIterator &it) const
TNextElement m_NextElement
Definition: continfo.hpp:201
bool EraseElement(CIterator &it) const
TCopyIterator m_CopyIterator
Definition: continfo.hpp:200
TAddElement m_AddElement
Definition: continfo.hpp:206
bool RandomElementsOrder(void) const
TGetElementPtr m_GetElementPtr
Definition: continfo.hpp:202
NCBI_NS_NCBI::TObjectPtr TObjectPtr
Definition: continfo.hpp:105
void Init(TObjectPtr containerPtr, const CContainerTypeInfo *containerType)
TObjectPtr AddElement(TObjectPtr containerPtr, TConstObjectPtr elementPtr, ESerialRecursionMode how=eRecursive) const
const CContainerTypeInfo * m_ContainerType
Definition: continfo.hpp:111
const CContainerTypeInfo * GetContainerType(void) const
TCopyIteratorConst m_CopyIteratorConst
Definition: continfo.hpp:194
TObjectPtr GetContainerPtr(void) const
NCBI_NS_NCBI::TConstObjectPtr TObjectPtr
Definition: continfo.hpp:88
size_t GetElementCount(TConstObjectPtr containerPtr) const
bool Valid(void) const
void ReserveElements(TObjectPtr containerPtr, size_t new_count) const
CTypeRef m_ElementType
Definition: continfo.hpp:185
TAddElementIn m_AddElementIn
Definition: continfo.hpp:207
const CContainerTypeInfo * GetContainerType(void) const
TInitIteratorConst m_InitIteratorConst
Definition: continfo.hpp:192
TMemberIndex GetIndex(void) const
TEraseAllElements m_EraseAllElements
Definition: continfo.hpp:204
TMemberIndex m_ElementIndex
Definition: continfo.hpp:271
TReleaseIterator m_ReleaseIterator
Definition: continfo.hpp:199
TGetElementCount m_GetElementCount
Definition: continfo.hpp:209
TNextElementConst m_NextElementConst
Definition: continfo.hpp:195
TReserveElements m_ReserveElements
Definition: continfo.hpp:210
void CopyIterator(CConstIterator &dst, const CConstIterator &src) const
TConstObjectPtr GetElementPtr(const CConstIterator &it) const
TInitIterator m_InitIterator
Definition: continfo.hpp:198
const CContainerTypeInfo * m_ContainerType
Definition: continfo.hpp:94
pair< TConstObjectPtr, TTypeInfo > Get(void) const
bool InitIterator(CConstIterator &it, TConstObjectPtr containerPtr) const
pair< TObjectPtr, TTypeInfo > Get(void) const
CConstContainerElementIterator & operator=(const CConstContainerElementIterator &src)
bool NextElement(CConstIterator &it) const
void EraseAllElements(CIterator &it) const
TEraseElement m_EraseElement
Definition: continfo.hpp:203
TTypeInfo GetElementType(void) const
size_t GetElementCount(void) const
CContainerElementIterator & operator=(const CContainerElementIterator &src)
void Init(TConstObjectPtr containerPtr, const CContainerTypeInfo *containerType)
TTypeInfo GetElementType(void) const
TGetElementPtrConst m_GetElementPtrConst
Definition: continfo.hpp:196
TTypeInfo GetElementType(void) const
TMemberIndex GetIndex(void) const
std::istream & in(std::istream &in_, double &x_)
#define count
#define _ASSERT
Modified on Fri Sep 20 14:57:59 2024 by modify_doxy.py rev. 669887