Defining the implementation

The dispatcher implementation class derives from the abstract base class. In this class, override the member functions from the abstract base class and provide the implementations you want to call remotely. The member functions do not need a special interface, as an instance of this class is not aware that it is being called remotely.

Here, TAdditionDispatcherImplementation derives from MAdditionProtocol:

      class TAdditionDispatcherImplementation : public MAdditionProtocol {
        public:
          MCollectibleDeclarationsMacro(TAdditionDispatcherImplementation);
        public:
                                  TAdditionDispatcherImplementation();
                                  TAdditionDispatcherImplementation(
                                  const TAdditionDispatcherImplementation& source);
                                  ~TAdditionDispatcherImplementation();
                                              
          TAdditionDispatcherImplementation&operator=(
              const TAdditionDispatcherImplementation& source);
          virtual TStream&        operator>>=(TStream& toStream) const;
          virtual TStream&        operator<<=(TStream& fromStream);
          
          
    virtual long            Add(long num1, long num2);
          virtual void            AddOne(long& num);
          virtual void            Shutdown();
      
        protected:
          void                    TestForOverflowAndUnderflow(long num1, long num2);
          
        private:
          enum {kOriginalVersion};
      };
TAdditionDispatcherImplementation overrides Add and AddOne to define the code that execute remotely:

      long
      TAdditionDispatcherImplementation::Add(long num1, long num2)
      {
          TestForOverflowAndUnderflow(num1, num2);
          return num1 + num2;
      }
      
      void
      TAdditionDispatcherImplementation::AddOne(long& num)
      {
          if (num == LONG_MAX) {
              throw TMathException(TMathException::kOverflow);
          }
          ++num;
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker