CFx SDK Documentation  2023 SP0
GiVariant.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 // OdGiVariant type for generic procedural material.
25 
26 #ifndef __ODGIVARIANT_H__
27 #define __ODGIVARIANT_H__
28 
29 #include "RootExport.h"
30 #include "GiExport.h"
31 
32 #include "CmColorBase.h"
33 #include "RxVariant.h"
34 #include "RxObject.h"
35 
36 #include "TD_PackPush.h"
37 
47 {
48  static void copyDataFrom(OdGiVariant &vTo, const OdGiVariant &vFrom);
49  public:
54  {
55  kUndefined = 0, // Variant type is undefined (the default type).
56  kBoolean, // An OdGiVariant is of a boolean type (bool).
57  kInt, // An OdGiVariant is of a long type (OdInt32).
58  kDouble, // An OdGiVariant is of a double type (double).
59  kColor, // An OdGiVariant is of a color type (OdCmEntityColor).
60  kString, // An OdGiVariant is of a string type (OdString).
61  kTable // An OdGiVariant is a table of key/value pairs.
62  };
63  public:
64  class EnumType
65  {
66  public:
67  explicit EnumType(int value) : m_value(value) { }
68  template <typename T> operator T() { return static_cast<T>(m_value); }
69  template <typename T> bool operator ==(T right) const { return static_cast<int>(right) == m_value; }
70  template <typename T> bool operator !=(T right) const { return !(*this == right); }
71  protected:
72  int m_value;
73  };
74  public:
76 
77  // Constructors
78  //OdGiVariant();
79  //OdGiVariant(const OdGiVariant &value);
80  //OdGiVariant(bool value);
81  //OdGiVariant(OdInt32 value);
82  //OdGiVariant(double value);
83  //OdGiVariant(const OdCmEntityColor &value);
84  //OdGiVariant(const OdString &value);
85  //OdGiVariant(const OdChar *value);
86  protected:
88  public:
95 
102 
109 
116 
123 
130 
137 
139 
140  bool operator ==(const OdGiVariant& value) const;
141 
142  OdGiVariant &operator =(const OdGiVariant& value);
143 
156  virtual void copyFrom(const OdRxObject* pSource);
157 
161  VariantType type() const;
162 
168  void set(bool value);
169 
176 
182  void set(double value);
183 
189  void set(const OdCmEntityColor &value);
190 
196  void set(const OdString &value);
197 
203  void set(const OdChar *value);
204 
208  bool asBoolean() const;
209 
213  OdInt32 asInt() const;
214 
218  double asDouble() const;
219 
223  const OdCmEntityColor &asColor() const;
224 
228  const OdString &asString() const;
229 
233  float asFloat() const;
234 
238  OdInt8 asChar() const;
239 
243  OdUInt8 asUchar() const;
244 
248  OdInt16 asShort() const;
249 
254 
258  OdUInt32 asUint() const;
259 
263  OdInt32 asLong() const;
264 
268  OdUInt32 asUlong() const;
269 
273  EnumType asEnum() const;
274 
284  bool getElem(const OdString &elem, OdGiVariant &value) const;
285 
294  const OdGiVariant *getElem(const OdString &elem) const;
295 
302  void setElem(const OdString &elem, const OdGiVariant &value);
303 
309  void deleteElem(const OdString &elem);
310 
315 
327  bool getElemAt(OdInt32 nElem, OdString &elem, OdGiVariant &value) const;
328 
338  const OdGiVariant *getElemAt(OdInt32 nElem, OdString &elem) const;
339 
351  static bool isEquivalent(const OdGiVariant *v1, const OdGiVariant *v2);
352  private:
353  VariantType m_type;
354  OdVariant m_variant;
355 };
356 
357 template <typename T>
358 inline bool operator ==(T left, const OdGiVariant::EnumType right)
359 {
360  return (right == left);
361 }
362 
363 template <typename T>
364 inline bool operator !=(T left, const OdGiVariant::EnumType right)
365 {
366  return (right != left);
367 }
368 
375 
376 #include "TD_PackPop.h"
377 
378 #endif // __ODGIVARIANT_H__
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:364
OdSmartPtr< OdGiVariant > OdGiVariantPtr
Definition: GiVariant.h:374
bool operator==(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:358
unsigned int OdUInt32
short OdInt16
signed char OdInt8
unsigned short OdUInt16
int OdInt32
unsigned char OdUInt8
wchar_t OdChar
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
EnumType(int value)
Definition: GiVariant.h:67
OdUInt32 asUlong() const
static OdSmartPtr< OdGiVariant > createObject(const OdCmEntityColor &value)
static bool isEquivalent(const OdGiVariant *v1, const OdGiVariant *v2)
const OdString & asString() const
void set(OdInt32 value)
ODRX_DECLARE_MEMBERS(OdGiVariant)
float asFloat() const
OdInt8 asChar() const
VariantType type() const
OdInt16 asShort() const
OdUInt32 asUint() const
void set(const OdString &value)
void setElem(const OdString &elem, const OdGiVariant &value)
bool getElemAt(OdInt32 nElem, OdString &elem, OdGiVariant &value) const
OdInt32 asLong() const
static OdSmartPtr< OdGiVariant > createObject(double value)
const OdGiVariant * getElemAt(OdInt32 nElem, OdString &elem) const
void set(bool value)
static OdSmartPtr< OdGiVariant > createObject(const OdGiVariant &value)
const OdCmEntityColor & asColor() const
const OdGiVariant * getElem(const OdString &elem) const
EnumType asEnum() const
bool asBoolean() const
void set(const OdCmEntityColor &value)
void set(const OdChar *value)
static OdSmartPtr< OdGiVariant > createObject(bool value)
void set(double value)
OdUInt16 asUshort() const
static OdSmartPtr< OdGiVariant > createObject(const OdString &value)
static OdSmartPtr< OdGiVariant > createObject(OdInt32 value)
double asDouble() const
static OdSmartPtr< OdGiVariant > createObject(const OdChar *value)
bool getElem(const OdString &elem, OdGiVariant &value) const
OdInt32 getElemCount() const
OdUInt8 asUchar() const
void deleteElem(const OdString &elem)
OdInt32 asInt() const
virtual void copyFrom(const OdRxObject *pSource)
GLfloat GLfloat v1
Definition: gles2_ext.h:295
GLfloat GLfloat GLfloat v2
Definition: gles2_ext.h:296
GLsizei const GLfloat * value
Definition: gles2_ext.h:302