CFx SDK Documentation
2026 SP0
Loading...
Searching...
No Matches
SDK
CFx
bim_ifc
Common
IfcCommon.h
Go to the documentation of this file.
1
2
// Copyright (C) 2002-2024, 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-2024 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 _IFC_COMMON_H_
25
#define _IFC_COMMON_H_
26
27
#include "
OdaCommon.h
"
28
29
#include "
RxObject.h
"
30
#include "
SmartPtr.h
"
31
#include "daiValueTypes.h"
32
33
#define SMARTPTR(classname) class classname; typedef OdSmartPtr<classname> classname##Ptr; typedef OdArray<classname##Ptr> classname##PtrArray;
34
35
#define OD_IFC_CONS_DEFINE_MEMBERS(ClassName,ParentClass,DOCREATE,ClassType) \
36
\
37
OD_IFC_CONS_DEFINE_MEMBERS_ALTNAME(ClassName,ParentClass,OD_T(#ClassName),DOCREATE,ClassType)
38
39
#define OD_IFC_CONS_DEFINE_MEMBERS_ALTNAME(ClassName,ParentClass,szClassName,DOCREATE,ClassType) \
40
\
41
OD_IFC_DEFINE_MEMBERS2(ClassName,ParentClass,ClassName::pseudoConstructor,0,0,0,szClassName,OdString::kEmpty,OdString::kEmpty,0,ClassType) \
42
\
43
ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName,DOCREATE)
44
45
#define OD_IFC_DEFINE_MEMBERS2(ClassName,ParentClass,pseudoConsFn,DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags,ClassType) \
46
\
47
ODRX_DEFINE_RTTI_MEMBERS(ClassName,ParentClass) \
48
\
49
OD_IFC_DEFINE_INIT_MEMBERS(ClassName,ParentClass,pseudoConsFn, \
50
DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags, ClassType)
51
52
53
#define OD_IFC_DEFINE_INIT_MEMBERS(ClassName, ParentClass, pseudoConsFn, DwgVer, \
54
MaintVer, nProxyFlags, szDWGClassName, \
55
szDxfName, szAppName, nCustomFlags, ClassType) \
56
OD_IFC_DEFINE_INIT_MEMBERS_GENERIC( \
57
ClassName, \
58
(::newOdRxClass(szDWGClassName, ParentClass::desc(), pseudoConsFn, DwgVer, \
59
MaintVer, nProxyFlags, szDxfName, szAppName, NULL, nCustomFlags)), \
60
(::newOdRxClass(szDWGClassName, ParentClass::desc(), pseudoConsFn, DwgVer, \
61
MaintVer, nProxyFlags, szDxfName, szAppName, pAppNameChangeCallback, nCustomFlags)), \
62
ClassType)
63
64
#define OD_IFC_DEFINE_INIT_MEMBERS_GENERIC(ClassName, CREATE_CLASS_INSTANCE, CREATE_CLASS_INSTANCE2, ClassType)\
65
void ClassName::rxInit() \
66
{ \
67
if (!ClassName::g_pDesc) { \
68
ClassName::g_pDesc = CREATE_CLASS_INSTANCE; \
69
odIfcClassDictionary().putAt(ClassType, ClassName::desc()); \
70
} else { \
71
ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \
72
throw OdError(eExtendedError); \
73
} \
74
} \
75
void ClassName::rxInit(AppNameChangeFuncPtr pAppNameChangeCallback) \
76
{ \
77
if (!ClassName::g_pDesc) { \
78
ClassName::g_pDesc = CREATE_CLASS_INSTANCE2; \
79
odIfcClassDictionary().putAt(ClassType, ClassName::desc()); \
80
} else { \
81
ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \
82
throw OdError(eExtendedError); \
83
} \
84
} \
85
\
86
/* Unregisters this class with ODA Platform. */
\
87
void ClassName::rxUninit() \
88
{ \
89
if (ClassName::g_pDesc) { \
90
::deleteOdRxClass(ClassName::g_pDesc); \
91
ClassName::g_pDesc = 0; \
92
odIfcClassDictionary().remove(ClassType); \
93
} else { \
94
ODA_ASSERT(("Class ["#ClassName"] is not initialized yet.",0)); \
95
throw OdError(eNotInitializedYet); \
96
} \
97
}
98
99
#define OD_IFC_DECLARE_MEMBERS_GENERIC(ClassType, ClassName) \
100
public: \
101
static OdSmartPtr<ClassName> cast(const OdRxObject* pObj) \
102
{ \
103
if (pObj) \
104
return OdSmartPtr<ClassName>(((ClassName*)pObj->queryX(ClassName::desc())), kOdRxObjAttach); \
105
return (ClassName*)0; \
106
} \
107
static ClassType* g_pDesc; \
108
static ClassType* desc(); \
109
virtual ClassType* isA() const; \
110
virtual OdRxObject* queryX(const OdRxClass* protocolClass) const; \
111
static OdRxObjectPtr pseudoConstructor(); \
112
static OdSmartPtr<ClassName> createObject() \
113
{ if (!desc()) throw OdError(eNotInitializedYet); return desc()->create(); } \
114
static OdSmartPtr<ClassName> createObject(OdIfcModel* pModel) \
115
{ \
116
if (!pModel) \
117
throw OdError(eNoDatabase); \
118
if (!desc()) \
119
throw OdError(eNotInitializedYet); \
120
OdSmartPtr<ClassName> pObj = desc()->create(); \
121
OdIfcInstancePtr pEnt = pModel->createEntityInstance(desc()->name().mid(2)); \
122
if (pEnt.isNull()) \
123
throw OdError(eIllegalEntityType); \
124
pModel->appendEntityInstance(pEnt); \
125
pObj->m_pEntInst = pEnt; \
126
pEnt->resolve(kResCompound, new OdIfcCompoundPtr(pObj)); \
127
return pObj; \
128
} \
129
static void rxInit(); \
130
static void rxInit(AppNameChangeFuncPtr appNameChangeFunc); \
131
\
132
static void rxUninit()
133
134
#define OD_IFC_DECLARE_MEMBERS(ClassName) \
135
OD_IFC_DECLARE_MEMBERS_GENERIC(OdRxClass, ClassName)
136
137
#endif
// _IFC_COMMON_H_
OdaCommon.h
RxObject.h
SmartPtr.h
Generated on Tue Apr 15 2025 11:28:11