ObjectType & operator = (ObjectType * object) { clear(); mObject = object; initRef(); return *mObject; }
inline const Variant& operator=(const Variant& b) { type_ = b.type_; if (b.type_ & RefType) { if (type_ & RefType) initRef(b.ref().get()); else ref() = b.ref(); } else { if (type_ & RefType) killRef(); int_ = b.int_; } return *this; }
void NXVectorTest::dataTest(void) { NXVector4d p; NXVectorRef4d pRef; pRef = p; CPPUNIT_ASSERT(p.data() == pRef.data()); // test copy constructor for deep-copy semantics double init[4] = { 2.0, 3.0, -1.0, 6.0 }; NXVectorRef4d initRef(init); NXVector4d initCopy(initRef); CPPUNIT_ASSERT(initRef.data() != initCopy.data()); cppunit_assert_vectors_equal(initRef, initCopy); // test copy assignment for deep-copy initCopy.zero(); initCopy = initRef; CPPUNIT_ASSERT(initRef.data() != initCopy.data()); cppunit_assert_vectors_equal(initRef, initCopy); }
void NXVectorTest::decrementTest(void) { double zeros[4] = { 0.0, 0.0, 0.0, 0.0 }; NXVector4d p1; p1.zero(); NXVector4d p2; p2.zero(); p1 -= p2; cppunit_assert_vectors_equal(p1, zeros, 0.0); double init[4] = { 1.0, -2.0, 13.0, -27.0 }; double answer[4] = { -1.0, 2.0, -13.0, 27.0 }; NXVectorRef4d initRef(init); NXVector4d initCopy = initRef; cppunit_assert_vectors_equal(initRef, initCopy); initCopy -= initRef; cppunit_assert_vectors_equal(initCopy, zeros, 0.0); initCopy -= initRef; cppunit_assert_vectors_equal(initCopy, answer, 0.0); }
TSharedPointer(ObjectType * object) { mObject = object; initRef(); }
TSharedPointer() { mObject = 0; initRef(); }
Variant(Path value) : type_(PathType) { initRef(value.toString().bytes()); }
Variant(String value) : type_(StringType) { initRef(value.bytes()); }
Variant(Ref<T, P> value) : type_(RefType) { initRef(value); }
Variant(const char* value) : type_(StringType) { initRef(String(value).bytes()); }