// $Revision: 1.6 $ // Copyright (C) 1994-1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_TEMPLATECALLERMACROS #define TaligentSamples_TEMPLATECALLERMACROS // These are the MRemoteCallerDeclarationsMacro and the MRemoteCallerDefinitionsMacro that have been // adapted for use with templatized callers and dispatchers. // This macro is used if you have either a templatized caller or dispatcher class. This macro is only // placed in the caller. #define MRemoteCallerTemplateDeclarationsMacro()\ private:\ static MRemoteCaller::DispatcherID &fgDispatcherID;\ CallerCache fCache;\ \ static MRemoteCaller::DispatcherID GetMyDispatcherID() {return MRemoteCaller::MakeDispatcherID(DispatcherType());}\ void MRemoteCallerEnable() {\ if(! fgDispatcherID) fgDispatcherID = MRemoteCaller::MakeDispatcherID(DispatcherType()); \ ForceCacheEmpty(fCache);}\ TStream* BeginRequest(MRemoteCaller::RequestID theRequestID) {return DoBeginRequest(fgDispatcherID, fCache, theRequestID);}\ TStream* SendRequest() {return DoSendRequest(fgDispatcherID, fCache);}\ void EndRequest() {DoEndRequest();}\ static const char* DispatcherType(); // This macro only covers the case where both the caller and the dispatcher are template classes and // they both have the same type as there parameter (e.g., TDogCallerOn and TDogDispatcherOn // This is the macro used in the TemplateRPC sample. #define MRemoteCallerTemplateCallerAndTemplateDispatcherDefinitionsMacro(_caller,_dispatcher,_ptype)\ \ MRemoteCaller::DispatcherID _caller##__fgDispatcherID = 0;\ \ template\ MRemoteCaller::DispatcherID& _caller<_ptype >::fgDispatcherID = _caller##__fgDispatcherID;\ \ template\ const char*\ _caller<_ptype >::DispatcherType()\ {\ return StaticTypeInfo(_dispatcher).name();\ } // This macro is for the case where only the caller is a template class. If you have a templatized // caller and a non-templatized dispatcher, use this macro. #define MRemoteCallerTemplateCallerOnlyDefinitionsMacro(_caller,_dispatcher,_ptype)\ \ MRemoteCaller::DispatcherID _caller##__fgDispatcherID = 0;\ \ template\ MRemoteCaller::DispatcherID& _caller<_ptype >::fgDispatcherID = _caller##__fgDispatcherID;\ \ template\ const char*\ _caller<_ptype >::DispatcherType()\ {\ return StaticTypeInfo(_dispatcher).name();\ } // This macro is for the case where only the dispatcher is a template class. If you have a templatized // dispatcher and a non-templatized caller, use this macro. #define MRemoteCallerTemplateDispatcherOnlyDefinitionsMacro(_caller,_dispatcher,_ptype)\ \ MRemoteCaller::DispatcherID _caller##__fgDispatcherID = 0;\ \ MRemoteCaller::DispatcherID& _caller::fgDispatcherID = _caller##__fgDispatcherID;\ \ const char*\ _caller::DispatcherType()\ {\ return StaticTypeInfo(_dispatcher).name();\ } #endif