home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ivbvprtp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  6.1 KB  |  141 lines

  1. /*******************************************************************************
  2. * FILE NAME: ivbvprtp.c                                                        *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   Class implementation of the class(es):                                     *
  6. *    IVBVariablePartPointer - Variable template class for pointer to a part.          *
  7. *                                                                              *
  8. * COPYRIGHT:                                                                   *
  9. *   IBM(R) VisualAge(TM) for C++                                               *
  10. *   (C) Copyright International Business Machines Corporation 1991, 1996       *
  11. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  12. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  13. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  14. *******************************************************************************/
  15.  
  16. #ifndef _IVBVPRTP_
  17.   #include <ivbvprtp.h>
  18. #endif
  19.  
  20. #ifndef _INOTIFEV_
  21.   #include <inotifev.hpp>
  22. #endif
  23.  
  24. #ifndef _IWINDOW_
  25.   #include <iwindow.hpp>
  26. #endif
  27.  
  28. #include <ivbdefs.h>
  29.  
  30. /*------------------------------------------------------------------------------
  31. | IVBVariablePartPointer <Element>::IVBVariablePartPointer                     |
  32. |                                                                              |
  33. | Standard constructor.                                                        |
  34. ------------------------------------------------------------------------------*/
  35. template < class Element >
  36. IVBVariablePartPointer <Element>::IVBVariablePartPointer ()
  37.   : IVBVariablePartBase (), iTarget (0)
  38. {
  39. }
  40.  
  41. /*------------------------------------------------------------------------------
  42. | IVBVariablePartPointer <Element>::~IVBVariablePartPointer                    |
  43. |                                                                              |
  44. | Standard destructor.                                                         |
  45. ------------------------------------------------------------------------------*/
  46. template < class Element >
  47. IVBVariablePartPointer <Element>::~IVBVariablePartPointer ()
  48. {
  49.   if (iTarget) {
  50.     stopHandlingNotificationsFor (*iTarget);
  51.     if (iAutoDeleteTarget) {
  52.       delete iTarget;
  53.     } /* endif */
  54.   } /* endif */
  55. }
  56.  
  57. /*------------------------------------------------------------------------------
  58. | IVBVariablePartPointer <Element>::target                                     |
  59. |                                                                              |
  60. | Returns the target attribute.                                                |
  61. ------------------------------------------------------------------------------*/
  62. template < class Element >
  63. Element IVBVariablePartPointer <Element>::target () const
  64. {
  65.   return iTarget;
  66. }
  67.  
  68. /*------------------------------------------------------------------------------
  69. | IVBVariablePartPointer <Element>::targetPtr                                  |
  70. |                                                                              |
  71. | Returns the target attribute.                                                |
  72. ------------------------------------------------------------------------------*/
  73. template < class Element >
  74. Element IVBVariablePartPointer <Element>::targetPtr () const
  75. {
  76.   return iTarget;
  77. }
  78.  
  79. /*------------------------------------------------------------------------------
  80. | IVBVariablePartPointer <Element>::setTarget                                  |
  81. |                                                                              |
  82. | Sets the target attribute.                                                   |
  83. ------------------------------------------------------------------------------*/
  84. template < class Element >
  85. IVBVariablePartPointer <Element>& IVBVariablePartPointer <Element>::setTarget
  86.   (Element newTarget)
  87. {
  88.   if (iTarget != newTarget) {
  89.     if (iTarget) {
  90.       stopHandlingNotificationsFor (*iTarget);
  91.       if (iAutoDeleteTarget) {
  92.         delete iTarget;
  93.       } /* endif */
  94.     } /* endif */
  95.     iTarget = newTarget;
  96.     if (iTarget) {
  97.       iTarget->enableNotification();
  98.       handleNotificationsFor (*iTarget);
  99.     } /* endif */
  100.   } /* endif */
  101.   notifyObservers(INotificationEvent(VBINITIALIZEID, *this));
  102.   notifyObservers(INotificationEvent(targetId, *this));
  103.   return *this;
  104. }
  105.  
  106. /*------------------------------------------------------------------------------
  107. | IVBVariablePartPointer <Element>::dispatchNotificationEvent                  |
  108. |                                                                              |
  109. | Sets the target attribute.                                                   |
  110. ------------------------------------------------------------------------------*/
  111. template < class Element >
  112. IObserver& IVBVariablePartPointer <Element>::
  113.   dispatchNotificationEvent  ( const INotificationEvent& anEvent)
  114. {
  115.   notifyObservers (anEvent);
  116.   if (( anEvent.notificationId() == IStandardNotifier::deleteId ) ||
  117.       ( anEvent.notificationId() == IWindow::deleteId )) {
  118.     iTarget = 0;
  119.   } ; /* endif */
  120.   return *this;
  121. }
  122.  
  123. /*------------------------------------------------------------------------------
  124. | IVBVariablePartPointer <Element>::deleteTarget                               |
  125. |                                                                              |
  126. | Delete the target attribute.                                                 |
  127. ------------------------------------------------------------------------------*/
  128. template < class Element >
  129. IVBVariablePartPointer <Element>&
  130.   IVBVariablePartPointer <Element>::deleteTarget ()
  131. {
  132.   if (iTarget) {
  133.     stopHandlingNotificationsFor (*iTarget);
  134.     delete iTarget;
  135.     iTarget = 0;
  136.     notifyObservers(INotificationEvent(VBINITIALIZEID, *this));
  137.     notifyObservers(INotificationEvent(targetId, *this));
  138.   } ; /* endif */
  139.   return *this;
  140. }
  141.