// Copyright (C)1994 Taligent, Inc. All rights reserved. // $Revision: $ #ifndef Taligent_EXAMPLE3 #define Taligent_EXAMPLE3 #ifndef Taligent_PRIMITIVECLASSES #include <PrimitiveClasses.h> #endif class TOwningStackOf3Implementation { public: TOwningStackOf3Implementation(); virtual ~TOwningStackOf3Implementation(); void ImplementConstructor( const TOwningStackOf3Implementation& other ); void ImplementDestructor(); void ImplementAdopt(void* item); virtual unsigned int Count() const; private: virtual void * TypeSpecificCopy(const void* item) = 0; virtual void TypeSpecificDelete(void* item) = 0; void* fStack[10]; unsigned int fCount; };
template <class AType> class TOwningStackOf3 : private TOwningStackOf3Implementation { public: TOwningStackOf3(); TOwningStackOf3( const TOwningStackOf3<AType>& other ); virtual ~TOwningStackOf3(); virtual void Adopt(AType* graphic); // Reexport Count TOwningStackOf3Implementation::Count; private: virtual void * TypeSpecificCopy(const void* item); virtual void TypeSpecificDelete(void* item); }; #ifndef Taligent_EXAMPLE3TEMPLATEIMPLEMENTATION #include <Example3TemplateImplementation.h> #endif // Inlines go here template<class AType> inline TOwningStackOf3<AType>::TOwningStackOf3() { } template<class AType> inline TOwningStackOf3<AType>::TOwningStackOf3( const TOwningStackOf3<AType>& other ) { ImplementConstructor(other); } template<class AType> inline TOwningStackOf3<AType>::~TOwningStackOf3() { ImplementDestructor(); } template<class AType> inline void TOwningStackOf3<AType>::Adopt(AType* item) { ImplementAdopt(item); }
// Copyright (C) 1994 Taligent, Inc. All rights reserved. // $Revision: $ #ifndef Taligent_EXAMPLE3 #include <Example3.h> #endif TOwningStackOf3Implementation::TOwningStackOf3Implementation() : fCount(0) { } TOwningStackOf3Implementation::~TOwningStackOf3Implementation() { } void TOwningStackOf3Implementation::ImplementConstructor( const TOwningStackOf3Implementation& other) { fCount = other.fCount; for ( unsigned int i = 0; i < fCount; i++ ) { fStack[i] = TypeSpecificCopy(other.fStack[i]); } } void TOwningStackOf3Implementation::ImplementDestructor() { for ( unsigned int i = 0; i < fCount; i++ ) { TypeSpecificDelete(fStack[i]); } } void TOwningStackOf3Implementation::ImplementAdopt(void* item) { fStack[fCount++] = item; } unsigned int TOwningStackOf3Implementation::Count() const { return fCount; }
// Copyright (C)1994 Taligent, Inc. All rights reserved. // $Revision: $ #ifndef Taligent_EXAMPLE3TEMPLATEIMPLEMENTATION #define Taligent_EXAMPLE3TEMPLATEIMPLEMENTATION #ifndef Taligent_EXAMPLE3 #include <Example3.h> #endif template<class AType> void* TOwningStackOf3<AType>::TypeSpecificCopy(const void* item) { return new AType(* (const AType*) item); } template<class AType> void TOwningStackOf3<AType>::TypeSpecificDelete(void* item) { delete (AType*) item; } #endif
// Copyright (C)1994 Taligent, Inc. All rights reserved. // $Revision: $ #ifndef Taligent_EXAMPLE3 #include <Example3.h> #endif TOwningStackOf3Implementation::TOwningStackOf3Implementation() : fCount(0) { } TOwningStackOf3Implementation::~TOwningStackOf3Implementation() { } void TOwningStackOf3Implementation::ImplementConstructor( const TOwningStackOf3Implementation& other) { fCount = other.fCount; for ( unsigned int i = 0; i < fCount; i++ ) { fStack[i] = TypeSpecificCopy(other.fStack[i]); } } void TOwningStackOf3Implementation::ImplementDestructor() { for ( unsigned int i = 0; i < fCount; i++ ) { TypeSpecificDelete(fStack[i]); } } void TOwningStackOf3Implementation::ImplementAdopt(void* item) { fStack[fCount++] = item; } unsigned int TOwningStackOf3Implementation::Count() const { return fCount; }