home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ibmodf.zip / ODFRK.ZIP / ICONNECT.HPP < prev    next >
Text File  |  1995-06-09  |  6KB  |  148 lines

  1. #ifndef _ICONNECT_
  2. #define _ICONNECT_
  3.  
  4. /*******************************************************************************
  5. * FILE NAME: iconnect.hpp                                                      *
  6. *                                                                              *
  7. * DESCRIPTION: see online documentation                                        *
  8. *                                                                              *
  9. * COPYRIGHT:                                                                   *
  10. *   Licensed Materials - Property of IBM                                       *
  11. *   (C) Copyright IBM Corporation 1994                                         *
  12. *   All Rights Reserved                                                        *
  13. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  14. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  15. *                                                                              *
  16. *******************************************************************************/
  17.  
  18. #include <ivbase.hpp>
  19. #include <inotify.hpp>
  20. #include <iobservr.hpp>
  21. #include <ithread.hpp>
  22.  
  23. /*----------------------------------------------------------------------------  */
  24. /* Align classes on four byte boundary.                                         */
  25. /*----------------------------------------------------------------------------  */
  26. #pragma pack(4)
  27.  
  28. // Forward declarations for other classes:
  29. class IVBase;
  30. class IString;
  31. class ODFFormView;
  32.  
  33. class IConnection : public IObserver {
  34. public:
  35. IConnection( INotifier &firstNotifier,
  36.              const INotificationId firstNotificationId,
  37.              const IReference<IThreadFn>& firstFunction,
  38.              INotifier &secondNotifier,
  39.              const INotificationId secondNotificationId,
  40.              const IReference<IThreadFn>& secondFunction   );
  41.  
  42. IConnection( INotifier &firstNotifier,
  43.              const INotificationId firstNotificationId,
  44.              const IReference<IThreadFn>& firstFunction );
  45.  
  46. IConnection( INotifier &firstNotifier,
  47.              const INotificationId firstNotificationId,
  48.              INotifier &secondNotifier,
  49.              const INotificationId secondNotificationId );
  50.  
  51. IConnection( INotifier &firstNotifier,
  52.              const INotificationId firstNotificationId );
  53.  
  54. virtual ~IConnection();
  55.  
  56. inline INotifier 
  57.      &firstNotifier() {return fFirstNotifier;}
  58. inline INotifier 
  59.      &secondNotifier() {return fSecondNotifier;}
  60. inline INotificationId 
  61.      firstId() {return fFirstNotificationId;}
  62. inline INotificationId 
  63.      secondId() {return fSecondNotificationId;}
  64. inline virtual IConnection
  65.      &dispatchFirstFunction();      //??rename "firstNotificationOccured()" ?
  66. inline virtual IConnection
  67.      &dispatchSecondFunction();     //??rename "secondNotificationOccured()" ?
  68. inline Boolean
  69.      isOneWay() {return fOneWay;}
  70.  
  71. protected:
  72. virtual IConnection &dispatchNotificationEvent(
  73.                                 const INotificationEvent &event);
  74. private:
  75.    INotifier &fFirstNotifier,
  76.              &fSecondNotifier;
  77.    INotificationId fFirstNotificationId,
  78.                    fSecondNotificationId;
  79. IThreadFn *fFirstFunction, 
  80.           *fSecondFunction;
  81. Boolean fOneWay;
  82. }; // IConnection
  83.  
  84.  
  85. class IModelViewSynchConnection : public IConnection {
  86. public:
  87.    IModelViewSynchConnection( INotifier &modelObject,
  88.                 const INotificationId modelChangedId,
  89.                 const IReference<IThreadFn>& modelChangedFunction,
  90.                 ODFFormView &view,
  91.                 INotifier &viewObject,
  92.                 const IReference<IThreadFn>& viewChangedFunction   );
  93.    IModelViewSynchConnection( INotifier &modelObject,
  94.                 const INotificationId modelChangedId,
  95.                 const IReference<IThreadFn>& modelChangedFunction,
  96.                 ODFFormView &view   );
  97.    IModelViewSynchConnection( INotifier &modelObject,
  98.                 const INotificationId modelChangedId,
  99.                 ODFFormView &view,
  100.                 INotifier &viewObject   );
  101.    IModelViewSynchConnection( INotifier &modelObject,
  102.                 const INotificationId modelChangedId,
  103.                 ODFFormView &view   );
  104.    ~IModelViewSynchConnection();
  105.  
  106. //************* inline all this stuff, so our use of it doesn't incur double call overhead ***
  107.    inline INotifier 
  108.               &modelObject() {return firstNotifier();}
  109.    inline INotifier 
  110.               &viewObject(){return secondNotifier();}
  111.    inline INotificationId 
  112.               modelChangedId(){return firstId();}
  113.    inline IModelViewSynchConnection 
  114.               &dispatchModelChangedFunction() {dispatchFirstFunction();}
  115.    inline IModelViewSynchConnection 
  116.               &dispatchViewChangedFunction() {dispatchSecondFunction();}
  117.    inline ODFFormView 
  118.               &view(){return fView;}
  119.    inline virtual Boolean 
  120.               isViewObjectOutOfSynch() {return fViewObjectDirty;}
  121.    inline virtual IModelViewSynchConnection
  122.               &viewObjectOutOfSynch(Boolean outOfSynch = true);
  123.  
  124. protected:
  125.    virtual IModelViewSynchConnection &dispatchNotificationEvent(
  126.                                 const INotificationEvent &event);
  127. virtual Boolean isValueChangedNotification(const INotificationEvent &event);
  128.  
  129.  
  130. private:
  131.    ODFFormView &fView;
  132.    Boolean fViewObjectDirty;
  133. }; // IModelViewSynchConnection
  134.  
  135.  
  136.  
  137.  
  138. /*----------------------------------------------------------------------------  */
  139. /* Resume compiler default packing.                                             */
  140. /*----------------------------------------------------------------------------  */
  141. #pragma pack()
  142.  
  143. /*----------------------------- Inline Functions -----------------------------  */
  144.  
  145. #ifndef I_NO_INLINES
  146. #endif
  147. #endif /* _ICONNECT_ */
  148.