ExchangeWrapper.h
1 // Copyright (c) Tech Soft 3D
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 #pragma once
11 
12 
13 namespace Query
14 {
15 
16  template <typename Type, typename TypeData>
18  {
19  public:
20  typedef A3DStatus(*PGetFunction)(Type const *, TypeData *);
21 
23  Type * entity,
24  PGetFunction getter)
25  : entity(entity)
26  , getter(getter)
27  , valid(false)
28  {}
29 
31  ExchangePointerObject && that)
32  {
33  *this = that;
34 
35  that.valid = false;
36  that.entity = nullptr;
37  that.memset(&data, 0, sizeof(data));
38  that.getter = nullptr;
39  }
40 
41  virtual ~ExchangePointerObject()
42  {
43  if (valid)
44  getter(nullptr, &data);
45  }
46 
47  ExchangePointerObject & operator=(
48  ExchangePointerObject && that)
49  {
50  *this = that;
51 
52  that.valid = false;
53  that.entity = nullptr;
54  that.memset(&data, 0, sizeof(data));
55  that.getter = nullptr;
56 
57  return *this;
58  }
59 
60  operator Type *() const { return entity; }
61 
62  TypeData const * operator->() const { return &data; }
63  TypeData * operator->() { return &data; }
64 
65  bool IsValid() const { return valid; }
66 
67  TypeData data;
68 
69  private:
70  bool valid;
71  Type * entity;
72  PGetFunction getter;
73 
74  protected:
75  void getData()
76  {
77  A3DStatus status = getter(entity, &data);
78  valid = (status == A3D_SUCCESS);
79  }
80 
81  private:
84  ExchangePointerObject & operator=(ExchangePointerObject const &) = default;
85  };
86 
87  template <typename Type, typename TypeData>
89  {
90  public:
91  typedef A3DStatus(*PGetFunction)(Type, TypeData *);
93  Type index,
94  PGetFunction getter)
95  : index(index)
96  , getter(getter)
97  , valid(false)
98  {}
99 
101  ExchangeIndexObject && that)
102  {
103  *this = that;
104 
105  that.valid = false;
106  that.index = (Type)-1;
107  that.memset(&data, 0, sizeof(data));
108  that.getter = nullptr;
109  }
110 
111  virtual ~ExchangeIndexObject()
112  {
113  if (valid)
114  getter((Type)-1, &data);
115  }
116 
117  ExchangeIndexObject & operator=(
118  ExchangeIndexObject && that)
119  {
120  *this = that;
121 
122  that.valid = false;
123  that.index = (Type)-1;
124  that.memset(&data, 0, sizeof(data));
125  that.getter = nullptr;
126 
127  return *this;
128  }
129 
130  operator Type () const { return index; }
131 
132  TypeData const * operator->() const { return &data; }
133  TypeData * operator->() { return &data; }
134 
135  bool IsValid() const { return valid; }
136 
137  TypeData data;
138 
139  private:
140  bool valid;
141  Type index;
142  PGetFunction getter;
143 
144  protected:
145  void getData()
146  {
147  A3DStatus status = getter(index, &data);
148  valid = (status == A3D_SUCCESS);
149  }
150 
151  private:
154  ExchangeIndexObject & operator=(ExchangeIndexObject const &) = default;
155  };
156 
159  {
160  public:
161  DrawingModel(
162  A3DDrawingModel * entity)
163  : BaseDrawingModel(entity, A3DDrawingModelGet)
164  {
165  A3D_INITIALIZE_DATA(A3DDrawingModelData, data);
166  getData();
167  }
168  };
169 
172  {
173  public:
174  DrawingSheet(
175  A3DDrawingSheet * entity)
176  : BaseDrawingSheet(entity, A3DDrawingSheetGet)
177  {
178  A3D_INITIALIZE_DATA(A3DDrawingSheetData, data);
179  getData();
180  }
181  };
182 
184  class GraphStyle : public BaseGraphStyle
185  {
186  public:
187  GraphStyle(
188  A3DUns32 index)
189  : BaseGraphStyle(index, A3DGlobalGetGraphStyleData)
190  {
191  A3D_INITIALIZE_DATA(A3DGraphStyleData, data);
192  if (index != A3D_DEFAULT_STYLE_INDEX)
193  getData();
194  }
195  };
196 
199  {
200  public:
202  A3DDrawingSheetFormat * entity)
203  : BaseDrawingSheetFormat(entity, A3DDrawingSheetFormatGet)
204  {
205  A3D_INITIALIZE_DATA(A3DDrawingSheetFormatData, data);
206  getData();
207  }
208  };
209 
212  {
213  public:
215  A3DDrawingBlockBasic * entity)
216  : BaseDrawingBlockBasic(entity, A3DDrawingBlockBasicGet)
217  {
218  A3D_INITIALIZE_DATA(A3DDrawingBlockBasicData, data);
219  getData();
220  }
221  };
222 
225  {
226  public:
228  A3DDrawingBlockOperator * entity)
229  : BaseDrawingBlockOperator(entity, A3DDrawingBlockOperatorGet)
230  {
231  A3D_INITIALIZE_DATA(A3DDrawingBlockOperatorData, data);
232  getData();
233  }
234  };
235 
238  {
239  public:
240  DrawingCurve(
241  A3DDrawingCurve * entity)
242  : BaseDrawingCurve(entity, A3DDrawingCurveGet)
243  {
244  A3D_INITIALIZE_DATA(A3DDrawingCurveData, data);
245  getData();
246  }
247  };
248 
251  {
252  public:
254  A3DDrawingFilledArea * entity)
255  : BaseDrawingFilledArea(entity, A3DDrawingFilledAreaGet)
256  {
257  A3D_INITIALIZE_DATA(A3DDrawingFilledAreaData, data);
258  getData();
259  }
260  };
261 
264  {
265  public:
267  A3DDrawingPicture * entity)
268  : BaseDrawingPicture(entity, A3DDrawingPictureGet)
269  {
270  A3D_INITIALIZE_DATA(A3DDrawingPictureData, data);
271  getData();
272  }
273  };
274 
277  {
278  public:
280  A3DDrawingVertices * entity)
281  : BaseDrawingVertices(entity, A3DDrawingVerticesGet)
282  {
283  A3D_INITIALIZE_DATA(A3DDrawingVerticesData, data);
284  getData();
285  }
286  };
287 
290  {
291  public:
292  DrawingView(
293  A3DDrawingView * entity)
294  : BaseDrawingView(entity, A3DDrawingViewGet)
295  {
296  A3D_INITIALIZE_DATA(A3DDrawingViewData, data);
297  getData();
298  }
299  };
300 
303  {
304  public:
306  A3DDrawingClipFrame * entity)
307  : BaseDrawingClipFrame(entity, A3DDrawingClipFrameGet)
308  {
309  A3D_INITIALIZE_DATA(A3DDrawingClipFrameData, data);
310  getData();
311  }
312  };
313 
316  {
317  public:
319  A3DCrvBlend02Boundary * entity)
320  : BaseCrvBlend02Boundary(entity, A3DCrvBlend02BoundaryGet)
321  {
322  A3D_INITIALIZE_DATA(A3DCrvBlend02BoundaryData, data);
323  getData();
324  }
325  };
326 
328  class CrvCircle : public BaseCrvCircle
329  {
330  public:
331  CrvCircle(
332  A3DCrvCircle * entity)
333  : BaseCrvCircle(entity, A3DCrvCircleGet)
334  {
335  A3D_INITIALIZE_DATA(A3DCrvCircleData, data);
336  getData();
337  }
338  };
339 
342  {
343  public:
344  CrvComposite(
345  A3DCrvComposite * entity)
346  : BaseCrvComposite(entity, A3DCrvCompositeGet)
347  {
348  A3D_INITIALIZE_DATA(A3DCrvCompositeData, data);
349  getData();
350  }
351  };
352 
354  class CrvEllipse : public BaseCrvEllipse
355  {
356  public:
357  CrvEllipse(
358  A3DCrvEllipse * entity)
359  : BaseCrvEllipse(entity, A3DCrvEllipseGet)
360  {
361  A3D_INITIALIZE_DATA(A3DCrvEllipseData, data);
362  getData();
363  }
364  };
365 
367  class CrvHelix : public BaseCrvHelix
368  {
369  public:
370  CrvHelix(
371  A3DCrvHelix * entity)
372  : BaseCrvHelix(entity, A3DCrvHelixGet)
373  {
374  A3D_INITIALIZE_DATA(A3DCrvHelixData, data);
375  getData();
376  }
377  };
378 
381  {
382  public:
383  CrvHyperbola(
384  A3DCrvHyperbola * entity)
385  : BaseCrvHyperbola(entity, A3DCrvHyperbolaGet)
386  {
387  A3D_INITIALIZE_DATA(A3DCrvHyperbolaData, data);
388  getData();
389  }
390  };
391 
394  {
395  public:
397  A3DCrvIntersection * entity)
398  : BaseCrvIntersection(entity, A3DCrvIntersectionGet)
399  {
400  A3D_INITIALIZE_DATA(A3DCrvIntersectionData, data);
401  getData();
402  }
403  };
404 
406  class CrvLine : public BaseCrvLine
407  {
408  public:
409  CrvLine(
410  A3DCrvLine * entity)
411  : BaseCrvLine(entity, A3DCrvLineGet)
412  {
413  A3D_INITIALIZE_DATA(A3DCrvLineData, data);
414  getData();
415  }
416  };
417 
419  class CrvOffset : public BaseCrvOffset
420  {
421  public:
422  CrvOffset(
423  A3DCrvOffset * entity)
424  : BaseCrvOffset(entity, A3DCrvOffsetGet)
425  {
426  A3D_INITIALIZE_DATA(A3DCrvOffsetData, data);
427  getData();
428  }
429  };
430 
432  class CrvOnSurf : public BaseCrvOnSurf
433  {
434  public:
435  CrvOnSurf(
436  A3DCrvOnSurf * entity)
437  : BaseCrvOnSurf(entity, A3DCrvOnSurfGet)
438  {
439  A3D_INITIALIZE_DATA(A3DCrvOnSurfData, data);
440  getData();
441  }
442  };
443 
446  {
447  public:
448  CrvParabola(
449  A3DCrvParabola * entity)
450  : BaseCrvParabola(entity, A3DCrvParabolaGet)
451  {
452  A3D_INITIALIZE_DATA(A3DCrvParabolaData, data);
453  getData();
454  }
455  };
456 
459  {
460  public:
461  CrvPolyLine(
462  A3DCrvPolyLine * entity)
463  : BaseCrvPolyLine(entity, A3DCrvPolyLineGet)
464  {
465  A3D_INITIALIZE_DATA(A3DCrvPolyLineData, data);
466  getData();
467  }
468  };
469 
472  {
473  public:
474  CrvTransform(
475  A3DCrvTransform * entity)
476  : BaseCrvTransform(entity, A3DCrvTransformGet)
477  {
478  A3D_INITIALIZE_DATA(A3DCrvTransformData, data);
479  getData();
480  }
481  };
482 
484  class TessBase : public BaseTessBase
485  {
486  public:
487  TessBase(
488  A3DTessBase * entity)
489  : BaseTessBase(entity, A3DTessBaseGet)
490  {
491  A3D_INITIALIZE_DATA(A3DTessBaseData, data);
492  getData();
493  }
494  };
495 
497  class Tess3DWire : public BaseTess3DWire
498  {
499  public:
500  Tess3DWire(
501  A3DTess3DWire * entity)
502  : BaseTess3DWire(entity, A3DTess3DWireGet)
503  {
504  A3D_INITIALIZE_DATA(A3DTess3DWireData, data);
505  getData();
506  }
507  };
508 
510  class TessMarkup : public BaseTessMarkup
511  {
512  public:
513  TessMarkup(
514  A3DTessMarkup * entity)
515  : BaseTessMarkup(entity, A3DTessMarkupGet)
516  {
517  A3D_INITIALIZE_DATA(A3DTessMarkupData, data);
518  getData();
519  }
520  };
521 
524  {
525  public:
527  A3DRiRepresentationItem * entity)
528  : BaseRiRepresentationItem(entity, A3DRiRepresentationItemGet)
529  {
530  A3D_INITIALIZE_DATA(A3DRiRepresentationItemData, data);
531  getData();
532  }
533  };
534 
537  {
538  public:
540  A3DUns32 index)
541  : BaseGraphHatchingPattern(index, A3DGlobalGetGraphHatchingPatternData)
542  {
543  A3D_INITIALIZE_DATA(A3DGraphHatchingPatternData, data);
544  if (index != A3D_DEFAULT_PATTERN_INDEX)
545  getData();
546  }
547  };
548 
551  {
552  public:
553  AsmModelFile(
554  A3DAsmModelFile * entity)
555  : BaseAsmModelFile(entity, A3DAsmModelFileGet)
556  {
557  A3D_INITIALIZE_DATA(A3DAsmModelFileData, data);
558  getData();
559  }
560  };
561 
564  {
565  public:
567  A3DAsmProductOccurrence * entity)
568  : BaseAsmProductOccurrence(entity, A3DAsmProductOccurrenceGet)
569  {
570  A3D_INITIALIZE_DATA(A3DAsmProductOccurrenceData, data);
571  getData();
572  }
573  };
574 
577  {
578  public:
580  A3DAsmPartDefinition * entity)
581  : BaseAsmPartDefinition(entity, A3DAsmPartDefinitionGet)
582  {
583  A3D_INITIALIZE_DATA(A3DAsmPartDefinitionData, data);
584  getData();
585  }
586  };
587 
589  class RootBase : public BaseRootBase
590  {
591  public:
592  RootBase(
593  A3DRootBase * entity)
594  : BaseRootBase(entity, A3DRootBaseGet)
595  {
596  A3D_INITIALIZE_DATA(A3DRootBaseData, data);
597  getData();
598  }
599  };
600 
602  class MkpMarkup : public BaseMkpMarkup
603  {
604  public:
605  MkpMarkup(
606  A3DMkpMarkup * entity)
607  : BaseMkpMarkup(entity, A3DMkpMarkupGet)
608  {
609  A3D_INITIALIZE_DATA(A3DMkpMarkupData, data);
610  getData();
611  }
612  };
613 
616  {
617  public:
619  A3DMarkupRichText * entity)
620  : BaseMarkupRichText(entity, A3DMarkupRichTextGet)
621  {
622  A3D_INITIALIZE_DATA(A3DMarkupRichTextData, data);
623  getData();
624  }
625  };
626 
629  {
630  public:
632  A3DMarkupDefinition * entity)
633  : BaseMarkupDefinition(entity, A3DMarkupDefinitionGet)
634  {
635  A3D_INITIALIZE_DATA(A3DMarkupDefinitionData, data);
636  getData();
637  }
638  };
639 
642  {
643  public:
644  MDPosition2D(
645  A3DMDPosition2D * entity)
646  : BaseMDPosition2D(entity, A3DMDPosition2DGet)
647  {
648  A3D_INITIALIZE_DATA(A3DMDPosition2DData, data);
649  getData();
650  }
651  };
652 
655  {
656  public:
658  A3DUns32 index)
659  : BaseGraphLinePattern(index, A3DGlobalGetGraphLinePatternData)
660  {
661  A3D_INITIALIZE_DATA(A3DGraphLinePatternData, data);
662  if (index != A3D_DEFAULT_LINEPATTERN_INDEX)
663  getData();
664  }
665  };
666 
669  {
670  public:
671  GraphPicture(
672  A3DUns32 index)
673  : BaseGraphPicture(index, A3DGlobalGetGraphPictureData)
674  {
675  A3D_INITIALIZE_DATA(A3DGraphPictureData, data);
676  if (index != A3D_DEFAULT_PICTURE_INDEX)
677  getData();
678  }
679  };
680 
683  {
684  public:
686  A3DUns32 index)
687  : BaseGraphTextureDefinition(index, A3DGlobalGetGraphTextureDefinitionData)
688  {
689  A3D_INITIALIZE_DATA(A3DGraphTextureDefinitionData, data);
690  if (index != A3D_DEFAULT_TEXTURE_DEFINITION_INDEX)
691  getData();
692  }
693  };
694 
695 
697  {
698  public:
700  A3DRootBaseWithGraphics const * entity,
701  A3DMiscCascadedAttributes const * fatherAttr)
702  : entity(entity)
703  , attr(nullptr)
704  , validData(false)
705  {
706  A3D_INITIALIZE_DATA(A3DMiscCascadedAttributesData, data);
707 
708  A3DStatus status = A3DMiscCascadedAttributesCreate(&attr);
709  if (status == A3D_SUCCESS)
710  {
711  status = A3DMiscCascadedAttributesPush(attr, entity, fatherAttr);
712  if (status == A3D_SUCCESS)
713  {
714  status = A3DMiscCascadedAttributesGet(attr, &data);
715  validData = (status == A3D_SUCCESS);
716  }
717  }
718  }
719 
721  {
722  if (validData)
723  A3DMiscCascadedAttributesGet(nullptr, &data);
724  if (attr)
725  A3DMiscCascadedAttributesDelete(attr);
726  }
727 
728  operator A3DMiscCascadedAttributes *() const { return attr; }
729 
730  A3DMiscCascadedAttributesData const * operator->() const { return &data; }
731  A3DMiscCascadedAttributesData * operator->() { return &data; }
732 
733  bool IsValid() const { return attr != nullptr && validData; }
734 
735  A3DRootBaseWithGraphics const * entity;
736  A3DMiscCascadedAttributes * attr;
737  bool validData;
738  A3DMiscCascadedAttributesData data;
739  };
740 
741 }
Definition: ExchangeWrapper.h:198
Definition: ExchangeWrapper.h:315
Definition: ExchangeWrapper.h:682
Definition: ExchangeWrapper.h:523
Definition: ExchangeWrapper.h:302
Definition: ExchangeWrapper.h:184
Definition: ExchangeWrapper.h:17
Definition: ExchangeWrapper.h:550
Definition: ExchangeWrapper.h:615
Definition: ExchangeWrapper.h:380
Definition: ExchangeWrapper.h:250
Definition: ExchangeWrapper.h:367
Definition: ExchangeWrapper.h:289
Definition: ExchangeWrapper.h:328
Definition: ExchangeWrapper.h:445
Definition: ExchangeWrapper.h:341
Definition: ExchangeWrapper.h:393
Definition: ExchangeWrapper.h:628
Definition: ExchangeWrapper.h:432
Definition: ExchangeWrapper.h:696
Definition: ExchangeWrapper.h:589
Definition: ExchangeWrapper.h:171
Definition: ExchangeWrapper.h:668
Definition: ExchangeWrapper.h:576
Definition: ExchangeWrapper.h:276
Definition: ExchangeWrapper.h:237
Definition: ExchangeWrapper.h:88
Definition: ExchangeWrapper.h:536
Definition: ExchangeWrapper.h:406
Definition: ExchangeWrapper.h:654
Definition: ExchangeWrapper.h:158
Definition: ExchangeWrapper.h:263
Definition: ExchangeWrapper.h:471
Definition: ExchangeWrapper.h:563
Definition: ExchangeWrapper.h:354
Definition: ExchangeWrapper.h:224
Definition: ExchangeWrapper.h:510
Definition: ExchangeWrapper.h:458
Definition: ExchangeWrapper.h:211
Definition: ExchangeWrapper.h:497
Definition: ExchangeWrapper.h:13
Definition: ExchangeWrapper.h:602
Definition: ExchangeWrapper.h:641
Definition: ExchangeWrapper.h:419
Definition: ExchangeWrapper.h:484