CFx SDK Documentation  2022 SP0
RxMultiCast.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 _ODRXMULTICAST_H_
25 #define _ODRXMULTICAST_H_
26 
27 #include "RxObject.h"
28 
29 #include "TD_PackPush.h"
30 
54 inline // Returns count of available casts, pPointers must be non-zero
55 OdUInt32 odrxMultiCast(const OdRxObject *pObject, OdRxObjectPtr *pPointers, const OdRxClass **pClasses, OdUInt32 nClasses)
56 {
57  OdUInt32 nCasts = 0;
58  if (!pObject || !pPointers || !pClasses || !nClasses)
59  return nCasts;
60  OdRxClass *pClass = pObject->isA();
61  while (pClass)
62  {
63  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
64  {
65  if (pPointers[nClass].isNull())
66  {
67  if (pClass == pClasses[nClass])
68  {
69  pPointers[nClass] = pObject;
70  nCasts++;
71  if (nCasts == nClasses)
72  return nCasts;
73  }
74  else
75  {
76  pPointers[nClass] = pClass->getX(pClasses[nClass]);
77  if (!pPointers[nClass].isNull())
78  {
79  nCasts++;
80  if (nCasts == nClasses)
81  return nCasts;
82  }
83  }
84  }
85  }
86  pClass = pClass->myParent();
87  }
88  return nCasts;
89 }
90 
91 inline // If pCasts null returns bit mask, elsewhere count of casts
92 OdUInt32 odrxMultiCastObject(const OdRxObject *pObject, bool *pCasts, const OdRxClass **pClasses, OdUInt32 nClasses)
93 {
94  OdUInt32 nCasts = 0, nBits = 0;
95  if (!pObject || !pClasses || !nClasses)
96  return nCasts;
97  OdRxClass *pClass = pObject->isA();
98  while (pClass)
99  {
100  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
101  {
102  if ((pCasts) ? !pCasts[nClass] : ((nBits & (1 << nClass)) == 0))
103  {
104  if (pClass == pClasses[nClass])
105  {
106  if (pCasts)
107  pCasts[nClass] = true;
108  else
109  nBits |= 1 << nClass;
110  nCasts++;
111  if (nCasts == nClasses)
112  return nCasts;
113  }
114  }
115  }
116  pClass = pClass->myParent();
117  }
118  return (pCasts) ? nCasts : nBits;
119 }
120 
121 inline // Returns count of available casts, pPointers must be non-zero
122 OdUInt32 odrxMultiCastX(const OdRxObject *pObject, OdRxObjectPtr *pPointers, const OdRxClass **pClasses, OdUInt32 nClasses)
123 {
124  OdUInt32 nCasts = 0;
125  if (!pObject || !pPointers || !pClasses || !nClasses)
126  return nCasts;
127  OdRxClass *pClass = pObject->isA();
128  while (pClass)
129  {
130  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
131  {
132  if (pPointers[nClass].isNull())
133  {
134  pPointers[nClass] = pClass->getX(pClasses[nClass]);
135  if (!pPointers[nClass].isNull())
136  {
137  nCasts++;
138  if (nCasts == nClasses)
139  return nCasts;
140  }
141  }
142  }
143  pClass = pClass->myParent();
144  }
145  return nCasts;
146 }
147 
148 inline
149 OdUInt32 odrxMultiCastFwd_(OdRxClass *pClass, const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
150 {
151  OdRxClass *pParent = pClass->myParent();
152  if (pParent)
153  {
154  OdUInt32 nIndex = odrxMultiCastFwd_(pParent, pObject, pPointer, pClasses, nClasses);
155  if (nIndex < nClasses)
156  return nIndex;
157  }
158  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
159  {
160  if (pClass == pClasses[nClass])
161  {
162  pPointer = pObject;
163  return nClass;
164  }
165  else
166  {
167  pPointer = pClass->getX(pClasses[nClass]);
168  if (!pPointer.isNull())
169  return nClass;
170  }
171  }
172  return nClasses;
173 }
174 inline
175 OdUInt32 odrxMultiCastFwd(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
176 {
177  if (!pObject || !pClasses || !nClasses)
178  return nClasses;
179  OdRxClass *pClass = pObject->isA();
180  return odrxMultiCastFwd_(pClass, pObject, pPointer, pClasses, nClasses);
181 }
182 
183 inline
184 OdUInt32 odrxMultiCastFwdXPrior_(OdRxClass *pClass, const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
185 {
186  OdRxClass *pParent = pClass->myParent();
187  if (pParent)
188  {
189  OdUInt32 nIndex = odrxMultiCastFwdXPrior_(pParent, pObject, pPointer, pClasses, nClasses);
190  if (nIndex < nClasses)
191  return nIndex;
192  }
193  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
194  {
195  pPointer = pClass->getX(pClasses[nClass]);
196  if (!pPointer.isNull())
197  return nClass;
198  if (pClass == pClasses[nClass])
199  {
200  pPointer = pObject;
201  return nClass;
202  }
203  }
204  return nClasses;
205 }
206 inline
207 OdUInt32 odrxMultiCastFwdXPrior(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
208 {
209  if (!pObject || !pClasses || !nClasses)
210  return nClasses;
211  OdRxClass *pClass = pObject->isA();
212  return odrxMultiCastFwdXPrior_(pClass, pObject, pPointer, pClasses, nClasses);
213 }
214 
215 inline
216 OdUInt32 odrxMultiCastFwdObject_(OdRxClass *pClass, const OdRxObject *pObject, const OdRxClass **pClasses, OdUInt32 nClasses)
217 {
218  OdRxClass *pParent = pClass->myParent();
219  if (pParent)
220  {
221  OdUInt32 nIndex = odrxMultiCastFwdObject_(pParent, pObject, pClasses, nClasses);
222  if (nIndex < nClasses)
223  return nIndex;
224  }
225  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
226  {
227  if (pClass == pClasses[nClass])
228  return nClass;
229  }
230  return nClasses;
231 }
232 inline
233 OdUInt32 odrxMultiCastFwdObject(const OdRxObject *pObject, const OdRxClass **pClasses, OdUInt32 nClasses)
234 {
235  if (!pObject || !pClasses || !nClasses)
236  return nClasses;
237  OdRxClass *pClass = pObject->isA();
238  return odrxMultiCastFwdObject_(pClass, pObject, pClasses, nClasses);
239 }
240 
241 inline
242 OdUInt32 odrxMultiCastFwdX_(OdRxClass *pClass, const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
243 {
244  OdRxClass *pParent = pClass->myParent();
245  if (pParent)
246  {
247  OdUInt32 nIndex = odrxMultiCastFwdX_(pParent, pObject, pPointer, pClasses, nClasses);
248  if (nIndex < nClasses)
249  return nIndex;
250  }
251  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
252  {
253  pPointer = pClass->getX(pClasses[nClass]);
254  if (!pPointer.isNull())
255  return nClass;
256  }
257  return nClasses;
258 }
259 inline
260 OdUInt32 odrxMultiCastFwdX(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
261 {
262  if (!pObject || !pClasses || !nClasses)
263  return nClasses;
264  OdRxClass *pClass = pObject->isA();
265  return odrxMultiCastFwdX_(pClass, pObject, pPointer, pClasses, nClasses);
266 }
267 
268 inline
269 OdUInt32 odrxMultiCastBk(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
270 {
271  if (!pObject || !pClasses || !nClasses)
272  return nClasses;
273  OdRxClass *pClass = pObject->isA();
274  while (pClass)
275  {
276  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
277  {
278  if (pClass == pClasses[nClass])
279  {
280  pPointer = pObject;
281  return nClass;
282  }
283  else
284  {
285  pPointer = pClass->getX(pClasses[nClass]);
286  if (!pPointer.isNull())
287  return nClass;
288  }
289  }
290  pClass = pClass->myParent();
291  }
292  return nClasses;
293 }
294 
295 inline
296 OdUInt32 odrxMultiCastBkXPrior(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
297 {
298  if (!pObject || !pClasses || !nClasses)
299  return nClasses;
300  OdRxClass *pClass = pObject->isA();
301  while (pClass)
302  {
303  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
304  {
305  pPointer = pClass->getX(pClasses[nClass]);
306  if (!pPointer.isNull())
307  return nClass;
308  if (pClass == pClasses[nClass])
309  {
310  pPointer = pObject;
311  return nClass;
312  }
313  }
314  pClass = pClass->myParent();
315  }
316  return nClasses;
317 }
318 
319 inline
320 OdUInt32 odrxMultiCastBkObject(const OdRxObject *pObject, const OdRxClass **pClasses, OdUInt32 nClasses)
321 {
322  if (!pObject || !pClasses || !nClasses)
323  return nClasses;
324  OdRxClass *pClass = pObject->isA();
325  while (pClass)
326  {
327  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
328  {
329  if (pClass == pClasses[nClass])
330  return nClass;
331  }
332  pClass = pClass->myParent();
333  }
334  return nClasses;
335 }
336 
337 inline
338 OdUInt32 odrxMultiCastBkX(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
339 {
340  if (!pObject || !pClasses || !nClasses)
341  return nClasses;
342  OdRxClass *pClass = pObject->isA();
343  while (pClass)
344  {
345  for (OdUInt32 nClass = 0; nClass < nClasses; nClass++)
346  {
347  pPointer = pClass->getX(pClasses[nClass]);
348  if (!pPointer.isNull())
349  return nClass;
350  }
351  pClass = pClass->myParent();
352  }
353  return nClasses;
354 }
355 
356 #include "TD_PackPop.h"
357 
358 #endif // _ODRXMULTICAST_H_
unsigned int OdUInt32
OdUInt32 odrxMultiCastFwdObject(const OdRxObject *pObject, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:233
OdUInt32 odrxMultiCastFwd_(OdRxClass *pClass, const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:149
OdUInt32 odrxMultiCastFwdXPrior_(OdRxClass *pClass, const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:184
OdUInt32 odrxMultiCastBk(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:269
OdUInt32 odrxMultiCastX(const OdRxObject *pObject, OdRxObjectPtr *pPointers, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:122
OdUInt32 odrxMultiCastBkXPrior(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:296
OdUInt32 odrxMultiCastBkObject(const OdRxObject *pObject, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:320
OdUInt32 odrxMultiCast(const OdRxObject *pObject, OdRxObjectPtr *pPointers, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:55
OdUInt32 odrxMultiCastFwdX_(OdRxClass *pClass, const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:242
OdUInt32 odrxMultiCastBkX(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:338
OdUInt32 odrxMultiCastFwd(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:175
OdUInt32 odrxMultiCastFwdObject_(OdRxClass *pClass, const OdRxObject *pObject, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:216
OdUInt32 odrxMultiCastObject(const OdRxObject *pObject, bool *pCasts, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:92
OdUInt32 odrxMultiCastFwdXPrior(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:207
OdUInt32 odrxMultiCastFwdX(const OdRxObject *pObject, OdRxObjectPtr &pPointer, const OdRxClass **pClasses, OdUInt32 nClasses)
Definition: RxMultiCast.h:260
bool isNull() const
Definition: BaseObjectPtr.h:70
virtual OdRxClass * myParent() const =0
virtual OdRxObjectPtr getX(const OdRxClass *pProtocolClass)
virtual OdRxClass * isA() const