44 #ifndef OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED
45 #define OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED
47 #include <boost/type_traits/is_class.hpp>
48 #include <openvdb/version.h>
56 template<
bool ValueIsClass,
class ValueT,
class ChildT>
class NodeUnionImpl;
61 template<
typename ValueT,
typename ChildT>
65 union { ChildT* child; ValueT
value; } mUnion;
70 ChildT*
getChild()
const {
return mUnion.child; }
71 const ValueT&
getValue()
const {
return mUnion.value; }
72 void setChild(ChildT* child) { mUnion.child = child; }
73 void setValue(
const ValueT& val) { mUnion.value = val; }
79 template<
typename ValueT,
typename ChildT>
83 union { ChildT* child; ValueT*
value; } mUnion;
90 if (other.mHasChild) setChild(other.getChild());
91 else setValue(other.getValue());
95 if (other.mHasChild) setChild(other.getChild());
96 else setValue(other.getValue());
101 {
return mHasChild ? mUnion.child : NULL; }
104 if (!mHasChild)
delete mUnion.value;
105 mUnion.child = child;
109 const ValueT&
getValue()
const {
return *mUnion.value; }
115 if (!mHasChild)
delete mUnion.value;
116 mUnion.value =
new ValueT(val);
122 template<
typename ValueT,
typename ChildT>
124 boost::is_class<ValueT>::value, ValueT, ChildT>
133 #endif // OPENVDB_TREE_NODEUNION_HAS_BEEN_INCLUDED