11 #ifndef OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED 12 #define OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED 17 #include <type_traits> 31 template<
typename ValueT,
typename ChildT,
typename Enable =
void>
42 void setChild(ChildT* child) { mChild = child; }
44 const ValueT&
getValue()
const {
return mValue; }
46 void setValue(
const ValueT& val) { mValue = val; }
51 template<
typename ValueT,
typename ChildT>
52 class NodeUnion<ValueT, ChildT, typename
std::enable_if<std::is_pod<ValueT>::value>::type>
55 union { ChildT* mChild; ValueT
mValue; };
61 void setChild(ChildT* child) { mChild = child; }
63 const ValueT&
getValue()
const {
return mValue; }
65 void setValue(
const ValueT& val) { mValue = val; }
71 template<
typename ValueT,
typename ChildT>
72 class NodeUnion<ValueT, ChildT, typename
std::enable_if<CopyTraits<ValueT>::IsCopyable>::type>
75 union { ChildT* mChild; ValueT
mValue; };
80 { std::memcpy(static_cast<void*>(
this), &other,
sizeof(*
this)); }
82 { std::memcpy(static_cast<void*>(
this), &rhs,
sizeof(*
this));
return *
this; }
85 void setChild(ChildT* child) { mChild = child; }
87 const ValueT&
getValue()
const {
return mValue; }
89 void setValue(
const ValueT& val) { mValue = val; }
99 template<
typename T>
struct CopyTraits {
static const bool IsCopyable =
false; };
100 template<
typename T>
struct CopyTraits<math::Vec2<T>> {
static const bool IsCopyable =
true; };
101 template<
typename T>
struct CopyTraits<math::Vec3<T>> {
static const bool IsCopyable =
true; };
102 template<
typename T>
struct CopyTraits<math::Vec4<T>> {
static const bool IsCopyable =
true; };
103 template<>
struct CopyTraits<math::Coord> {
static const bool IsCopyable =
true; };
113 #endif // OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED Definition: NodeUnion.h:26
const ValueT & getValue() const
Definition: NodeUnion.h:63
ValueT & getValue()
Definition: NodeUnion.h:45
ChildT * getChild() const
Definition: NodeUnion.h:60
void setValue(const ValueT &val)
Definition: NodeUnion.h:65
void setChild(ChildT *child)
Definition: NodeUnion.h:85
ValueT & getValue()
Definition: NodeUnion.h:64
void setValue(const ValueT &val)
Definition: NodeUnion.h:46
ValueT & getValue()
Definition: NodeUnion.h:88
ChildT * getChild() const
Definition: NodeUnion.h:41
void setChild(ChildT *child)
Definition: NodeUnion.h:42
NodeUnion()
Definition: NodeUnion.h:39
NodeUnion()
Definition: NodeUnion.h:58
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
Definition: NodeUnion.h:32
void setValue(const ValueT &val)
Definition: NodeUnion.h:89
NodeUnion & operator=(const NodeUnion &rhs)
Definition: NodeUnion.h:81
const ValueT & getValue() const
Definition: NodeUnion.h:87
Definition: openvdb/Exceptions.h:13
NodeUnion()
Definition: NodeUnion.h:78
ChildT * getChild() const
Definition: NodeUnion.h:84
Library and file format version numbers.
void setChild(ChildT *child)
Definition: NodeUnion.h:61
ValueT mValue
Definition: NodeUnion.h:75
ValueT mValue
Definition: NodeUnion.h:55
const ValueT & getValue() const
Definition: NodeUnion.h:44
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
NodeUnion(const NodeUnion &other)
Definition: NodeUnion.h:79