// $Revision: 1.3 $ // Copyright (c) 1994-1995 Taligent, Inc. All Rights Reserved. // Notification sample 5 #ifndef TaligentSamples_VALUERECEIVER #include "ValueReceiver.h" #endif #ifndef Taligent_ASSERTIONS #include #endif #ifndef TaligentSamples_LONGNOTIFICATION #include "LongNotification.h" #endif // ======================================================================================== VersionDefinitionsMacro(TValueReceiver, kOriginalVersion); TValueReceiver::TValueReceiver(TSender* sender, long value) : fSender(sender), fConnection(this, &TValueReceiver::HandleValueNotification), fValue(value) { Assertion(fSender != NIL, "Must have sender."); fConnection.AddInterest(fSender->GetValueInterest(value)); fConnection.Connect(); } TValueReceiver::~TValueReceiver() { } long TValueReceiver::GetValue() const { return fValue; } void TValueReceiver::SetValue(long value) { if (value != fValue) { fConnection.RemoveInterest(fSender->GetValueInterest(fValue)); fValue = value; fConnection.AddInterest(fSender->GetValueInterest(fValue)); } } void TValueReceiver::HandleValueNotification(const TNotification&) { qprintf("Value receiver notified of value: %d\n", fValue); }