CFx SDK Documentation  2020SP3
TfObject.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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-2017 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 __TF_OBJECT_H__
25 #define __TF_OBJECT_H__
26 
27 #include "TD_PackPush.h"
28 
29 #include "RxObject.h"
30 #include "RxIterator.h"
31 #include "TfVariant.h"
32 #include "TfObjectReactor.h"
33 #include "DbStubPtrArray.h"
34 #include "Gi/GiDrawable.h"
35 
36 #define ODTF_CREATE_ATTRIBUTE(Name, value) \
37  reuslt.push_back(::newOdTfAttribute(OD_T(#Name), pObject, value));
38 
39 #define ODTF_DEFINE_ATTRIBUTES_CONSTRUCTOR(Name, ATTRIBUTES_LIST) \
40  static OdArray<OdTfAttribute*> Name##AttributesConstructor( \
41  OdRxObject* pObject) { \
42  OdArray<OdTfAttribute*> result; \
43  ATTRIBUTES_LIST(ODTF_CREATE_ATTRIBUTE) \
44  return result; \
45  }
46 
47 #define ODTF_CREATE_PROPERTY_NO_ATTRS(PropertyName, type, gettterFn, setterFn, \
48  defaultItemFn) \
49  result.push_back(::newOdTfProperty( \
50  OD_T(#PropertyName), pClass, static_cast<OdTfVariant::Type>(type), NULL, \
51  defaultItemFn, gettterFn, setterFn));
52 
53 #define ODTF_DEFINE_PROPERTIES_CONSTRUCTOR(ClassName, PROPERTIES_LIST) \
54  static OdArray<OdTfProperty*> ClassName##propertiesConstructor( \
55  OdTfClass* pClass) { \
56  OdArray<OdTfProperty*> result; \
57  PROPERTIES_LIST(ODTF_CREATE_PROPERTY_NO_ATTRS); \
58  return result; \
59  }
60 
61 #define ODTF_DECLARE_MEMBERS(ClassName)\
62  ODRX_DECLARE_MEMBERS_GENERIC(OdTfClass, ClassName)
63 
64 #define ODTF_DEFINE_RTTI_MEMBERS(ClassName, ParentClass) \
65  ODRX_DEFINE_RTTI_MEMBERS_GENERIC(OdTfClass, ClassName, ParentClass)
66 
67 #define ODTF_DEFINE_INIT_MEMBERS(ClassName, ParentClass, attrsConsFn, \
68  propsConsFn, pseudoConsFn, szClassName) \
69  ODRX_DEFINE_INIT_MEMBERS_GENERIC( \
70  ClassName, (::newOdTfClass(szClassName, ParentClass::desc(), \
71  attrsConsFn, propsConsFn, pseudoConsFn)), \
72  (::newOdTfClass(szClassName, ParentClass::desc(), attrsConsFn, \
73  propsConsFn, pseudoConsFn)))
74 
75 #define ODTF_DEFINE_MEMBERS2(ClassName, ParentClass, attrsConsFn, propsConsFn, \
76  pseudoConsFn, szClassName) \
77  \
78  ODTF_DEFINE_RTTI_MEMBERS(ClassName, ParentClass) \
79  ODTF_DEFINE_INIT_MEMBERS(ClassName, ParentClass, attrsConsFn, propsConsFn, \
80  pseudoConsFn, szClassName)
81 
82 #define ODTF_NO_CONS_NO_ATTRS_NO_PROPS_DEFINE_MEMBERS(ClassName, ParentClass) \
83  \
84  ODTF_DEFINE_MEMBERS2(ClassName, ParentClass, NULL, NULL, NULL, \
85  OD_T(#ClassName)) \
86  \
87  ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName, EMPTY_CONSTR)
88 
89 #define ODTF_NO_CONS_NO_ATTRS_PROPS_DEFINE_MEMBERS(ClassName, ParentClass, \
90  PROPERTIES_LIST) \
91  ODTF_DEFINE_PROPERTIES_CONSTRUCTOR(ClassName, PROPERTIES_LIST) \
92  ODTF_DEFINE_MEMBERS2(ClassName, ParentClass, NULL, \
93  ClassName##propertiesConstructor, NULL, \
94  OD_T(#ClassName)) \
95  \
96  ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName, EMPTY_CONSTR)
97 
98 #define ODTF_CONS_NO_ATTRS_PROPS_DEFINE_MEMBERS(ClassName, ParentClass, \
99  PROPERTIES_LIST, DOCREATE) \
100  ODTF_DEFINE_PROPERTIES_CONSTRUCTOR(ClassName, PROPERTIES_LIST) \
101  ODTF_DEFINE_MEMBERS2(ClassName, ParentClass, NULL, \
102  ClassName##propertiesConstructor, \
103  ClassName::pseudoConstructor, OD_T(#ClassName)) \
104  \
105  ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName, DOCREATE)
106 
107 #define ODTF_CONS_NO_ATTRS_NO_PROPS_DEFINE_MEMBERS(ClassName, ParentClass, \
108  DOCREATE) \
109  ODTF_DEFINE_MEMBERS2(ClassName, ParentClass, NULL, NULL, \
110  ClassName::pseudoConstructor, OD_T(#ClassName)) \
111  \
112  ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName, DOCREATE)
113 
114 class OdTfClass;
115 class OdTfProperty;
116 class OdTfAttribute;
117 
120 public:
121  virtual OdRxObject* owner() const = 0;
122  virtual const OdTfAttribute* find(const OdString& name) const = 0;
123 };
125 
126 
129 public:
131 
132  virtual OdTfClass* owner() const = 0;
133  virtual size_type size() const = 0;
134  virtual bool contains(const OdTfProperty* pProp) const = 0;
135  virtual const OdTfProperty* find(size_type index) const = 0;
136  virtual const OdTfProperty* find(const OdString& name) const = 0;
137  virtual const OdTfProperty* find(const OdString& name,
138  const OdTfVariant::Type type) const = 0;
139  virtual size_type index(const OdTfProperty* pProp) const = 0;
140  virtual bool unique(const OdString& name) const = 0;
141  virtual bool unique(const OdString& name,
142  const OdTfVariant::Type type) const = 0;
143  virtual OdRxIteratorPtr iterator() const = 0;
144 };
146 
153 public:
154  virtual const OdTfAttributesContainerPtr attributes() const = 0;
155  virtual const OdTfPropertiesContainerPtr properties() const = 0;
156  virtual const OdTfPropertiesContainerPtr allProperties() const = 0;
157  virtual OdTfClass* tfParent() const = 0;
158 };
160 
167 public:
168  virtual OdTfClass* owner() const = 0;
169  virtual OdTfVariant::Type type() const = 0;
170  virtual OdString name() const = 0;
172  /*
173  Returns default value, that should be used for this property instead of
174  OdTfVariant::kEmpty.
175  For single property it returns value, that should be used in place of whole
176  property.
177  For array property it returns value, to replace empty items.
178  */
179  virtual OdTfVariant defaultItemValue() const = 0;
180  virtual OdResult getValue(const OdTfObject* pObject,
181  OdTfVariant& value) const = 0;
182  virtual OdResult setValue(OdTfObject* pObject,
183  const OdTfVariant& value) const = 0;
184 };
186 
193 public:
194  virtual OdRxObject* owner() const = 0;
195  virtual OdString name() const = 0;
196  virtual OdTfVariant value() const = 0;
197 };
199 
206 
207 public:
210 
214  virtual const OdTfObject* getOwner() const = 0;
215 
217  const OdTfProperty* pPI, OdTfVariant& value,
218  const ItemIndexType arrayIndex = -1) const = 0;
219 
221  const OdTfProperty* pPI, const OdTfVariant& value,
222  const ItemIndexType arrayIndex = -1) = 0;
223 
233  const OdString& name, OdTfVariant& value,
234  const ItemIndexType arrayIndex = -1,
235  const OdTfClass* pClass = NULL) const = 0;
245  const OdTfVariant& value,
246  const ItemIndexType arrayIndex = -1,
247  const OdTfClass* pClass = NULL) = 0;
257  const PropertyIndexType propertyIndex, OdTfVariant& value,
258  const ItemIndexType arrayIndex = -1) const = 0;
268  const PropertyIndexType propertyIndex, const OdTfVariant& value,
269  const ItemIndexType arrayIndex = -1) = 0;
270 
280  virtual void addReactor(OdTfObjectReactor* pReactor) = 0;
281 
291  virtual void removeReactor(OdTfObjectReactor* pReactor) = 0;
292 
306 
317 
324  virtual bool hasPersistentReactor(OdTfPersistentReactor*) const = 0;
325 
333 
339  virtual void getTransientReactors(OdTfObjectReactorArray& reactors) = 0;
340 };
342 
343 //
344 //
345 //
346 
350  OdTfVariant&);
352  const OdTfVariant&);
354 
356  const OdString& name, OdRxClass* pBaseClass,
357  OdTfAttributesConstructorType pAttrsConstr,
359  bool bRegister = true);
360 
362 
364  OdTfClass* pClass, const OdString& name, OdRxClass* pBaseClass,
365  const OdArray<OdTfAttribute*>& attributes,
366  const OdArray<OdTfProperty*>& properties, OdPseudoConstructorType pConstr,
367  bool bRegister = true);
368 
370  const OdString& name, OdTfClass* pOwner, OdTfVariant::Type type,
371  OdTfAttributesConstructorType pAttrsConstr,
372  OdTfVariantConstructorType pDefaultValueConstructor,
374 
376 
378  OdTfProperty* pProp, const OdString& name, OdTfClass* pOwner,
380  OdTfVariantConstructorType pDefaultValueConstructor,
382 
384  OdRxObject* pOwner,
385  const OdTfVariant& value);
386 
387 #endif // __TF_OBJECT_H__
OdTfProperty
Definition: TfObject.h:165
OdResult
OdResult
Definition: OdResult.h:29
OdTfVariant
Definition: TfVariant.h:41
OdTfObject::getPersistentReactors
virtual void getPersistentReactors(OdTfPersistentReactorArray &elmIds)=0
OdTfObject::setProperty
virtual OdResult setProperty(const OdTfProperty *pPI, const OdTfVariant &value, const ItemIndexType arrayIndex=-1)=0
OdTfAttribute
Definition: TfObject.h:191
OdString
Definition: OdString.h:95
NULL
#define NULL
Definition: GsProperties.h:177
OdTfPropertyGetterType
OdResult(* OdTfPropertyGetterType)(const OdTfObject *, OdTfVariant &)
Definition: TfObject.h:349
OdTfClassPtr
OdSmartPtr< OdTfClass > OdTfClassPtr
Definition: TfObject.h:159
name
GLuint const GLchar * name
Definition: gles2_ext.h:265
createOdTfClass
TFCORE_EXPORT OdTfClass * createOdTfClass()
OdTfObject::PropertyIndexType
OdTfPropertiesContainer::size_type PropertyIndexType
Definition: TfObject.h:208
OdTfObject::removePersistentReactor
virtual void removePersistentReactor(OdTfPersistentReactor *)=0
type
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
OdTfAttributePtr
OdSmartPtr< OdTfAttribute > OdTfAttributePtr
Definition: TfObject.h:198
OdTfPropertiesContainer::find
virtual const OdTfProperty * find(const OdString &name, const OdTfVariant::Type type) const =0
OdTfObject::removeReactor
virtual void removeReactor(OdTfObjectReactor *pReactor)=0
OdRxObject
Definition: RxObject.h:564
OdTfPropertiesContainer::find
virtual const OdTfProperty * find(size_type index) const =0
TFCORE_EXPORT
#define TFCORE_EXPORT
Definition: TfExport.h:34
OdTfClass::properties
virtual const OdTfPropertiesContainerPtr properties() const =0
OdTfAttributesConstructorType
OdArray< OdTfAttribute * >(* OdTfAttributesConstructorType)(OdRxObject *)
Definition: TfObject.h:348
OdTfProperty::getValue
virtual OdResult getValue(const OdTfObject *pObject, OdTfVariant &value) const =0
RxIterator.h
OdArray
Definition: OdArray.h:591
TfObjectReactor.h
OdTfPropertiesConstructorType
OdArray< OdTfProperty * >(* OdTfPropertiesConstructorType)(OdTfClass *)
Definition: TfObject.h:347
OdTfProperty::owner
virtual OdTfClass * owner() const =0
OdTfAttribute::name
virtual OdString name() const =0
RxObject.h
OdTfObject::addPersistentReactor
virtual void addPersistentReactor(OdTfPersistentReactor *)=0
TfVariant.h
OdTfPropertiesContainer::contains
virtual bool contains(const OdTfProperty *pProp) const =0
OdTfAttribute::value
virtual OdTfVariant value() const =0
index
GLuint index
Definition: gles2_ext.h:265
newOdTfAttribute
TFCORE_EXPORT OdTfAttribute * newOdTfAttribute(const OdString &name, OdRxObject *pOwner, const OdTfVariant &value)
OdTfAttribute::owner
virtual OdRxObject * owner() const =0
OdTfProperty::name
virtual OdString name() const =0
OdTfObject::getOwner
virtual const OdTfObject * getOwner() const =0
OdTfAttributesContainerPtr
OdSmartPtr< OdTfAttributesContainer > OdTfAttributesContainerPtr
Definition: TfObject.h:124
OdTfPropertiesContainer::find
virtual const OdTfProperty * find(const OdString &name) const =0
OdTfPersistentReactor
Definition: TfObjectReactor.h:255
OdRxClass
Definition: RxObject.h:865
OdTfObject::setProperty
virtual OdResult setProperty(const OdString &name, const OdTfVariant &value, const ItemIndexType arrayIndex=-1, const OdTfClass *pClass=NULL)=0
OdSmartPtr
Definition: SmartPtr.h:58
OdTfProperty::type
virtual OdTfVariant::Type type() const =0
OdTfObject
Definition: TfObject.h:204
ODTF_DECLARE_MEMBERS
#define ODTF_DECLARE_MEMBERS(ClassName)
Definition: TfObject.h:61
initOdTfClass
TFCORE_EXPORT OdTfClass * initOdTfClass(OdTfClass *pClass, const OdString &name, OdRxClass *pBaseClass, const OdArray< OdTfAttribute * > &attributes, const OdArray< OdTfProperty * > &properties, OdPseudoConstructorType pConstr, bool bRegister=true)
OdInt32
int OdInt32
Definition: OdPlatformSettings.h:782
OdTfAttributesContainer
Definition: TfObject.h:118
OdTfPropertiesContainer::size
virtual size_type size() const =0
OdTfObject::setProperty
virtual OdResult setProperty(const PropertyIndexType propertyIndex, const OdTfVariant &value, const ItemIndexType arrayIndex=-1)=0
OdTfObject::getProperty
virtual OdResult getProperty(const OdString &name, OdTfVariant &value, const ItemIndexType arrayIndex=-1, const OdTfClass *pClass=NULL) const =0
OdTfClass
Definition: TfObject.h:151
OdGiDrawable
Definition: GiDrawable.h:49
OdTfClass::attributes
virtual const OdTfAttributesContainerPtr attributes() const =0
OdTfPropertiesContainer
Definition: TfObject.h:127
OdTfPropertiesContainerPtr
OdSmartPtr< OdTfPropertiesContainer > OdTfPropertiesContainerPtr
Definition: TfObject.h:145
OdTfPropertiesContainer::index
virtual size_type index(const OdTfProperty *pProp) const =0
OdTfClass::allProperties
virtual const OdTfPropertiesContainerPtr allProperties() const =0
createOdTfProperty
TFCORE_EXPORT OdTfProperty * createOdTfProperty()
TD_PackPush.h
OdArray::size_type
A::size_type size_type
Definition: OdArray.h:593
OdTfObjectPtr
OdSmartPtr< OdTfObject > OdTfObjectPtr
Definition: TfObject.h:341
OdTfObject::hasPersistentReactor
virtual bool hasPersistentReactor(OdTfPersistentReactor *) const =0
OdTfVariant::Type
Type
Definition: TfVariant.h:44
ODRX_ABSTRACT
#define ODRX_ABSTRACT
Definition: OdPlatformSettings.h:117
OdTfVariantConstructorType
OdTfVariant(* OdTfVariantConstructorType)()
Definition: TfObject.h:353
OdTfAttributesContainer::owner
virtual OdRxObject * owner() const =0
OdTfPropertiesContainer::unique
virtual bool unique(const OdString &name, const OdTfVariant::Type type) const =0
OdTfProperty::defaultItemValue
virtual OdTfVariant defaultItemValue() const =0
OdTfObject::ItemIndexType
OdTfVariantArray::size_type ItemIndexType
Definition: TfObject.h:209
OdTfClass::tfParent
virtual OdTfClass * tfParent() const =0
OdTfObject::addReactor
virtual void addReactor(OdTfObjectReactor *pReactor)=0
OdTfObjectReactor
Definition: TfObjectReactor.h:47
GiDrawable.h
value
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
OdTfPropertiesContainer::unique
virtual bool unique(const OdString &name) const =0
OdTfPropertiesContainer::size_type
OdInt32 size_type
Definition: TfObject.h:130
OdTfPropertiesContainer::owner
virtual OdTfClass * owner() const =0
OdTfPropertiesContainer::iterator
virtual OdRxIteratorPtr iterator() const =0
initOdTfProperty
TFCORE_EXPORT OdTfProperty * initOdTfProperty(OdTfProperty *pProp, const OdString &name, OdTfClass *pOwner, OdTfVariant::Type type, const OdArray< OdTfAttribute * > &attributes, OdTfVariantConstructorType pDefaultValueConstructor, OdTfPropertyGetterType pGetter, OdTfPropertySetterType pSetter)
OdTfProperty::attributes
virtual OdTfAttributesContainerPtr attributes() const =0
OdTfObject::getProperty
virtual OdResult getProperty(const PropertyIndexType propertyIndex, OdTfVariant &value, const ItemIndexType arrayIndex=-1) const =0
OdTfObject::getTransientReactors
virtual void getTransientReactors(OdTfObjectReactorArray &reactors)=0
DbStubPtrArray.h
OdTfPropertyPtr
OdSmartPtr< OdTfProperty > OdTfPropertyPtr
Definition: TfObject.h:185
OdTfPropertySetterType
OdResult(* OdTfPropertySetterType)(OdTfObject *, const OdTfVariant &)
Definition: TfObject.h:351
newOdTfClass
TFCORE_EXPORT OdTfClass * newOdTfClass(const OdString &name, OdRxClass *pBaseClass, OdTfAttributesConstructorType pAttrsConstr, OdTfPropertiesConstructorType pPropsConstr, OdPseudoConstructorType pConstr, bool bRegister=true)
OdRxClass::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdRxClass)
ODRX_DECLARE_MEMBERS
#define ODRX_DECLARE_MEMBERS(ClassName)
Definition: RxObject.h:112
OdTfProperty::setValue
virtual OdResult setValue(OdTfObject *pObject, const OdTfVariant &value) const =0
OdTfAttributesContainer::find
virtual const OdTfAttribute * find(const OdString &name) const =0
newOdTfProperty
TFCORE_EXPORT OdTfProperty * newOdTfProperty(const OdString &name, OdTfClass *pOwner, OdTfVariant::Type type, OdTfAttributesConstructorType pAttrsConstr, OdTfVariantConstructorType pDefaultValueConstructor, OdTfPropertyGetterType pGetter, OdTfPropertySetterType pSetter)
OdTfObject::getProperty
virtual OdResult getProperty(const OdTfProperty *pPI, OdTfVariant &value, const ItemIndexType arrayIndex=-1) const =0
OdPseudoConstructorType
OdRxObjectPtr(* OdPseudoConstructorType)()
Definition: RxObject.h:849