diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-06-15 21:42:51 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-06-15 21:42:51 +0000 |
| commit | 2959730c5d4caef539015755ce5adbddfed8afb4 (patch) | |
| tree | 4fc04cb47750fbbf741cc030f1fcea90aea32fc0 /Tests/TestApp/src/SmartPointerTest.cpp | |
| parent | Updated core & math lib test (added floor & ceil vector operations) (diff) | |
| download | DiligentEngine-2959730c5d4caef539015755ce5adbddfed8afb4.tar.gz DiligentEngine-2959730c5d4caef539015755ce5adbddfed8afb4.zip | |
Updated smart pointer test
Diffstat (limited to 'Tests/TestApp/src/SmartPointerTest.cpp')
| -rw-r--r-- | Tests/TestApp/src/SmartPointerTest.cpp | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/Tests/TestApp/src/SmartPointerTest.cpp b/Tests/TestApp/src/SmartPointerTest.cpp index 7b0fb23..c43fbee 100644 --- a/Tests/TestApp/src/SmartPointerTest.cpp +++ b/Tests/TestApp/src/SmartPointerTest.cpp @@ -552,9 +552,9 @@ SmartPointerTest::SmartPointerTest() : wpSelf( this ) {} - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} private: - Diligent::RefCntWeakPtr<SelfRefTest> wpSelf; + RefCntWeakPtr<SelfRefTest> wpSelf; }; SelfRefTest *pSelfRefTest = MakeNewObj<SelfRefTest>(); @@ -573,9 +573,9 @@ SmartPointerTest::SmartPointerTest() : throw std::runtime_error("test exception"); } - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} private: - Diligent::RefCntWeakPtr<ExceptionTest1> wpSelf; + RefCntWeakPtr<ExceptionTest1> wpSelf; }; try @@ -600,9 +600,9 @@ SmartPointerTest::SmartPointerTest() : throw std::runtime_error("test exception"); } - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} private: - Diligent::RefCntWeakPtr<ExceptionTest2> wpSelf; + RefCntWeakPtr<ExceptionTest2> wpSelf; }; try @@ -635,9 +635,9 @@ SmartPointerTest::SmartPointerTest() : throw std::runtime_error("test exception"); } private: - Diligent::RefCntWeakPtr<ExceptionTest3> wpSelf; + RefCntWeakPtr<ExceptionTest3> wpSelf; }; - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} private: Subclass m_Member; }; @@ -672,7 +672,7 @@ SmartPointerTest::SmartPointerTest() : } } - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} class ExceptionTest4 : public RefCountedObject<IObject> { @@ -693,10 +693,10 @@ SmartPointerTest::SmartPointerTest() : throw std::runtime_error("test exception"); } private: - Diligent::RefCntWeakPtr<ExceptionTest4> wpParent; - Diligent::RefCntWeakPtr<OwnerObject> wpOwner; + RefCntWeakPtr<ExceptionTest4> wpParent; + RefCntWeakPtr<OwnerObject> wpOwner; }; - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} private: Subclass m_Member; }; @@ -719,7 +719,7 @@ SmartPointerTest::SmartPointerTest() : m_pMember = NEW_RC_OBJ( DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest4, this)(*this); } - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} class ExceptionTest4 : public RefCountedObject<IObject> { @@ -740,10 +740,10 @@ SmartPointerTest::SmartPointerTest() : throw std::runtime_error("test exception"); } private: - Diligent::RefCntWeakPtr<ExceptionTest4> wpParent; - Diligent::RefCntWeakPtr<OwnerObject> wpOwner; + RefCntWeakPtr<ExceptionTest4> wpParent; + RefCntWeakPtr<OwnerObject> wpOwner; }; - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ){} + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} private: Subclass m_Member; }; @@ -761,6 +761,36 @@ SmartPointerTest::SmartPointerTest() : } } + { + class TestObject : public RefCountedObject<IObject> + { + public: + TestObject(IReferenceCounters *pRefCounters) : + RefCountedObject<IObject>(pRefCounters) + { + } + + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ){} + + inline virtual Atomics::Long Release()override final + { + return RefCountedObject<IObject>::Release( + [&]() + { + ppWeakPtr->Release(); + } + ); + } + RefCntWeakPtr<TestObject>* ppWeakPtr = nullptr; + }; + + RefCntAutoPtr<TestObject> pObj( NEW_RC_OBJ( DefaultRawMemoryAllocator::GetAllocator(), "Test object", TestObject)() ); + RefCntWeakPtr<TestObject> pWeakPtr(pObj); + + pObj->ppWeakPtr = &pWeakPtr; + pObj.Release(); + } + StartConcurrencyTest(); RunConcurrencyTest(); } |
