// $Revision: 1.3 $ // Copyright (C) 1994-1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_SENDERDISPATCHER #include "SenderDispatcher.h" #endif #ifndef Taligent_ASSERTIONS #include #endif MCollectibleDefinitionsMacro(TSenderDispatcher, kOriginalVersion); TSenderDispatcher::TSenderDispatcher() : MRemoteDispatcher(), MRemoteDispatcherNotifier(), fImplementation(NIL) { } TSenderDispatcher::TSenderDispatcher(TSender* adoptedImplementation) : MRemoteDispatcher(), MRemoteDispatcherNotifier(), fImplementation(adoptedImplementation) { ::Assertion(adoptedImplementation != NIL, "\nCannot adopt a NIL implementation!\n"); fImplementation->SetNotifier((MRemoteDispatcherNotifier*)this); static RequestEntry notifierRequests[] = { {MRemoteCallerNotifier::kAddRemoteInterest, (RemoteFnPtr)&TSenderDispatcher::FwdAddRemoteInterest}, {MRemoteCallerNotifier::kRemoveRemoteInterest, (RemoteFnPtr)&TSenderDispatcher::FwdRemoveRemoteInterest}, {MRemoteCaller::kUnknownRequest} }; RegisterRequests(TStandardText("MRemoteDispatcherNotifier"), MRemoteCallerNotifier::kLastRequest, notifierRequests); static RequestEntry senderRequests[] = { {MSenderProtocol::kSetValue, (RemoteFnPtr)&TSenderDispatcher::SetValueStub}, {MSenderProtocol::kGetValue, (RemoteFnPtr)&TSenderDispatcher::GetValueStub}, {MRemoteCaller::kUnknownRequest} }; RegisterRequests(TStandardText("TSenderDispatcher"), MSenderProtocol::kLastRequest, senderRequests); } TSenderDispatcher::~TSenderDispatcher() { delete fImplementation; } void TSenderDispatcher::SetValueStub(TStream& argStream, TStream& resultStream) { long value; value <<= argStream; fImplementation->SetValue(value); ReturnSuccess(resultStream); } void TSenderDispatcher::GetValueStub(TStream& argStream, TStream& resultStream) { long value = fImplementation->GetValue(); ReturnSuccess(resultStream); value >>= resultStream; } void TSenderDispatcher::FwdAddRemoteInterest(TStream& argStream, TStream& resultStream) { AddRemoteInterest(argStream, resultStream); ReturnSuccess(resultStream); } void TSenderDispatcher::FwdRemoveRemoteInterest(TStream& argStream, TStream& resultStream) { RemoveRemoteInterest(argStream, resultStream); ReturnSuccess(resultStream); }