// $Revision: 1.3 $ // Copyright (c) 1994-1995 Taligent, Inc. All Rights Reserved. // Notification sample 2 #ifndef TaligentSamples_RECEIVER #include "Receiver.h" #endif #ifndef Taligent_ASSERTIONS #include #endif #ifndef TaligentSamples_LONGNOTIFICATION #include "LongNotification.h" #endif // ======================================================================================== VersionDefinitionsMacro(TReceiver, kOriginalVersion); TReceiver::TReceiver(TSender* sender) : fSender(sender), fConnection(this, &TReceiver::HandleBatchNotification), fState(kUnusedState) { Assertion(fSender != NIL, "Must have sender."); fConnection.AddInterest(fSender->GetValueChangedInterest(), &TReceiver::HandleValueChanged); fConnection.SetBatchNotify(); fConnection.Connect(); } TReceiver::~TReceiver() { } void TReceiver::HandleValueChanged(const TNotification& notification) { TLongNotification* longNotification = (TLongNotification*)¬ification; if (fState == kUnusedState) { fState = longNotification->GetValue(); } } void TReceiver::HandleBatchNotification(const TNotification& notification) { TBatchNotification* batchNotification = (TBatchNotification*)¬ification; batchNotification->DispatchNotifications(); qprintf("Value changed from: %d to: %d\n", fState, fSender->GetValue()); fState = kUnusedState; }