CFx SDK Documentation  2020SP3
IfcRxProperties.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 _IFC_RX_PROPERTIES_H
25 #define _IFC_RX_PROPERTIES_H
26 
27 #include "IfcCommon.h"
28 #include "daiRxProperties.h"
29 #include "IfcValueTypes.h"
30 
31 #undef ODRX_DECLARE_RX_PROPERTY_RO_TREE
32 #define ODRX_DECLARE_RX_PROPERTY_RO_TREE(Object, Name, Type, Category, Description, HierarchyLevel) \
33 struct Object ## Name ## Property : OdRxProperty {\
34  static OdRxMemberPtr createObject(const OdRxClass* owner)\
35  {\
36  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
37  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
38  if( OdString::kEmpty != Description ) \
39  ((Object ## Name ## Property*)res.get())->attributes().add(OdRxDescriptionAttribute::createObject(OD_T(Description))); \
40  if( OdString::kEmpty != Category ) \
41  ((Object ## Name ## Property*)res.get())->attributes().add(OdRxUiPlacementAttribute::createObject(OD_T(Category), 1)); \
42  if( OdString::kEmpty != HierarchyLevel ) \
43  ((Object ## Name ## Property*)res.get())->attributes().add(OdIfcRxHierarchyLevelAttribute::createObject()); \
44  return res;\
45  }\
46  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const ODRX_OVERRIDE;\
47  virtual bool isReadOnly(const OdRxObject*) const ODRX_OVERRIDE { return true; }\
48 }
49 
50 #undef ODRX_DAI_DECLARE_RX_PROPERTY_COLLECTION_TREE
51 #define ODRX_DAI_DECLARE_RX_PROPERTY_COLLECTION_TREE(Object, Name, Type, Category, Description, HierarchyLevel) \
52 struct Object ## Name ## Property : OdRxCollectionProperty {\
53  static OdRxMemberPtr createObject(const OdRxClass* owner)\
54  {\
55  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
56  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
57  ((Object ## Name ## Property*)res.get())->attributes().add(OdIfcRxDisplayAsAttribute::createObject(false, true)); \
58  if( OdString::kEmpty != Description ) \
59  ((Object ## Name ## Property*)res.get())->attributes().add(OdRxDescriptionAttribute::createObject(OD_T(Description))); \
60  if( OdString::kEmpty != Category ) \
61  ((Object ## Name ## Property*)res.get())->attributes().add(OdRxUiPlacementAttribute::createObject(OD_T(Category), 1)); \
62  if( OdString::kEmpty != HierarchyLevel ) \
63  ((Object ## Name ## Property*)res.get())->attributes().add(OdIfcRxHierarchyLevelAttribute::createObject()); \
64  return res;\
65  }\
66  virtual OdRxValueIteratorPtr subNewValueIterator(const OdRxObject* pO) const ODRX_OVERRIDE;\
67  virtual OdResult subTryGetCount(const OdRxObject* pO, int& count) const ODRX_OVERRIDE;\
68 }
69 
70 #define ODRX_DAI_DECLARE_RX_PROPERTY(Object, Name, Type, Category) struct Object ## Name ## Property : OdRxProperty {\
71  static OdRxMemberPtr createObject(const OdRxClass* owner)\
72  {\
73  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
74  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
75  if( OdString::kEmpty != Category ) \
76  ((Object ## Name ## Property*)res.get())->attributes().add(OdRxUiPlacementAttribute::createObject(OD_T(Category), 1)); \
77  return res;\
78  }\
79  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const ODRX_OVERRIDE;\
80  virtual OdResult subSetValue(OdRxObject* pO, const OdRxValue& value) const ODRX_OVERRIDE;\
81 }
82 
83 #define ODRX_DAI_DECLARE_RX_PROPERTY_UI(Object, Name, Type, Category) struct Object ## Name ## Property : OdRxProperty {\
84  static OdRxMemberPtr createObject(const OdRxClass* owner)\
85  {\
86  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
87  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
88  if( OdString::kEmpty != Category ) \
89  ((Object ## Name ## Property*)res.get())->attributes().add(OdRxUiPlacementAttribute::createObject(OD_T(Category), 1)); \
90  return res;\
91  }\
92  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const ODRX_OVERRIDE;\
93  virtual OdResult subSetValue(OdRxObject* pO, const OdRxValue& value) const ODRX_OVERRIDE;\
94 }
95 
96 #define OD_DAI_DEFINE_COLLECTION_TREE_PROPERTY_INTERMEDIARY(Object, Name, IntermediaryPropName) \
97 OdRxValueIteratorPtr Object ## Name ## Property::subNewValueIterator(const OdRxObject* pO) const\
98 {\
99  OdRxValueIteratorPtr res;\
100  OdDAI::EntityInstancePtr pEnt = OdDAI::EntityInstance::cast(pO);\
101  if (!pEnt.isNull())\
102  {\
103  OdDAIObjectIds idsRel;\
104  if (pEnt->getAttr( #Name ) >> idsRel) {\
105  OdDAIObjectIds resIds;\
106  OdDAI::EntityInstancePtr pIntermediary;\
107  for (OdDAIObjectIds::iterator it = idsRel.begin(), end = idsRel.end(); it < end; ++it) {\
108  pIntermediary = it->openObject(OdDAI::kForRead);\
109  if (!pIntermediary.isNull()) {\
110  OdDAIObjectIds idsIntermediary;\
111  if (pIntermediary->getAttr( #IntermediaryPropName ) >> idsIntermediary) {\
112  resIds.append(idsIntermediary);\
113  }\
114  }\
115  }\
116  if (resIds.size() > 0) {\
117  res = OdRxObjectImpl<OdDAIObjectIdIterator>::createObject();\
118  ((OdDAIObjectIdIterator*)res.get())->init(resIds);\
119  }\
120  }\
121  }\
122  return res;\
123 }\
124 OdResult Object ## Name ## Property::subTryGetCount(const OdRxObject* pO, int& count) const\
125 {\
126  const OdDAI::EntityInstancePtr pEnt = OdDAI::EntityInstance::cast(pO);\
127  if (pEnt.isNull())\
128  return eNotApplicable;\
129  count = 0;\
130  OdDAIObjectIds idsRel;\
131  if (pEnt->getAttr( #Name ) >> idsRel) {\
132  OdDAI::EntityInstancePtr pIntermediary;\
133  for (OdDAIObjectIds::iterator it = idsRel.begin(), end = idsRel.end(); it < end; ++it) {\
134  pIntermediary = it->openObject(OdDAI::kForRead);\
135  if (!pIntermediary.isNull()) {\
136  OdDAIObjectIds idsIntermediary;\
137  if (pIntermediary->getAttr( #IntermediaryPropName ) >> idsIntermediary) {\
138  count += idsIntermediary.size();\
139  }\
140  }\
141  }\
142  return eOk;\
143  }\
144  return eInvalidProps;\
145 }\
146 
147 #define OD_DAI_DEFINE_PRIMITIVE_PROPERTY(Object, Name, Type) \
148 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
149 {\
150  OdSmartPtr<Object> pObj = Object::cast(pO);\
151  if (pObj.isNull())\
152  return eNotApplicable;\
153  value = pObj->get ## Name ();\
154  return eOk;\
155 }\
156 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
157 {\
158  OdSmartPtr<Object> pObj = Object::cast(pO);\
159  if (pObj.isNull())\
160  return eNotApplicable;\
161  const Type *pVal = rxvalue_cast<Type>(&value);\
162  if (pVal)\
163  {\
164  pObj->set ## Name (*pVal);\
165  return eOk;\
166  }\
167  return eNotApplicable;\
168 }
169 
170 #define OD_DAI_DEFINE_PRIMITIVE_AGGR_PROPERTY(Object, Name, Type)\
171 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
172 {\
173  OdSmartPtr<Object> pObj = Object::cast(pO);\
174  if (pObj.isNull())\
175  return eNotApplicable;\
176  Type arr;\
177  pObj->get ## Name ## Aggr (arr);\
178  value = arr;\
179  return eOk;\
180 }\
181 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
182 {\
183  OdSmartPtr<Object> pObj = Object::cast(pO);\
184  if (pObj.isNull())\
185  return eNotApplicable;\
186  const Type *pVal = rxvalue_cast<Type>(&value);\
187  if (pVal)\
188  {\
189  pObj->set ## Name ## Aggr (*pVal);\
190  return eOk;\
191  }\
192  return eNotApplicable;\
193 }
194 
195 #define OD_DAI_DEFINE_INV_PRIMITIVE_PROPERTY(Object, Name, Type)\
196 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
197 {\
198  OdSmartPtr<Object> pObj = Object::cast(pO);\
199  if (pObj.isNull())\
200  return eNotApplicable;\
201  value = pObj->getInv ## Name(); \
202  return eOk;\
203 }\
204 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
205 {\
206  return eNotApplicable;\
207 }
208 
209 #define OD_DAI_DEFINE_INV_PRIMITIVE_AGGR_PROPERTY(Object, Name, Type)\
210 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
211 {\
212  OdSmartPtr<Object> pObj = Object::cast(pO);\
213  if (pObj.isNull())\
214  return eNotApplicable;\
215  Type arr;\
216  pObj->getInv ## Name ## Aggr (arr);\
217  value = arr;\
218  return eOk;\
219 }\
220 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
221 {\
222  return eNotApplicable;\
223 }
224 
225 #define OD_DAI_DEFINE_ENUM_PROPERTY(Object, Name, Type)\
226 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
227 {\
228  return eNotApplicable;\
229 }\
230 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
231 {\
232  return eNotApplicable;\
233 }
234 
235 #define OD_DAI_DEFINE_SELECT_PROPERTY(Object, Name, Type)\
236 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
237 {\
238  return eNotApplicable;\
239 }\
240 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
241 {\
242  return eNotApplicable;\
243 }
244 
245 #define OD_DAI_DEFINE_SELECT_AGGR_PROPERTY(Object, Name, Type)\
246 OdResult Object ## Name ## Property::subGetValue(const OdRxObject* pO, OdRxValue& value) const\
247 {\
248  return eNotApplicable;\
249 }\
250 OdResult Object ## Name ## Property::subSetValue(OdRxObject* pO, const OdRxValue& value) const\
251 {\
252  return eNotApplicable;\
253 }
254 
255 #endif // _IFC_RX_PROPERTIES_H
IfcValueTypes.h
IfcCommon.h
daiRxProperties.h