From 1138dc98786f59be3e794c2c99dc51c2fff2902f Mon Sep 17 00:00:00 2001 From: rich_sposato Date: Mon, 20 Mar 2006 21:14:16 +0000 Subject: [PATCH] Adding base.h to CVS. git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@611 7ec92016-0320-0410-acc4-a06ded1c099a --- test/SmartPtr/base.h | 106 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 test/SmartPtr/base.h diff --git a/test/SmartPtr/base.h b/test/SmartPtr/base.h new file mode 100644 index 0000000..2b9062a --- /dev/null +++ b/test/SmartPtr/base.h @@ -0,0 +1,106 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test program for The Loki Library +// Copyright (c) 2006 Richard Sposato +// Permission to use, copy, modify, distribute and sell this software for any +// purpose is hereby granted without fee, provided that the above copyright +// notice appear in all copies and that both that copyright notice and this +// permission notice appear in supporting documentation. +// The authors make no representations about the +// suitability of this software for any purpose. It is provided "as is" +// without express or implied warranty. +//////////////////////////////////////////////////////////////////////////////// + +// $Header$ + + +// ---------------------------------------------------------------------------- + +class BaseClass +{ +public: + BaseClass( void ) + { + s_constructions++; + } + + virtual ~BaseClass( void ) + { + s_destructions++; + } + + // These 2 functions are so we can pretend we have a COM object. + void AddRef( void ) {} + void Release( void ) {} + + // This function is used only for the DeepCopy policy. + virtual BaseClass * Clone( void ) const + { + return new BaseClass(); + } + + static inline bool AllDestroyed( void ) + { + return ( s_constructions == s_destructions ); + } + + static inline bool ExtraConstructions( void ) + { + return ( s_constructions > s_destructions ); + } + + static inline bool ExtraDestructions( void ) + { + return ( s_constructions < s_destructions ); + } + + static inline unsigned int GetCtorCount( void ) + { + return s_constructions; + } + + static inline unsigned int GetDtorCount( void ) + { + return s_destructions; + } + +private: + /// Not implemented. + BaseClass( const BaseClass & ); + /// Not implemented. + BaseClass & operator = ( const BaseClass & ); + + static unsigned int s_constructions; + static unsigned int s_destructions; +}; + + +// ---------------------------------------------------------------------------- + +class PublicSubClass : public BaseClass +{ +public: + // This function is used only for the DeepCopy policy. + virtual BaseClass * Clone( void ) const + { + return new BaseClass; + } +}; + +// ---------------------------------------------------------------------------- + +class PrivateSubClass : private BaseClass +{ +public: + // This function is used only for the DeepCopy policy. + virtual BaseClass * Clone( void ) const + { + return new BaseClass; + } +}; + +// ---------------------------------------------------------------------------- + +// $Log$ +// Revision 1.1 2006/03/20 21:14:16 rich_sposato +// Adding base.h to CVS. +//