From a38d02bdd5bb2103d0ce5acabee7cd687a912bda Mon Sep 17 00:00:00 2001 From: rich_sposato Date: Thu, 18 May 2006 05:05:21 +0000 Subject: [PATCH] Added QueryInterface function to MimicCOM class. git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@649 7ec92016-0320-0410-acc4-a06ded1c099a --- test/SmartPtr/base.h | 21 ++++++++++++++++----- test/SmartPtr/main.cpp | 9 ++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/test/SmartPtr/base.h b/test/SmartPtr/base.h index d9bb59f..2705eb3 100644 --- a/test/SmartPtr/base.h +++ b/test/SmartPtr/base.h @@ -110,12 +110,12 @@ public: class MimicCOM { public: - MimicCOM( void ) - : m_count( 0 ) - , m_AddRefCount( 0 ) - , m_ReleaseCount( 0 ) + + static MimicCOM * QueryInterface( void ) { - s_constructions++; + MimicCOM * p = new MimicCOM; + p->AddRef(); + return p; } virtual ~MimicCOM( void ) @@ -176,6 +176,14 @@ private: /// Not implemented. MimicCOM & operator = ( const MimicCOM & ); + MimicCOM( void ) + : m_count( 0 ) + , m_AddRefCount( 0 ) + , m_ReleaseCount( 0 ) + { + s_constructions++; + } + static unsigned int s_constructions; static unsigned int s_destructions; @@ -187,6 +195,9 @@ private: // ---------------------------------------------------------------------------- // $Log$ +// Revision 1.3 2006/05/18 05:05:21 rich_sposato +// Added QueryInterface function to MimicCOM class. +// // Revision 1.2 2006/04/05 22:53:12 rich_sposato // Added StrongPtr class to Loki along with tests for StrongPtr. // diff --git a/test/SmartPtr/main.cpp b/test/SmartPtr/main.cpp index 331740b..b88971d 100644 --- a/test/SmartPtr/main.cpp +++ b/test/SmartPtr/main.cpp @@ -955,13 +955,13 @@ void DoComRefTest( void ) assert( dtorCount == MimicCOM::GetDtorCount() ); { - MimicCOM_ptr p1( new MimicCOM ); + MimicCOM_ptr p1( MimicCOM::QueryInterface() ); } assert( ctorCount+1 == MimicCOM::GetCtorCount() ); assert( dtorCount+1 == MimicCOM::GetDtorCount() ); { - MimicCOM_ptr p2( new MimicCOM ); + MimicCOM_ptr p2( MimicCOM::QueryInterface() ); MimicCOM_ptr p3( p2 ); MimicCOM_ptr p4; p4 = p2; @@ -999,7 +999,7 @@ int main( unsigned int , const char * [] ) DoRefLinkTests(); DoStrongRefCountTests(); - DoStrongRefLinkTests(); + DoStrongReleaseTests(); DoStrongReleaseTests(); DoWeakCycleTests(); @@ -1035,6 +1035,9 @@ int main( unsigned int , const char * [] ) // ---------------------------------------------------------------------------- // $Log$ +// Revision 1.8 2006/05/18 05:05:21 rich_sposato +// Added QueryInterface function to MimicCOM class. +// // Revision 1.7 2006/04/28 00:34:21 rich_sposato // Added test for thread-safe StrongPtr policy. //