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

Go to the SVN repository for this file.

1 #if defined(OBJECTINFO__HPP) && !defined(OBJECTINFO__INL)
2 #define OBJECTINFO__INL
3 
4 /* $Id: objectinfo.inl 52752 2012-01-24 19:53:15Z vasilche $
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 /////////////////////////////////////////////////////////////////////////////
36 // CObjectTypeInfo
37 /////////////////////////////////////////////////////////////////////////////
38 
39 inline
41  : m_TypeInfo(typeinfo)
42 {
43 }
44 
45 inline
47 {
48  return m_TypeInfo;
49 }
50 
51 inline
53 {
54  return const_cast<CTypeInfo*>(GetTypeInfo());
55 }
56 
57 inline
59 {
60  return GetTypeInfo()->GetTypeFamily();
61 }
62 
63 inline
65 {
66  if ( GetTypeInfo()->GetTypeFamily() != family )
67  WrongTypeFamily(family);
68 }
69 
70 inline
72 {
73  m_TypeInfo = 0;
74 }
75 
76 inline
78 {
79  m_TypeInfo = typeinfo;
80 }
81 
82 inline
84 {
85  return GetTypeInfo() == type.GetTypeInfo();
86 }
87 
88 inline
90 {
91  return GetTypeInfo() != type.GetTypeInfo();
92 }
93 
94 /////////////////////////////////////////////////////////////////////////////
95 // CConstObjectInfo
96 /////////////////////////////////////////////////////////////////////////////
97 
98 inline
100  : m_ObjectPtr(0)
101 {
102 }
103 
104 inline
106  TTypeInfo typeInfo)
107  : CObjectTypeInfo(objectPtr? typeInfo: 0), m_ObjectPtr(objectPtr),
108  m_Ref(typeInfo->GetCObjectPtr(objectPtr))
109 {
110 }
111 
112 inline
114  TTypeInfo typeInfo,
115  ENonCObject)
116  : CObjectTypeInfo(objectPtr? typeInfo: 0), m_ObjectPtr(objectPtr)
117 {
118  _ASSERT(!typeInfo->IsCObject() ||
119  static_cast<const CObject*>(objectPtr)->Referenced() ||
120  !static_cast<const CObject*>(objectPtr)->CanBeDeleted());
121 }
122 
123 inline
124 CConstObjectInfo::CConstObjectInfo(pair<TConstObjectPtr, TTypeInfo> object)
125  : CObjectTypeInfo(object.first? object.second: 0),
126  m_ObjectPtr(object.first),
127  m_Ref(object.second->GetCObjectPtr(object.first))
128 {
129 }
130 
131 inline
132 CConstObjectInfo::CConstObjectInfo(pair<TObjectPtr, TTypeInfo> object)
133  : CObjectTypeInfo(object.first? object.second: 0),
134  m_ObjectPtr(object.first),
135  m_Ref(object.second->GetCObjectPtr(object.first))
136 {
137 }
138 
139 inline
141 {
142  m_ObjectPtr = 0;
143  m_Ref.Reset();
144 }
145 
146 inline
148 {
149  return m_ObjectPtr;
150 }
151 
152 inline
153 pair<TConstObjectPtr, TTypeInfo> CConstObjectInfo::GetPair(void) const
154 {
155  return make_pair(GetObjectPtr(), GetTypeInfo());
156 }
157 
158 inline
159 void CConstObjectInfo::Reset(void)
160 {
161  ResetObjectPtr();
162  ResetTypeInfo();
163 }
164 
165 inline
166 void CConstObjectInfo::Set(TConstObjectPtr objectPtr, TTypeInfo typeInfo)
167 {
168  m_ObjectPtr = objectPtr;
169  SetTypeInfo(typeInfo);
170  m_Ref.Reset(typeInfo->GetCObjectPtr(objectPtr));
171 }
172 
173 inline
175 CConstObjectInfo::operator=(pair<TConstObjectPtr, TTypeInfo> object)
176 {
177  Set(object.first, object.second);
178  return *this;
179 }
180 
181 inline
183 CConstObjectInfo::operator=(pair<TObjectPtr, TTypeInfo> object)
184 {
185  Set(object.first, object.second);
186  return *this;
187 }
188 
189 /////////////////////////////////////////////////////////////////////////////
190 // CObjectInfo
191 /////////////////////////////////////////////////////////////////////////////
192 
193 inline
195 {
196 }
197 
198 inline
200  : CParent(typeInfo->Create(), typeInfo)
201 {
202 }
203 
204 inline
206  : CParent(typeInfo.GetTypeInfo()->Create(), typeInfo.GetTypeInfo())
207 {
208 }
209 
210 inline
211 CObjectInfo::CObjectInfo(TObjectPtr objectPtr, TTypeInfo typeInfo)
212  : CParent(objectPtr, typeInfo)
213 {
214 }
215 
216 inline
218  TTypeInfo typeInfo,
219  ENonCObject nonCObject)
220  : CParent(objectPtr, typeInfo, nonCObject)
221 {
222 }
223 
224 inline
225 CObjectInfo::CObjectInfo(pair<TObjectPtr, TTypeInfo> object)
226  : CParent(object)
227 {
228 }
229 
230 inline
232 {
233  return const_cast<TObjectPtr>(CParent::GetObjectPtr());
234 }
235 
236 inline
237 pair<TObjectPtr, TTypeInfo> CObjectInfo::GetPair(void) const
238 {
239  return make_pair(GetObjectPtr(), GetTypeInfo());
240 }
241 
242 inline
244 CObjectInfo::operator=(pair<TObjectPtr, TTypeInfo> object)
245 {
246  Set(object.first, object.second);
247  return *this;
248 }
249 
250 #endif /* def OBJECTINFO__HPP && ndef OBJECTINFO__INL */
CConstObjectInfo –.
Definition: objectinfo.hpp:421
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
CObject –.
Definition: ncbiobj.hpp:180
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
void * TObjectPtr
Definition: serialdef.hpp:55
const void * TConstObjectPtr
Definition: serialdef.hpp:59
ETypeFamily
Type family.
Definition: serialdef.hpp:138
pair< TConstObjectPtr, TTypeInfo > GetPair(void) const
CTypeInfo * GetNCTypeInfo(void) const
pair< TObjectPtr, TTypeInfo > GetPair(void) const
bool operator!=(const CObjectTypeInfo &type) const
CConstObjectInfo(void)
Create empty CObjectInfo.
void CheckTypeFamily(ETypeFamily family) const
TTypeInfo m_TypeInfo
Definition: objectinfo.hpp:402
void Set(TConstObjectPtr objectPtr, TTypeInfo typeInfo)
CObjectTypeInfo(TTypeInfo typeinfo=0)
TConstObjectPtr m_ObjectPtr
Definition: objectinfo.hpp:585
bool operator==(const CObjectTypeInfo &type) const
TObjectPtr GetObjectPtr(void) const
Get pointer to object.
void ResetObjectPtr(void)
TTypeInfo GetTypeInfo(void) const
CObjectInfo(void)
Create empty CObjectInfo.
void Reset(void)
Reset CObjectInfo to empty state.
ETypeFamily GetTypeFamily(void) const
Get data type family.
CObjectInfo & operator=(pair< TObjectPtr, TTypeInfo > object)
Set CObjectInfo to point to another object.
void SetTypeInfo(TTypeInfo typeinfo)
void ResetTypeInfo(void)
CConstObjectInfo & operator=(pair< TConstObjectPtr, TTypeInfo > object)
Set CObjectInfo.
void WrongTypeFamily(ETypeFamily needFamily) const
Definition: objectinfo.cpp:44
TConstObjectPtr GetObjectPtr(void) const
Get pointer to object.
CConstRef< CObject > m_Ref
Definition: objectinfo.hpp:586
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
bool Referenced(void) const THROWS_NONE
Check if object is referenced.
Definition: ncbiobj.hpp:468
bool CanBeDeleted(void) const THROWS_NONE
Check if object can be deleted.
Definition: ncbiobj.hpp:454
ETypeFamily GetTypeFamily(void) const
bool IsCObject(void) const
Check is this TypeInfo object is kind of CClassTypeInfoBase.
virtual const CObject * GetCObjectPtr(TConstObjectPtr objectPtr) const
Definition: typeinfo.cpp:325
Definition: type.c:6
#define _ASSERT
Modified on Mon May 20 04:59:58 2024 by modify_doxy.py rev. 669887