CFx SDK Documentation  2022 SP0
daiRTTI.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2019, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Open Design Alliance software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Open Design Alliance Copyright (C) 2002-2019 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef _DAI_RTTI_H
25 #define _DAI_RTTI_H
26 
27 #include "daiSchema.h"
28 #include "daiEntity.h"
29 
31  const OdString &szClassName,
32  OdRxClass* pBaseClass,
33  OdDAI::SchemaPtr expSchema,
34  OdPseudoConstructorType pConstr = 0,
35  int DwgVer = 0,
36  int MaintVer = 0,
37  int nProxyFlags = 0,
38  const OdString& sDxfName = OdString::kEmpty,
39  const OdString& sAppName = OdString::kEmpty,
40  AppNameChangeFuncPtr fNameChangeFunc = NULL,
41  int nCustomFlags = 0,
42  OdRxMemberCollectionConstructorPtr memberConstruct = 0,
43  void* userData = 0
44 );
45 
50 #define OD_EXP_DECLARE_MEMBERS_GENERIC(ClassType, ClassName)\
51 public: \
52  \
53  static OdDAI::Entity* g_pExpEntityDef; \
54  \
55  \
56  static OdSmartPtr<ClassName> cast(const OdRxObject* pObj) \
57  { \
58  if (pObj) \
59  return OdSmartPtr<ClassName>(((ClassName*)pObj->queryX(ClassName::desc())), kOdRxObjAttach); \
60  return (ClassName*)0; \
61  } \
62  \
63  static ClassType* g_pDesc; \
64  \
65  \
66  \
67  \
68  static ClassType* desc(); \
69  \
70  \
71  \
72  \
73  virtual ClassType* isA() const; \
74  \
75  \
76  \
77  virtual OdRxObject* queryX(const OdRxClass* protocolClass) const; \
78  \
79  \
80  \
81  static OdRxObjectPtr pseudoConstructor(); \
82  \
83  \
84  \
85  static OdSmartPtr<ClassName> createObject() \
86  { if (!desc()) throw OdError(eNotInitializedYet); return desc()->create(); } \
87  \
88  \
89  static void rxInit(); \
90  static void rxInit(AppNameChangeFuncPtr appNameChangeFunc); \
91  \
92 /* Unregisters ClassName with the ODA Platform. **/ \
93  static void rxUninit()
94 
95 #define OD_EXP_DECLARE_MEMBERS(ClassName)\
96  OD_EXP_DECLARE_MEMBERS_GENERIC(OdRxClass, ClassName)
97 
98 
102 #define OD_EXP_DEFINE_RTTI_MEMBERS_GENERIC(ClassType, ClassName, ParentClass) \
103  \
104  OdDAI::Entity* ClassName::g_pExpEntityDef = 0; \
105  ClassType* ClassName::g_pDesc = 0; \
106  ClassType* ClassName::desc() { return g_pDesc; } \
107  ClassType* ClassName::isA() const { return g_pDesc; } \
108  \
109  OdRxObject* ClassName::queryX(const OdRxClass* pClass) const { \
110  return ::odQueryXImpl<ClassName, ParentClass>(this, pClass); \
111  }
112 
113 #define OD_EXP_DEFINE_INIT_MEMBERS_GENERIC(ClassName, CREATE_CLASS_INSTANCE, CREATE_CLASS_INSTANCE2) \
114  \
115 /* Registers this class with Teigha. */ \
116 void ClassName::rxInit() \
117 { \
118  if (!ClassName::g_pDesc) { \
119  ClassName::g_pDesc = CREATE_CLASS_INSTANCE; \
120  } else { \
121  ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \
122  throw OdError(eExtendedError); \
123  } \
124 } \
125 void ClassName::rxInit(AppNameChangeFuncPtr pAppNameChangeCallback) \
126 { \
127  if (!ClassName::g_pDesc) { \
128  ClassName::g_pDesc = CREATE_CLASS_INSTANCE2; \
129  } else { \
130  ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \
131  throw OdError(eExtendedError); \
132  } \
133 } \
134  \
135 /* Unregisters this class with Teigha. */ \
136 void ClassName::rxUninit() \
137 { \
138  if (ClassName::g_pDesc) { \
139  ::deleteOdRxClass(ClassName::g_pDesc); \
140  ClassName::g_pDesc = 0; \
141  } else { \
142  ODA_ASSERT(("Class ["#ClassName"] is not initialized yet.",0)); \
143  throw OdError(eNotInitializedYet); \
144  } \
145 }
146 
147 
148 #define OD_EXP_DEFINE_RTTI_MEMBERS(ClassName, ParentClass) \
149  OD_EXP_DEFINE_RTTI_MEMBERS_GENERIC(OdRxClass, ClassName, ParentClass)
150 
151 #define OD_EXP_DEFINE_INIT_MEMBERS(SchemaName,ClassName, ParentClass, pseudoConsFn, DwgVer, \
152  MaintVer, nProxyFlags, szDWGClassName, \
153  szDxfName, szAppName, nCustomFlags) \
154  OD_EXP_DEFINE_INIT_MEMBERS_GENERIC( \
155  ClassName, \
156  (/*getOdDAIEntityClass*/::newOdRxClass(szDWGClassName, ParentClass::desc()/*, g_pSchemaDef*/, pseudoConsFn, DwgVer, \
157  MaintVer, nProxyFlags, szDxfName, szAppName, NULL, nCustomFlags)), \
158  (/*getOdDAIEntityClass*/::newOdRxClass(szDWGClassName, ParentClass::desc()/*, g_pSchemaDef*/, pseudoConsFn, DwgVer, \
159  MaintVer, nProxyFlags, szDxfName, szAppName, pAppNameChangeCallback, nCustomFlags)))
160 
161 
162 //
163 #define OD_EXP_DEFINE_MEMBERS2(SchemaName,ClassName,ParentClass,pseudoConsFn,DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags) \
164  \
165 OD_EXP_DEFINE_RTTI_MEMBERS(ClassName,ParentClass) \
166  \
167 OD_EXP_DEFINE_INIT_MEMBERS(SchemaName,ClassName,ParentClass,pseudoConsFn, \
168  DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags)
169 
170 
171 
172 #define OD_EXP_DEFINE_PSEUDOCONSTRUCTOR(ClassName,DOCREATE) \
173  \
174 OdRxObjectPtr ClassName::pseudoConstructor() { return OdRxObjectPtr(DOCREATE(ClassName)); }
175 
176 
177 
178 #define OD_EXP_CONS_DEFINE_MEMBERS_ALTNAME(SchemaName,ClassName,ParentClass,szClassName,DOCREATE) \
179  \
180 OD_EXP_DEFINE_MEMBERS2(SchemaName,ClassName,ParentClass,ClassName::pseudoConstructor,0,0,0,szClassName,OdString::kEmpty,OdString::kEmpty,0) \
181  \
182 OD_EXP_DEFINE_PSEUDOCONSTRUCTOR(ClassName,DOCREATE)
183 
184 
185 
186 #define OD_EXP_CONS_DEFINE_MEMBERS(SchemaName,ClassName,ParentClass,DOCREATE) \
187  \
188 OD_EXP_CONS_DEFINE_MEMBERS_ALTNAME(SchemaName,ClassName,ParentClass,OD_T(#ClassName),DOCREATE)
189 
190 #endif // _DAI_RTTI_H
#define NULL
Definition: GsProperties.h:177
OdRxObjectPtr(* OdPseudoConstructorType)()
Definition: RxObject.h:849
void(* OdRxMemberCollectionConstructorPtr)(OdRxMemberCollectionBuilder &, void *)
Definition: RxObject.h:838
void(* AppNameChangeFuncPtr)(const OdRxClass *classObj, OdString &newAppName, int saveVer)
Definition: RxObject.h:44
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
#define DAI_EXPORT
DAI_EXPORT OdDAI::Entity * getOdDAIEntityClass(const OdString &szClassName, OdRxClass *pBaseClass, OdDAI::SchemaPtr expSchema, OdPseudoConstructorType pConstr=0, int DwgVer=0, int MaintVer=0, int nProxyFlags=0, const OdString &sDxfName=OdString::kEmpty, const OdString &sAppName=OdString::kEmpty, AppNameChangeFuncPtr fNameChangeFunc=NULL, int nCustomFlags=0, OdRxMemberCollectionConstructorPtr memberConstruct=0, void *userData=0)