NCBI C++ ToolKit
classinfob.hpp

Search Toolkit Book for infob_8hpp_source

Go to the documentation of this file.
1 #ifndef CLASSINFOB__HPP
2 #define CLASSINFOB__HPP
3 
4 /* $Id: classinfob.hpp 80811 2018-01-11 14:18:53Z 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 <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
38 #include <serial/impl/typeref.hpp>
39 #include <serial/typeinfo.hpp>
41 #include <map>
42 #include <set>
43 #include <memory>
44 
45 
46 /** @addtogroup TypeInfoCPP
47  *
48  * @{
49  */
50 
51 
53 
55  typedef CTypeInfo CParent;
56 public:
58 
59 protected:
60  CClassTypeInfoBase(ETypeFamily typeFamily, size_t size, const char* name,
61  const void* nonCObject, TTypeCreate createFunc,
62  const type_info& ti);
63  CClassTypeInfoBase(ETypeFamily typeFamily, size_t size, const char* name,
64  const CObject* cObject, TTypeCreate createFunc,
65  const type_info& ti);
66  CClassTypeInfoBase(ETypeFamily typeFamily, size_t size, const string& name,
67  const void* nonCObject, TTypeCreate createFunc,
68  const type_info& ti);
69  CClassTypeInfoBase(ETypeFamily typeFamily, size_t size, const string& name,
70  const CObject* cObject, TTypeCreate createFunc,
71  const type_info& ti);
72 
73 public:
74  virtual ~CClassTypeInfoBase(void);
75 
76  CMemberInfo* AddMember(const char* memberId,
77  const void* memberPtr, const CTypeRef& memberType);
78  CMemberInfo* AddMember(const CMemberId& memberId,
79  const void* memberPtr, const CTypeRef& memberType);
80 
81  const CItemsInfo& GetItems(void) const;
82  const CItemInfo* GetItemInfo(const string& name) const;
83  void AssignItemsTags(void);
84  void DataSpec(EDataSpec spec);
85 
86  const type_info& GetId(void) const;
87 
88  // PreRead/PostRead/PreWrite/PostWrite
89  typedef void (*TPreReadFunction)(TTypeInfo info, TObjectPtr object);
90  typedef void (*TPostReadFunction)(TTypeInfo info, TObjectPtr object);
91  typedef void (*TPreWriteFunction)(TTypeInfo info, TConstObjectPtr object);
93 
94  void SetPreReadFunction(TPreReadFunction func);
95  void SetPostReadFunction(TPostReadFunction func);
96  void SetPreWriteFunction(TPreWriteFunction func);
97  void SetPostWriteFunction(TPostWriteFunction func);
98 
99 public:
100  // finds type info (throws runtime_error if absent)
101  static TTypeInfo GetClassInfoByName(const string& name);
102  static TTypeInfo GetClassInfoById(const type_info& id);
103 
106  static void RegisterModule(const string& module);
107  static void GetRegisteredModuleNames(TRegModules& modules);
108  static void GetRegisteredClassNames(const string& module, TRegClasses& names);
109 
110  virtual const CObject* GetCObjectPtr(TConstObjectPtr objectPtr) const override;
111 
112  // iterators interface
113  virtual EMayContainType GetMayContainType(TTypeInfo type) const override;
114 
115  // helping member iterator class (internal use)
117  {
119  public:
122  };
123 
124 protected:
125  friend class CIterator;
127 
128  virtual EMayContainType CalcMayContainType(TTypeInfo typeInfo) const;
129 
130 private:
131  const type_info* m_Id;
132 
134 
135  mutable unique_ptr<TContainedTypes> m_ContainedTypes;
136 
137  // class mapping
139  typedef map<const type_info*, const CClassTypeInfoBase*,
142 
147 
148  void InitClassTypeInfoBase(const type_info& id);
149  void Register(void);
150  void Deregister(void);
151  static TClasses& Classes(void);
152  static TClassesById& ClassesById(void);
153  static TClassesByName& ClassesByName(void);
154 };
155 
156 
157 /* @} */
158 
159 
161 
163 
164 #endif /* CLASSINFOB__HPP */
CObject –.
Definition: ncbiobj.hpp:180
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Definition: map.hpp:338
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const struct name_t names[]
void(* TPreReadFunction)(const CTypeInfo *info, void *object)
Definition: serialbase.hpp:81
CMemberInfo * AddMember(CClassTypeInfoBase *info, const char *name, const void *member, TTypeInfo t)
Definition: serial.cpp:135
void * TObjectPtr
Definition: serialdef.hpp:55
void(* TPreWriteFunction)(const CTypeInfo *info, const void *object)
Definition: serialbase.hpp:83
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
const void * TConstObjectPtr
Definition: serialdef.hpp:59
void(* TPostWriteFunction)(const CTypeInfo *info, const void *object)
Definition: serialbase.hpp:84
ETypeFamily
Type family.
Definition: serialdef.hpp:138
EDataSpec
Definition: serialdef.hpp:204
void(* TPostReadFunction)(const CTypeInfo *info, void *object)
Definition: serialbase.hpp:82
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const type_info * m_Id
Definition: classinfob.hpp:131
const type_info & GetId(void) const
static TClassesByName * sm_ClassesByName
Definition: classinfob.hpp:145
void DataSpec(EDataSpec spec)
Definition: typeinfo.cpp:182
static set< string > * sm_Modules
Definition: classinfob.hpp:146
multimap< string, const CClassTypeInfoBase * > TClassesByName
Definition: classinfob.hpp:141
const CItemsInfo & GetItems(void) const
CItemsInfo::CIterator CParent
Definition: classinfob.hpp:118
virtual EMayContainType GetMayContainType(TTypeInfo type) const
Definition: typeinfo.cpp:320
static TClasses * sm_Classes
Definition: classinfob.hpp:143
map< TTypeInfo, EMayContainType > TContainedTypes
Definition: classinfob.hpp:57
CItemsInfo & GetItems(void)
const CItemInfo * GetItemInfo(const string &name) const
static TClassesById * sm_ClassesById
Definition: classinfob.hpp:144
set< string > TRegClasses
Definition: classinfob.hpp:105
CIterator(const CClassTypeInfoBase *type)
set< string > TRegModules
Definition: classinfob.hpp:104
unique_ptr< TContainedTypes > m_ContainedTypes
Definition: classinfob.hpp:135
CIterator(const CClassTypeInfoBase *type, TMemberIndex index)
map< const type_info *, const CClassTypeInfoBase *, CLessTypeInfo > TClassesById
Definition: classinfob.hpp:140
virtual const CObject * GetCObjectPtr(TConstObjectPtr objectPtr) const
Definition: typeinfo.cpp:325
set< CClassTypeInfoBase * > TClasses
Definition: classinfob.hpp:138
CItemsInfo m_Items
Definition: classinfob.hpp:133
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Definition: type.c:6
Modified on Wed May 22 11:33:46 2024 by modify_doxy.py rev. 669887