24 #ifndef _IFC_COMMON_H_
25 #define _IFC_COMMON_H_
37 #define SMARTPTR(classname) class classname; typedef OdSmartPtr<classname> classname##Ptr; typedef OdArray<classname##Ptr> classname##PtrArray;
39 #define OD_IFC_CONS_DEFINE_MEMBERS(ClassName,ParentClass,DOCREATE,ClassType) \
41 OD_IFC_CONS_DEFINE_MEMBERS_ALTNAME(ClassName,ParentClass,OD_T(#ClassName),DOCREATE,ClassType)
43 #define OD_IFC_CONS_DEFINE_MEMBERS_ALTNAME(ClassName,ParentClass,szClassName,DOCREATE,ClassType) \
45 OD_IFC_DEFINE_MEMBERS2(ClassName,ParentClass,ClassName::pseudoConstructor,0,0,0,szClassName,OdString::kEmpty,OdString::kEmpty,0,ClassType) \
47 ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName,DOCREATE)
49 #define OD_IFC_DEFINE_MEMBERS2(ClassName,ParentClass,pseudoConsFn,DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags,ClassType) \
51 ODRX_DEFINE_RTTI_MEMBERS(ClassName,ParentClass) \
53 OD_IFC_DEFINE_INIT_MEMBERS(ClassName,ParentClass,pseudoConsFn, \
54 DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags, ClassType)
57 #define OD_IFC_DEFINE_INIT_MEMBERS(ClassName, ParentClass, pseudoConsFn, DwgVer, \
58 MaintVer, nProxyFlags, szDWGClassName, \
59 szDxfName, szAppName, nCustomFlags, ClassType) \
60 OD_IFC_DEFINE_INIT_MEMBERS_GENERIC( \
62 (::newOdRxClass(szDWGClassName, ParentClass::desc(), pseudoConsFn, DwgVer, \
63 MaintVer, nProxyFlags, szDxfName, szAppName, NULL, nCustomFlags)), \
64 (::newOdRxClass(szDWGClassName, ParentClass::desc(), pseudoConsFn, DwgVer, \
65 MaintVer, nProxyFlags, szDxfName, szAppName, pAppNameChangeCallback, nCustomFlags)), \
68 #define OD_IFC_DEFINE_INIT_MEMBERS_GENERIC(ClassName, CREATE_CLASS_INSTANCE, CREATE_CLASS_INSTANCE2, ClassType)\
69 void ClassName::rxInit() \
71 if (!ClassName::g_pDesc) { \
72 ClassName::g_pDesc = CREATE_CLASS_INSTANCE; \
73 odIfcClassDictionary().putAt(ClassType, ClassName::desc()); \
75 ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \
76 throw OdError(eExtendedError); \
79 void ClassName::rxInit(AppNameChangeFuncPtr pAppNameChangeCallback) \
81 if (!ClassName::g_pDesc) { \
82 ClassName::g_pDesc = CREATE_CLASS_INSTANCE2; \
83 odIfcClassDictionary().putAt(ClassType, ClassName::desc()); \
85 ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \
86 throw OdError(eExtendedError); \
91 void ClassName::rxUninit() \
93 if (ClassName::g_pDesc) { \
94 ::deleteOdRxClass(ClassName::g_pDesc); \
95 ClassName::g_pDesc = 0; \
96 odIfcClassDictionary().remove(ClassType); \
98 ODA_ASSERT(("Class ["#ClassName"] is not initialized yet.",0)); \
99 throw OdError(eNotInitializedYet); \
103 #define OD_IFC_DECLARE_MEMBERS_GENERIC(ClassType, ClassName) \
105 static OdSmartPtr<ClassName> cast(const OdRxObject* pObj) \
108 return OdSmartPtr<ClassName>(((ClassName*)pObj->queryX(ClassName::desc())), kOdRxObjAttach); \
109 return (ClassName*)0; \
111 static ClassType* g_pDesc; \
112 static ClassType* desc(); \
113 virtual ClassType* isA() const; \
114 virtual OdRxObject* queryX(const OdRxClass* protocolClass) const; \
115 static OdRxObjectPtr pseudoConstructor(); \
116 static OdSmartPtr<ClassName> createObject() \
117 { if (!desc()) throw OdError(eNotInitializedYet); return desc()->create(); } \
118 static OdSmartPtr<ClassName> createObject(OdIfcModel* pModel) \
121 throw OdError(eNoDatabase); \
123 throw OdError(eNotInitializedYet); \
124 OdSmartPtr<ClassName> pObj = desc()->create(); \
125 OdIfcEntityPtr pEnt = pModel->createEntityInstance(desc()->name().mid(2)); \
127 throw OdError(eIllegalEntityType); \
128 pModel->appendEntityInstance(pEnt); \
129 pObj->m_pEntInst = pEnt; \
130 pEnt->resolve(kResCompound, new OdIfcCompoundPtr(pObj)); \
133 static void rxInit(); \
134 static void rxInit(AppNameChangeFuncPtr appNameChangeFunc); \
136 static void rxUninit()
138 #define OD_IFC_DECLARE_MEMBERS(ClassName) \
139 OD_IFC_DECLARE_MEMBERS_GENERIC(OdRxClass, ClassName)