CFx SDK Documentation  2022 SP0
daiAggr.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 _DAI_AGGR_H
25 #define _DAI_AGGR_H
26 
27 #include "OdPlatformSettings.h"
28 #include "OdaCommon.h"
29 #include "RxObject.h"
30 #include "RxObjectImpl.h"
31 #include "SharedPtr.h"
32 
33 #include "daiBuildOptions.h"
34 #include "daiObjectId.h"
35 #include "daiIterator.h"
36 
37 namespace OdDAI {
38 
40  {
41  public:
42 
43  virtual ~AggrInstance() {};
44  virtual IteratorPtr createIterator() const = 0;
45  virtual const OdRxValueType& type() const = 0;
46  virtual int size() const = 0;
47  virtual AggrInstance* duplicate() const = 0;
48  };
49 
50  template<class T>
52  {
53  OdArray<T> m_arr;
54 
55  AggrInstanceTyped(const OdArray<T> &arr) { m_arr = arr; };
56 
57  public:
58 
63 
67  const OdArray<T>& getArray() const
68  {
69  return m_arr;
70  }
71 
72  void operator = (const OdArray<T> &rhs) { m_arr = rhs; };
73 
74  operator OdArray<T>& () { return m_arr; }
75 
76  operator const OdArray<T>& () { return m_arr; }
77 
81  virtual IteratorPtr createIterator() const {
82  IteratorPtr pIter = new IteratorArr<T>(m_arr);
83  return pIter;
84  }
85 
89  virtual const OdRxValueType& type() const {
91  }
92 
96  virtual int size() const {
97  return m_arr.size();
98  }
99 
103  virtual AggrInstance* duplicate() const {
104  return new AggrInstanceTyped<T>(m_arr);
105  };
106 
107  };
108 
109 
110 
112  {
113  public:
114 
119 
125 
130  bool isNil() const {
131  return (m_pInst == NULL);
132  }
133 
137  unsigned long length() const;
138 
139  //DOM-IGNORE-BEGIN
140 
146  return m_pInst;
147  }
148 
149  protected:
150 
152 
154  : m_pInst(NULL)
155  {}
156 
157  AggrBase(const AggrBase& other)
158  : m_pInst(NULL)
159  {
160  if (other.m_pInst)
161  {
162  m_pInst = other.m_pInst->duplicate();
163  }
164  }
165 
166  //DOM-IGNORE-END
167 
168  };
169 
170  template<class T>
171  class DAI_EXPORT Aggr : public AggrBase
172  {
173  public:
174 
175  Aggr<T>& operator = (const OdArray<T> &rhs)
176  {
177  delete m_pInst;
178  if (rhs.size() == 0)
179  {
180  m_pInst = NULL;
181  return *this;
182  }
183  init(rhs);
184  return *this;
185  };
186 
187  operator OdArray<T> () const
188  {
189  return getArray();
190  }
191 
196  {
197  if (m_pInst)
198  {
199  AggrInstanceTyped<T> *pTyped = dynamic_cast<AggrInstanceTyped<T>*>(m_pInst);
200  if (pTyped)
201  return pTyped->getArray();
202  }
203  return OdArray<T>();
204  }
205 
206  protected:
207 
208  void init(const OdArray<T> &arr)
209  {
211  *pInst = arr;
212  m_pInst = pInst;
213  }
214  };
215 
218 
221 
224 
227 
228 }
229 
230 #endif // _DAI_DICTIONARY_INSTANCE_H
GE_TOOLKIT_EXPORT OdGeDoubleArray & getArray(OdGeKnotVector *p)
#define NULL
Definition: GsProperties.h:177
size_type size() const
Definition: OdArray.h:893
unsigned long length() const
AggrInstance * instance()
Definition: daiAggr.h:145
IteratorPtr createIterator() const
bool isNil() const
Definition: daiAggr.h:130
AggrBase(const AggrBase &other)
Definition: daiAggr.h:157
AggrInstance * m_pInst
Definition: daiAggr.h:151
OdArray< T > getArray() const
Definition: daiAggr.h:195
void init(const OdArray< T > &arr)
Definition: daiAggr.h:208
virtual int size() const =0
virtual const OdRxValueType & type() const =0
virtual IteratorPtr createIterator() const =0
virtual AggrInstance * duplicate() const =0
virtual ~AggrInstance()
Definition: daiAggr.h:43
virtual IteratorPtr createIterator() const
Definition: daiAggr.h:81
const OdArray< T > & getArray() const
Definition: daiAggr.h:67
virtual int size() const
Definition: daiAggr.h:96
virtual AggrInstance * duplicate() const
Definition: daiAggr.h:103
virtual const OdRxValueType & type() const
Definition: daiAggr.h:89
#define DAI_EXPORT
OdSharedPtr< DoubleAggr > DoubleAggrPtr
Definition: daiAggr.h:220
Aggr< bool > BoolAggr
Definition: daiAggr.h:216
Aggr< int > IntAggr
Definition: daiAggr.h:222
Aggr< OdDAIObjectId > OdDAIObjectIdAggr
Definition: daiAggr.h:225
OdSharedPtr< OdDAIObjectIdAggr > OdDAIObjectIdAggrPtr
Definition: daiAggr.h:226
Aggr< double > DoubleAggr
Definition: daiAggr.h:219
OdSharedPtr< BoolAggr > BoolAggrPtr
Definition: daiAggr.h:217
OdSharedPtr< IntAggr > IntAggrPtr
Definition: daiAggr.h:223
static const OdRxValueType & value()