summaryrefslogtreecommitdiffstats
path: root/Tests/TestApp/src/SmartPointerTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/TestApp/src/SmartPointerTest.cpp')
-rw-r--r--Tests/TestApp/src/SmartPointerTest.cpp62
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();
}