// $Revision: 1.4 $ // Copyright (C) 1994-1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_IMPLEMENTATIONON #define TaligentSamples_IMPLEMENTATIONON #ifndef Taligent_COREPRIMITIVECLASSES #include #endif #ifndef TaligentSamples_PROTOCOLON #include "ProtocolOn.h" #endif #ifndef Taligent_ASSERTIONS #include #endif //---- TImplementationOn ----------------------------------------------------------- template class TImplementationOn : public MProtocolOn { public: TaligentTypeExtensionTemplateDeclarationsMacro(TImplementationOn,AType) public: TImplementationOn(AType* state); TImplementationOn(const TImplementationOn& source); virtual ~TImplementationOn(); TImplementationOn& operator=(const TImplementationOn& source); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); virtual void Do(TStandardFunctorOn& functor); private: TImplementationOn(); private: enum {kOriginalVersion}; AType* fState; }; //---- TImplementationOn ----------------------------------------------------------- TaligentTypeExtensionTemplateMacro(TImplementationOn,AType) template TImplementationOn::TImplementationOn() : fState(NIL) { } template TImplementationOn::TImplementationOn(AType* state) : fState(state) { } template TImplementationOn::TImplementationOn(const TImplementationOn& source) : fState(NIL) { fState = ::CopyPointer(source.fState); } template TImplementationOn::~TImplementationOn() { delete fState; } template TImplementationOn& TImplementationOn::operator=(const TImplementationOn& source) { if (&source != this) { delete fState; fState = ::CopyPointer(source.fState); } return *this; } template TStream& TImplementationOn::operator>>=(TStream& toStream) const { short version(kOriginalVersion); version >>= toStream; ::WriteVersion(toStream, kOriginalVersion); ::Flatten(fState, toStream); return toStream; } template TStream& TImplementationOn::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); delete fState; ::Resurrect(fState, fromStream); return fromStream; } template void TImplementationOn::Do(TStandardFunctorOn& functor) { ::Assertion(fState != NIL, "\nfState cannot be NIL!\n"); functor(*fState); } #endif