CFx SDK Documentation  2022 SP0
RxProperty.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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) 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.
24 // Examples:
25 //
26 // R/W Property
27 // ODRX_DECLARE_RX_PROPERTY_START(OdDbDatabase, Splinetype, int)
28 // ODRX_DECLARE_RX_PROPERTY_GET_BY_VAL(OdDbDatabase, getSPLINETYPE, int);
29 // ODRX_DECLARE_RX_PROPERTY_SET_BY_VAL(OdDbDatabase, setPLINETYPE, int);
30 // ODRX_DECLARE_RX_PROPERTY_END;
31 //
32 // R/O Property
33 // ODRX_DECLARE_RX_PROPERTY_START(OdDbDatabase, Splinetype, int)
34 // ODRX_DECLARE_RX_PROPERTY_GET_BY_VAL(OdDbDatabase, getPLINETYPE, int);
35 // ODRX_DECLARE_RX_PROPERTY_READONLY;
36 // ODRX_DECLARE_RX_PROPERTY_END;
37 //
38 // R/W Property with subproperty
39 // ODRX_DECLARE_RX_PROPERTY_START(OdDbDatabase, Pextmin, OdGePoint3d)
40 // ODRX_DECLARE_RX_PROPERTY_GET_BY_VAL(OdDbDatabase, getPEXTMIN, OdGePoint3d);
41 // ODRX_DECLARE_RX_PROPERTY_SET_BY_VAL(OdDbDatabase, setPEXTMIN, OdGePoint3d);
42 // ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_START
43 // ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_ADD(X, double);
44 // ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_ADD(Y, double);
45 // ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_ADD(Z, double);
46 // ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_END;
47 // ODRX_DECLARE_RX_PROPERTY_END;
48 //
50 
51 #ifndef _RXPROPERTY_H_INCLUDED_
52 #define _RXPROPERTY_H_INCLUDED_
53 
54 #include "RxMember.h"
55 #include "RxObjectImpl.h"
56 
57 class OdRxPropertyBaseImpl;
58 class OdRxValueIteratorImpl;
59 class OdRxPropertyIteratorImpl;
60 class OdRxDictionaryPropertyImpl;
61 class OdRxPropertyImpl;
62 class OdRxCollectionPropertyImpl;
63 class OdRxIndexedPropertyImpl;
64 
71 {
72 public:
74  virtual bool isReadOnly(const OdRxObject* pO) const;
75 protected:
76  OdRxPropertyBase(OdRxPropertyBaseImpl*);
77 };
78 
80 
86 {
87 public:
90 
98 
106 protected:
110  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const;
111 
115  virtual OdResult subSetValue(OdRxObject* pO, const OdRxValue& value) const;
116  friend class OdRxPropertyImpl;
117  friend class OdRxPropertyOverrule;
118  OdRxProperty(OdRxPropertyImpl*);
119 };
120 
122 
128 {
129 public:
131  virtual OdResult getValue(const OdRxProperty* pProp, const OdRxObject* pO, OdRxValue& value) const;
132  virtual OdResult setValue(const OdRxProperty* pProp, OdRxObject* pO, const OdRxValue& value) const;
133 };
134 
135 
142 {
143 public:
145 };
146 
152 {
157  virtual bool done() = 0;
161  virtual bool next() = 0;
165  virtual OdRxValue current() const = 0;
166 };
167 
169 
174 {
175 public:
178  OdResult tryGetCount(const OdRxObject* pO, int& count) const;
180 protected:
182  virtual OdResult subTryGetCount(const OdRxObject* pO, int& count) const;
183  using OdRxMember::init;
184  friend class OdRxCollectionPropertyImpl;
186  OdRxCollectionProperty(OdRxCollectionPropertyImpl* pImpl);
187 };
188 
190 
195 {
196 public:
198  virtual OdRxValueIterator* newValueIterator(const OdRxCollectionProperty* pProp, const OdRxObject* pO) const;
199  virtual OdResult tryGetCount(const OdRxCollectionProperty* pProp, const OdRxObject* pO, int& count) const;
200 };
201 
206 {
207 public:
209  OdResult getValue(const OdRxObject* pO, int index, OdRxValue& value) const;
210  OdResult setValue(OdRxObject* pO, int index, const OdRxValue& value) const;
214 protected:
215  virtual OdResult subGetValue(const OdRxObject* pO, int index, OdRxValue& value) const { return eNotApplicable; }
216  virtual OdResult subSetValue(OdRxObject* pO, int index, const OdRxValue& value) const { return eNotApplicable; }
217  virtual OdResult subInsertValue(OdRxObject* pO, int index, const OdRxValue& value) const { return eNotApplicable; }
218  virtual OdResult subRemoveValue(OdRxObject* pO, int index) const { return eNotApplicable; }
220  friend class OdRxIndexedPropertyImpl;
221  OdRxIndexedProperty(OdRxIndexedPropertyImpl* pImpl);
222 };
223 
224 
226 
231 {
232 public:
234  OdResult getValue(const OdRxObject* pO, const OdString& key, OdRxValue& value) const;
235  OdResult setValue(OdRxObject* pO, const OdString& key, const OdRxValue& value) const;
237 protected:
238  virtual OdResult subGetValue(const OdRxObject* pO, const OdString& key, OdRxValue& value) const { return eNotApplicable; }
239  virtual OdResult subSetValue(OdRxObject* pO, const OdString& key, const OdRxValue& value) const { return eNotApplicable; }
241  friend class OdRxDictionaryPropertyImpl;
242  OdRxDictionaryProperty(OdRxDictionaryPropertyImpl* pImpl);
243 };
244 
245 #define ODRX_DECLARE_RX_PROPERTY_RO(Object, Name, Type) struct Object ## Name ## Property : OdRxProperty {\
246  static OdRxMemberPtr createObject(const OdRxClass* owner)\
247  {\
248  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
249  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
250  return res;\
251  }\
252  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const ODRX_OVERRIDE;\
253  virtual bool isReadOnly(const OdRxObject*) const ODRX_OVERRIDE { return true; }\
254 }
255 
256 #define ODRX_DECLARE_RX_PROPERTY(Object, Name, Type) struct Object ## Name ## Property : OdRxProperty {\
257  static OdRxMemberPtr createObject(const OdRxClass* owner)\
258  {\
259  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
260  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
261  return res;\
262  }\
263  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const ODRX_OVERRIDE;\
264  virtual OdResult subSetValue(OdRxObject* pO, const OdRxValue& value) const ODRX_OVERRIDE;\
265 }
266 
267 #define ODRX_DECLARE_RX_INDEXED_PROPERTY(Object, Name, Type) \
268 struct Object ## Name ## Property : OdRxIndexedProperty {\
269  static OdRxMemberPtr createObject(const OdRxClass* owner)\
270  {\
271  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
272  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
273  return res;\
274  }\
275  virtual OdResult subGetValue(const OdRxObject* pO, int index, OdRxValue& value) const ODRX_OVERRIDE; \
276  virtual OdResult subSetValue(OdRxObject* pO, int index, const OdRxValue& value) const ODRX_OVERRIDE; \
277  virtual OdResult subInsertValue(OdRxObject* pO, int index, const OdRxValue& value) const ODRX_OVERRIDE; \
278  virtual OdResult subRemoveValue(OdRxObject* pO, int index) const ODRX_OVERRIDE; \
279  virtual OdRxValueIteratorPtr subNewValueIterator(const OdRxObject* pO) const ODRX_OVERRIDE;\
280  virtual OdResult subTryGetCount(const OdRxObject* pO, int& count) const ODRX_OVERRIDE;\
281 }
282 
283 #define ODRX_DECLARE_RX_CPLX_INDEXED_PROPERTY(Object, Name, Type) \
284 struct Object ## Name ## Property : OdRxIndexedProperty {\
285  static OdRxMemberPtr createObject(const OdRxClass* owner)\
286  {\
287  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
288  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
289  return res;\
290  }\
291  virtual OdResult subGetValue(const OdRxObject* pO, int index, OdRxValue& value) const ODRX_OVERRIDE; \
292  virtual OdResult subSetValue(OdRxObject* pO, int index, const OdRxValue& value) const ODRX_OVERRIDE; \
293  virtual OdResult subInsertValue(OdRxObject* pO, int index, const OdRxValue& value) const ODRX_OVERRIDE; \
294  virtual OdResult subRemoveValue(OdRxObject* pO, int index) const ODRX_OVERRIDE; \
295  virtual OdRxValueIteratorPtr subNewValueIterator(const OdRxObject* pO) const ODRX_OVERRIDE;\
296  virtual OdResult subTryGetCount(const OdRxObject* pO, int& count) const ODRX_OVERRIDE;\
297  virtual OdResult subChildren(OdArray<OdRxMemberPtr>& children) const ODRX_OVERRIDE;\
298 }
299 
300 #define ODRX_DECLARE_RX_PROPERTY_START(Object, Name, Type) struct Object ## Name ## Property : OdRxProperty {\
301  static OdRxMemberPtr createObject(const OdRxClass* owner)\
302  {\
303  OdRxMemberPtr res = OdRxObjectImpl<Object ## Name ## Property>::createObject();\
304  ((Object ## Name ## Property*)res.get())->init(__OD_T(#Name), &OdRxValueType::Desc<Type>::value(), owner);\
305  return res;\
306  }
307 
308 #define ODRX_DECLARE_RX_PROPERTY_END }
309 
310 #define ODRX_DECLARE_RX_PROPERTY_READONLY virtual bool isReadOnly(const OdRxObject*) const ODRX_OVERRIDE { return true; }
311 
312 #define ODRX_DECLARE_RX_PROPERTY_GET_BY_VAL(Object, ObjGetMemberName, Type) \
313  virtual OdResult subGetValue(const OdRxObject* pO, OdRxValue& value) const ODRX_OVERRIDE\
314  {\
315  Object ## Ptr pObj = Object::cast(pO);\
316  if (pObj.isNull()) return eNotApplicable;\
317  value = static_cast<Type>(pObj->ObjGetMemberName());\
318  return eOk;\
319  }
320 
321 #define ODRX_DECLARE_RX_PROPERTY_SET_BY_VAL(Object, ObjSetMemberName, Type) \
322  virtual OdResult subSetValue(OdRxObject* pO, const OdRxValue& value) const ODRX_OVERRIDE\
323  {\
324  Object ## Ptr pObj = Object::cast(pO);\
325  if (pObj.isNull()) return eNotApplicable;\
326  pObj->ObjSetMemberName(*rxvalue_cast<Type>(&value));\
327  return eOk;\
328  }
329 
330 #define ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_START \
331  virtual OdResult subChildren(OdArray<OdRxMemberPtr>& children) const {
332 
333 #define ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_END return eOk; }
334 
335 #define ODRX_DECLARE_RX_PROPERTY_SUBCHILDREN_ADD(Name, Type) \
336  children.append(OdRxSubProperty::createObject(__OD_T(#Name), OdRxValueType::Desc<Type>::value(), this))
337 
338 // Subproperty allows access to the individual components of a complex type
339 
344 {
345 protected:
347 public:
348  static OdRxMemberPtr createObject(const OdString& memberName, const OdRxValueType& type, const OdRxProperty* owner);
349  virtual bool isReadOnly(const OdRxObject* pO) const ODRX_OVERRIDE;
352 };
353 
355 {
356 protected:
358 public:
359  static OdRxMemberPtr createObject(const OdString& memberName, const OdRxValueType& type, const OdRxIndexedProperty* owner);
362 };
363 
365 {
366 protected:
368 public:
369  static OdRxMemberPtr createObject(const OdString& memberName, const OdRxValueType& type, const OdRxProperty* owner);
375  virtual OdResult subTryGetCount(const OdRxObject* pO, int& count) const ODRX_OVERRIDE;
376 };
377 
378 
379 
380 #endif
#define NULL
Definition: GsProperties.h:177
#define ODRX_ABSTRACT
#define ODRX_OVERRIDE
OdResult
Definition: OdResult.h:29
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
OdSmartPtr< OdRxPropertyBase > OdRxPropertyBasePtr
Definition: RxProperty.h:79
OdSmartPtr< OdRxProperty > OdRxPropertyPtr
Definition: RxProperty.h:121
OdSmartPtr< OdRxValueIterator > OdRxValueIteratorPtr
Definition: RxProperty.h:168
OdSmartPtr< OdRxCollectionProperty > OdRxCollectionPropertyPtr
Definition: RxProperty.h:189
OdSmartPtr< OdRxIndexedProperty > OdRxIndexedPropertyPtr
Definition: RxProperty.h:225
virtual OdResult subTryGetCount(const OdRxObject *pO, int &count) const
ODRX_DECLARE_MEMBERS(OdRxCollectionProperty)
OdRxCollectionProperty(OdRxCollectionPropertyImpl *pImpl)
OdRxValueIteratorPtr newValueIterator(const OdRxObject *pO) const
OdResult tryGetCount(const OdRxObject *pO, int &count) const
virtual OdRxValueIteratorPtr subNewValueIterator(const OdRxObject *pO) const
virtual OdRxValueIterator * newValueIterator(const OdRxCollectionProperty *pProp, const OdRxObject *pO) const
ODRX_DECLARE_MEMBERS(OdRxCollectionPropertyOverrule)
virtual OdResult tryGetCount(const OdRxCollectionProperty *pProp, const OdRxObject *pO, int &count) const
OdResult setValue(OdRxObject *pO, const OdString &key, const OdRxValue &value) const
OdRxDictionaryProperty(OdRxDictionaryPropertyImpl *pImpl)
ODRX_DECLARE_MEMBERS(OdRxDictionaryProperty)
static OdRxCollectionPropertyPtr createObject(const OdString &name, const OdRxValueType &type, const OdRxObject *owner=NULL)
OdResult getValue(const OdRxObject *pO, const OdString &key, OdRxValue &value) const
virtual OdResult subSetValue(OdRxObject *pO, const OdString &key, const OdRxValue &value) const
Definition: RxProperty.h:239
virtual OdResult subGetValue(const OdRxObject *pO, const OdString &key, OdRxValue &value) const
Definition: RxProperty.h:238
OdResult getValue(const OdRxObject *pO, int index, OdRxValue &value) const
OdResult removeValue(OdRxObject *pO, int index) const
OdRxIndexedProperty(OdRxIndexedPropertyImpl *pImpl)
virtual OdResult subGetValue(const OdRxObject *pO, int index, OdRxValue &value) const
Definition: RxProperty.h:215
OdResult setValue(OdRxObject *pO, int index, const OdRxValue &value) const
virtual OdResult subSetValue(OdRxObject *pO, int index, const OdRxValue &value) const
Definition: RxProperty.h:216
virtual OdResult subRemoveValue(OdRxObject *pO, int index) const
Definition: RxProperty.h:218
static OdRxCollectionPropertyPtr createObject(const OdString &name, const OdRxValueType &type, const OdRxObject *owner=NULL)
virtual OdResult subInsertValue(OdRxObject *pO, int index, const OdRxValue &value) const
Definition: RxProperty.h:217
OdResult insertValue(OdRxObject *pO, int index, const OdRxValue &value) const
ODRX_DECLARE_MEMBERS(OdRxIndexedProperty)
virtual OdResult subRemoveValue(OdRxObject *pO, int index) const ODRX_OVERRIDE
virtual OdResult subGetValue(const OdRxObject *pO, int index, OdRxValue &value) const ODRX_OVERRIDE
virtual OdResult subSetValue(OdRxObject *pO, int index, const OdRxValue &value) const ODRX_OVERRIDE
virtual OdResult subInsertValue(OdRxObject *pO, int index, const OdRxValue &value) const ODRX_OVERRIDE
static OdRxMemberPtr createObject(const OdString &memberName, const OdRxValueType &type, const OdRxProperty *owner)
virtual OdRxValueIteratorPtr subNewValueIterator(const OdRxObject *pO) const ODRX_OVERRIDE
virtual OdResult subTryGetCount(const OdRxObject *pO, int &count) const ODRX_OVERRIDE
void init(const OdString &name, const OdRxValueType *type, const OdRxObject *owner=0)
ODRX_DECLARE_MEMBERS(OdRxPromotingQueryContext)
ODRX_DECLARE_MEMBERS(OdRxPropertyBase)
virtual bool isReadOnly(const OdRxObject *pO) const
OdRxPropertyBase(OdRxPropertyBaseImpl *)
OdResult setValue(OdRxObject *pO, const OdRxValue &value) const
OdResult getValue(const OdRxObject *pO, OdRxValue &value) const
OdRxProperty(OdRxPropertyImpl *)
ODRX_DECLARE_MEMBERS(OdRxProperty)
virtual OdResult subSetValue(OdRxObject *pO, const OdRxValue &value) const
virtual OdResult subGetValue(const OdRxObject *pO, OdRxValue &value) const
ODRX_DECLARE_MEMBERS(OdRxPropertyOverrule)
virtual OdResult getValue(const OdRxProperty *pProp, const OdRxObject *pO, OdRxValue &value) const
virtual OdResult setValue(const OdRxProperty *pProp, OdRxObject *pO, const OdRxValue &value) const
virtual bool isReadOnly(const OdRxObject *pO) const ODRX_OVERRIDE
virtual OdResult subGetValue(const OdRxObject *pO, OdRxValue &value) const ODRX_OVERRIDE
virtual OdResult subSetValue(OdRxObject *pO, const OdRxValue &value) const ODRX_OVERRIDE
static OdRxMemberPtr createObject(const OdString &memberName, const OdRxValueType &type, const OdRxProperty *owner)
virtual OdResult subSetValue(OdRxObject *pO, int index, const OdRxValue &value) const ODRX_OVERRIDE
static OdRxMemberPtr createObject(const OdString &memberName, const OdRxValueType &type, const OdRxIndexedProperty *owner)
virtual OdResult subGetValue(const OdRxObject *pO, int index, OdRxValue &value) const ODRX_OVERRIDE
GLuint index
Definition: gles2_ext.h:265
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLsizei GLsizei * count
Definition: gles2_ext.h:276
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
ODRX_DECLARE_MEMBERS(OdRxValueIterator)
virtual bool done()=0
virtual OdRxValue current() const =0
virtual bool next()=0