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

Go to the SVN repository for this file.

1 #ifndef TYPEREF__HPP
2 #define TYPEREF__HPP
3 
4 /* $Id: typeref.hpp 99788 2023-05-10 17:55:46Z 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 #include <serial/serialdef.hpp>
36 #include <corelib/ncbicntr.hpp>
37 
38 
39 /** @addtogroup GenClassSupport
40  *
41  * @{
42  */
43 
44 
46 
47 class CTypeRef;
48 
50 {
51 public:
52  CTypeInfoSource(void);
53  virtual ~CTypeInfoSource(void);
54 
55  virtual TTypeInfo GetTypeInfo(void) = 0;
56 
57 protected:
59  friend class CTypeRef;
60 
61 private:
64 };
65 
67 {
68 public:
69  CTypeRef(void);
70  CTypeRef(TTypeInfo typeInfo);
71 
72  typedef TTypeInfo (*TGetProc)(void);
73  CTypeRef(TGetProc getProc);
74 
75  typedef TTypeInfo (*TGet1Proc)(TTypeInfo arg);
76  CTypeRef(TGet1Proc getter, const CTypeRef& arg);
77 
78  typedef TTypeInfo (*TGet2Proc)(TTypeInfo arg1, TTypeInfo arg2);
79  CTypeRef(TGet2Proc getter, const CTypeRef& arg1, const CTypeRef& arg2);
80 
81  CTypeRef(TGet2Proc getter,
82  const CTypeRef& arg1,
83  TGet1Proc getter2, const CTypeRef& arg2);
84  CTypeRef(TGet2Proc getter,
85  TGet1Proc getter1, const CTypeRef& arg1,
86  const CTypeRef& arg2);
87  CTypeRef(TGet2Proc getter,
88  TGet1Proc getter1, const CTypeRef& arg1,
89  TGet1Proc getter2, const CTypeRef& arg2);
90 
92  CTypeRef(const CTypeRef& typeRef);
93  CTypeRef& operator=(const CTypeRef& typeRef);
94  ~CTypeRef(void);
95 
96  TTypeInfo Get(void) const;
97  DECLARE_OPERATOR_BOOL(m_Getter.load(memory_order_acquire) != sx_GetAbort);
98 
99  bool operator==(const CTypeRef& typeRef) const
100  {
101  return Get() == typeRef.Get();
102  }
103  bool operator!=(const CTypeRef& typeRef) const
104  {
105  return Get() != typeRef.Get();
106  }
107 
108 private:
109 
110  void Unref(void);
111  void Assign(const CTypeRef& typeRef);
112 
113  static TTypeInfo sx_GetAbort(const CTypeRef& typeRef);
114  static TTypeInfo sx_GetReturn(const CTypeRef& typeRef);
115  static TTypeInfo sx_GetProc(const CTypeRef& typeRef);
116  static TTypeInfo sx_GetResolve(const CTypeRef& typeRef);
117 
118  typedef TTypeInfo (*TGetter)(const CTypeRef& );
119  atomic<TGetter> m_Getter;
120  atomic<TTypeInfo> m_ReturnData;
121  union {
122  TGetProc m_GetProcData;
124  };
125 };
126 
128 {
129 public:
131  ~CGet1TypeInfoSource(void);
132 
133  virtual TTypeInfo GetTypeInfo(void) override;
134 
135 private:
138 };
139 
141 {
142 public:
144  const CTypeRef& arg1, const CTypeRef& arg2);
145  ~CGet2TypeInfoSource(void);
146 
147  virtual TTypeInfo GetTypeInfo(void) override;
148 
149 private:
153 };
154 
155 
156 /* @} */
157 
158 
159 #include <serial/impl/typeref.inl>
160 
162 
163 #endif /* TYPEREF__HPP */
CAtomicCounter_WithAutoInit –.
Definition: ncbicntr.hpp:120
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
CTypeRef m_Argument2
Definition: typeref.hpp:152
CTypeRef(const CTypeRef &typeRef)
atomic< TTypeInfo > m_ReturnData
Definition: typeref.hpp:120
CTypeRef(void)
CTypeRef(CTypeInfoSource *source)
CTypeInfoSource(const CTypeInfoSource &)
bool operator!=(const CTypeRef &typeRef) const
Definition: typeref.hpp:103
bool operator==(const CTypeRef &typeRef) const
Definition: typeref.hpp:99
CTypeRef m_Argument1
Definition: typeref.hpp:151
const CTypeInfo * TTypeInfo
Definition: serialdef.hpp:62
virtual TTypeInfo GetTypeInfo(void)=0
CTypeRef m_Argument
Definition: typeref.hpp:137
TTypeInfo Get(void) const
CTypeRef::TGet2Proc m_Getter
Definition: typeref.hpp:150
atomic< TGetter > m_Getter
Definition: typeref.hpp:119
CTypeInfoSource * m_ResolveData
Definition: typeref.hpp:123
~CTypeRef(void)
CTypeRef(TTypeInfo typeInfo)
CAtomicCounter_WithAutoInit m_RefCount
Definition: typeref.hpp:58
CTypeRef::TGet1Proc m_Getter
Definition: typeref.hpp:136
DECLARE_OPERATOR_BOOL(m_Getter.load(memory_order_acquire) !=sx_GetAbort)
TTypeInfo(* TGet1Proc)(TTypeInfo arg)
Definition: typeref.hpp:75
CTypeInfoSource & operator=(const CTypeInfoSource &)
TGetProc m_GetProcData
Definition: typeref.hpp:122
CTypeRef(TGetProc getProc)
TTypeInfo(* TGet2Proc)(TTypeInfo arg1, TTypeInfo arg2)
Definition: typeref.hpp:78
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
const TYPE & Get(const CNamedParameterList *param)
const CharType(& source)[N]
Definition: pointer.h:1149
Modified on Wed Apr 24 14:18:34 2024 by modify_doxy.py rev. 669887