// $Revision: 1.4 $ // Copyright (C) 1994-1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_CALCFUNCTORS #include "CalcFunctors.h" #endif //---- TPushFunctor ----------------------------------------------------------- TaligentTypeExtensionMacro(TPushFunctor) TPushFunctor::TPushFunctor() : fValue(0) { } TPushFunctor::TPushFunctor(long num) : fValue(num) { } TPushFunctor::TPushFunctor(const TPushFunctor& source) : TStandardFunctorOn(source), fValue(source.fValue) { } TPushFunctor::~TPushFunctor() { } TPushFunctor& TPushFunctor::operator=(const TPushFunctor& source) { if (&source != this) { TStandardFunctorOn::operator=(source); fValue = source.fValue; } return *this; } TStream& TPushFunctor::operator>>=(TStream& toStream) const { ::WriteVersion(toStream, kOriginalVersion); TStandardFunctorOn::operator>>=(toStream); fValue >>= toStream; return toStream; } TStream& TPushFunctor::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); TStandardFunctorOn::operator<<=(fromStream); fValue <<= fromStream; return fromStream; } void TPushFunctor::operator()(TRPNCalc& calc) { calc.SetYReg(calc.GetXReg()); calc.SetXReg(fValue); } //---- TPlusFunctor ----------------------------------------------------------- TaligentTypeExtensionMacro(TPlusFunctor) TPlusFunctor::TPlusFunctor() : fResult(0) { } TPlusFunctor::TPlusFunctor(const TPlusFunctor& source) : TStandardFunctorOn(source), fResult(source.fResult) { } TPlusFunctor::~TPlusFunctor() { } TPlusFunctor& TPlusFunctor::operator=(const TPlusFunctor& source) { if (&source != this) { TStandardFunctorOn::operator=(source); fResult = source.fResult; } return *this; } TStream& TPlusFunctor::operator>>=(TStream& toStream) const { ::WriteVersion(toStream, kOriginalVersion); TStandardFunctorOn::operator>>=(toStream); fResult >>= toStream; return toStream; } TStream& TPlusFunctor::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); TStandardFunctorOn::operator<<=(fromStream); fResult <<= fromStream; return fromStream; } void TPlusFunctor::operator()(TRPNCalc& calc) { fResult = calc.GetXReg() + calc.GetYReg(); // Now push the result into the x register. (TPushFunctor(fResult))(calc); } long TPlusFunctor::GetResult() const { return fResult; }