CFx SDK Documentation  2020SP3
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__
FIRSTDLL_EXPORT
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
OdGiVariant::VariantType
VariantType
Definition: GiVariant.h:54
OdCmEntityColor
Definition: CmColorBase.h:68
OdGiVariant::set
void set(const OdCmEntityColor &value)
v1
GLfloat GLfloat v1
Definition: gles2_ext.h:295
OdString
Definition: OdString.h:95
OdUInt8
unsigned char OdUInt8
Definition: OdPlatformSettings.h:759
OdGiVariant::EnumType::m_value
int m_value
Definition: GiVariant.h:72
OdGiVariant::kColor
@ kColor
Definition: GiVariant.h:59
OdGiVariant::getElem
bool getElem(const OdString &elem, OdGiVariant &value) const
OdRxObject
Definition: RxObject.h:564
OdGiVariant::set
void set(OdInt32 value)
v2
GLfloat GLfloat GLfloat v2
Definition: gles2_ext.h:296
OdGiVariant::type
VariantType type() const
OdGiVariant::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGiVariant)
TD_PackPop.h
OdGiVariant::asColor
const OdCmEntityColor & asColor() const
OdUInt16
unsigned short OdUInt16
Definition: OdPlatformSettings.h:760
operator==
bool operator==(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:358
RxObject.h
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdInt16
short OdInt16
Definition: OdPlatformSettings.h:756
OdGiVariant::asShort
OdInt16 asShort() const
OdGiVariant::~OdGiVariant
~OdGiVariant()
OdGiVariant::kBoolean
@ kBoolean
Definition: GiVariant.h:56
OdGiVariant::kString
@ kString
Definition: GiVariant.h:60
OdGiVariant
Definition: GiVariant.h:47
OdGiVariant::asUint
OdUInt32 asUint() const
RootExport.h
OdGiVariant::set
void set(double value)
OdGiVariant::asInt
OdInt32 asInt() const
OdSmartPtr< OdGiVariant >
OdGiVariant::asUlong
OdUInt32 asUlong() const
OdGiVariant::set
void set(const OdChar *value)
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(const OdString &value)
OdInt32
int OdInt32
Definition: OdPlatformSettings.h:782
OdGiVariant::getElemCount
OdInt32 getElemCount() const
operator!=
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:364
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(const OdChar *value)
OdGiVariantPtr
OdSmartPtr< OdGiVariant > OdGiVariantPtr
Definition: GiVariant.h:374
OdGiVariant::asString
const OdString & asString() const
OdChar
wchar_t OdChar
Definition: OdPlatformSettings.h:745
OdGiVariant::asDouble
double asDouble() const
OdGiVariant::getElemAt
const OdGiVariant * getElemAt(OdInt32 nElem, OdString &elem) const
OdGiVariant::isEquivalent
static bool isEquivalent(const OdGiVariant *v1, const OdGiVariant *v2)
CmColorBase.h
OdVariant
Definition: RxVariant.h:68
TD_PackPush.h
OdGiVariant::asBoolean
bool asBoolean() const
OdGiVariant::set
void set(bool value)
OdGiVariant::EnumType::EnumType
EnumType(int value)
Definition: GiVariant.h:67
OdInt8
signed char OdInt8
Definition: OdPlatformSettings.h:755
OdGiVariant::kDouble
@ kDouble
Definition: GiVariant.h:58
OdGiVariant::asLong
OdInt32 asLong() const
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(bool value)
OdGiVariant::set
void set(const OdString &value)
OdGiVariant::asFloat
float asFloat() const
OdGiVariant::getElemAt
bool getElemAt(OdInt32 nElem, OdString &elem, OdGiVariant &value) const
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(const OdGiVariant &value)
GiExport.h
OdGiVariant::EnumType
Definition: GiVariant.h:65
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(const OdCmEntityColor &value)
value
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
OdGiVariant::setElem
void setElem(const OdString &elem, const OdGiVariant &value)
OdGiVariant::asUshort
OdUInt16 asUshort() const
OdGiVariant::asChar
OdInt8 asChar() const
OdGiVariant::getElem
const OdGiVariant * getElem(const OdString &elem) const
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(OdInt32 value)
OdGiVariant::createObject
static OdSmartPtr< OdGiVariant > createObject(double value)
OdGiVariant::OdGiVariant
OdGiVariant()
OdGiVariant::asEnum
EnumType asEnum() const
OdGiVariant::deleteElem
void deleteElem(const OdString &elem)
OdGiVariant::asUchar
OdUInt8 asUchar() const
OdGiVariant::kInt
@ kInt
Definition: GiVariant.h:57
RxVariant.h
OdGiVariant::copyFrom
virtual void copyFrom(const OdRxObject *pSource)