NCBI C++ ToolKit
ptrinfo.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef PTRINFO__HPP
2 #define PTRINFO__HPP
3 
4 /* $Id: ptrinfo.hpp 79560 2017-09-20 17:04:38Z 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 #include <serial/typeinfo.hpp>
36 #include <serial/impl/typeref.hpp>
37 
38 
39 /** @addtogroup TypeInfoCPP
40  *
41  * @{
42  */
43 
44 
46 
47 // CTypeInfo for pointers
49 {
50  typedef CTypeInfo CParent;
51 public:
53  CPointerTypeInfo(const CTypeRef& typeRef);
55  CPointerTypeInfo(size_t size, const CTypeRef& typeRef);
56  CPointerTypeInfo(const string& name, TTypeInfo type);
57  CPointerTypeInfo(const string& name, size_t size, TTypeInfo type);
58 
59  static TTypeInfo GetTypeInfo(TTypeInfo base);
60 
62 
66 
67  TTypeInfo GetRealDataTypeInfo(TConstObjectPtr object) const;
68 
69  virtual EMayContainType GetMayContainType(TTypeInfo type) const override;
70 
71  virtual bool IsDefault(TConstObjectPtr object) const override;
72  virtual bool Equals(TConstObjectPtr object1, TConstObjectPtr object2,
73  ESerialRecursionMode how = eRecursive) const override;
74  virtual void SetDefault(TObjectPtr dst) const override;
75  virtual void Assign(TObjectPtr dst, TConstObjectPtr src,
76  ESerialRecursionMode how = eRecursive) const override;
77 
78  typedef TObjectPtr (*TGetDataFunction)(const CPointerTypeInfo* objectType,
79  TObjectPtr objectPtr);
80  typedef void (*TSetDataFunction)(const CPointerTypeInfo* objectType,
81  TObjectPtr objectPtr,
82  TObjectPtr dataPtr);
83 
84  void SetFunctions(TGetDataFunction getFunc, TSetDataFunction setFunc);
85 
89 
90 protected:
91  static TObjectPtr GetPointer(const CPointerTypeInfo* objectType,
92  TObjectPtr objectPtr);
93  static void SetPointer(const CPointerTypeInfo* objectType,
94  TObjectPtr objectPtr,
95  TObjectPtr dataPtr);
96 
97  static TObjectPtr CreatePointer(TTypeInfo objectType,
98  CObjectMemoryPool* memoryPool);
99 
100  static void ReadPointer(CObjectIStream& in,
101  TTypeInfo objectType,
102  TObjectPtr objectPtr);
103  static void WritePointer(CObjectOStream& out,
104  TTypeInfo objectType,
105  TConstObjectPtr objectPtr);
106  static void SkipPointer(CObjectIStream& in,
107  TTypeInfo objectType);
108  static void CopyPointer(CObjectStreamCopier& copier,
109  TTypeInfo objectType);
110 
111 protected:
113  TGetDataFunction m_GetData;
114  TSetDataFunction m_SetData;
115 
116 private:
117  void InitPointerTypeInfoFunctions(void);
118 };
119 
120 
121 /* @} */
122 
123 
124 #include <serial/impl/ptrinfo.inl>
125 
127 
128 #endif /* PTRINFO__HPP */
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
std::ofstream out("events_result.xml")
main entry point for tests
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
Definition: serialdef.hpp:191
void * TObjectPtr
Definition: serialdef.hpp:55
const void * TConstObjectPtr
Definition: serialdef.hpp:59
@ eRecursive
Recursively.
Definition: serialdef.hpp:192
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
virtual bool IsDefault(TConstObjectPtr object) const =0
Check, whether the object contains default value.
void SetObjectPointer(TObjectPtr object, TObjectPtr pointer) const
virtual CTypeInfo * SetTag(CAsnBinaryDefs::TLongTag tag, CAsnBinaryDefs::ETagClass tagclass=CAsnBinaryDefs::eUniversal, CAsnBinaryDefs::ETagType tagtype=CAsnBinaryDefs::eAutomatic)
Definition: typeinfo.cpp:172
CTypeRef m_DataTypeRef
Definition: ptrinfo.hpp:112
TTypeInfo GetPointedType(void) const
virtual EMayContainType GetMayContainType(TTypeInfo type) const
Definition: typeinfo.cpp:320
TObjectPtr GetObjectPointer(TObjectPtr object) const
TSetDataFunction m_SetData
Definition: ptrinfo.hpp:114
TGetDataFunction m_GetData
Definition: ptrinfo.hpp:113
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const =0
Set object to copy of another one.
virtual bool Equals(TConstObjectPtr object1, TConstObjectPtr object2, ESerialRecursionMode how=eRecursive) const =0
Check if both objects contain the same values.
TConstObjectPtr GetObjectPointer(TConstObjectPtr object) const
CTypeInfo CParent
Definition: ptrinfo.hpp:50
virtual void SetDefault(TObjectPtr dst) const =0
Set object to default value.
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1126
const char * tag
std::istream & in(std::istream &in_, double &x_)
Definition: type.c:6
Modified on Fri Sep 20 14:58:04 2024 by modify_doxy.py rev. 669887