home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vbtimer.zip / TIMERCOD.ZIP / VBTimer.cpp < prev    next >
C/C++ Source or Header  |  1995-06-14  |  5KB  |  157 lines

  1. /*******************************************************************************
  2. * FILE NAME: VBTimer.cpp                                                       *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   Class implementation of the class:                                         *
  6. *     VBTimer- A part that signals an event at regular intervals               *
  7. * ---------------------------------------------------------------------------- *
  8. * Warning: This file was generated by the VisualAge C++ Visual Builder.        *
  9. * Modifications to this source file will be lost when the part is regenerated. *
  10. *******************************************************************************/
  11. #ifndef _ITIMER_
  12. #include <itimer.hpp>
  13. #endif
  14.  
  15. #ifndef _INOTIFEV_
  16. #include <inotifev.hpp>
  17. #endif
  18.  
  19. #ifndef _IOBSERVR_
  20. #include <iobservr.hpp>
  21. #endif
  22.  
  23. #ifndef _ISTDNTFY_
  24. #include <istdntfy.hpp>
  25. #endif
  26.  
  27. #ifndef _VBTIMER_
  28. #include "VBTimer.hpp"
  29. #endif
  30.  
  31. #ifndef _IVBDEFS_
  32. #include <ivbdefs.h>
  33. #endif
  34.  
  35. #ifndef _ITRACE_
  36. #include <itrace.hpp>
  37. #endif
  38.  
  39.  
  40. #pragma export (VBTimer::readyId)
  41. const INotificationId VBTimer::readyId = "VBTimer::readyId";
  42. #pragma export (VBTimer::intervalId)
  43. const INotificationId VBTimer::intervalId = "VBTimer::interval";
  44. #pragma export (VBTimer::startedEvent)
  45. const INotificationId VBTimer::startedEvent = "VBTimer::isStarted";
  46. #pragma export (VBTimer::stoppedEvent)
  47. const INotificationId VBTimer::stoppedEvent = "VBTimer::isStopped";
  48. #pragma export (VBTimer::timerEventId)
  49. const INotificationId VBTimer::timerEventId = "VBTimer::timerEvent";
  50.  
  51. //------------------------------------------------------------------------------
  52. // VBTimer :: VBTimer
  53. //------------------------------------------------------------------------------
  54. #pragma export (VBTimer::VBTimer())
  55. VBTimer::VBTimer() : iVBTimerFn(new VBTimerFn(this))
  56. {
  57.    iTimer = new ITimer();
  58. }     //end constructor
  59.  
  60.  
  61. //------------------------------------------------------------------------------
  62. // VBTimer :: ~VBTimer
  63. //------------------------------------------------------------------------------
  64. #pragma export (VBTimer::~VBTimer())
  65. VBTimer::~VBTimer()
  66. {
  67.    delete iTimer;
  68. }
  69.  
  70. //------------------------------------------------------------------------------
  71. // VBTimer :: initializePart
  72. //------------------------------------------------------------------------------
  73. #pragma export (VBTimer::initializePart())
  74. VBTimer & VBTimer::initializePart()
  75. {
  76.    makeConnections();
  77.    notifyObservers(INotificationEvent(readyId, *this));
  78.    return *this;
  79. }
  80.  
  81.  
  82. //------------------------------------------------------------------------------
  83. // VBTimer :: makeConnections
  84. //------------------------------------------------------------------------------
  85. #pragma export (VBTimer::makeConnections())
  86. Boolean VBTimer::makeConnections()
  87. {
  88.    this->enableNotification();
  89.  
  90.    return true;
  91. }
  92.  
  93. //------------------------------------------------------------------------------
  94. // VBTimer :: interval
  95. //------------------------------------------------------------------------------
  96. #pragma export (VBTimer::interval())
  97. unsigned long VBTimer::interval() const
  98. {
  99.   return iInterval;
  100. }
  101.  
  102. //------------------------------------------------------------------------------
  103. // VBTimer :: setInterval
  104. //------------------------------------------------------------------------------
  105. #pragma export (VBTimer::setInterval(unsigned long aInterval))
  106. VBTimer& VBTimer::setInterval(unsigned long aInterval)
  107. {
  108.   if (!(iInterval == aInterval))
  109.   {
  110.     iInterval = aInterval;
  111.     iTimer->setInterval(iInterval);
  112.     notifyObservers(INotificationEvent(VBTimer::intervalId, *this));
  113.   } // endif
  114.   return *this;
  115. }
  116.  
  117. //------------------------------------------------------------------------------
  118. // VBTimer :: isStarted
  119. //------------------------------------------------------------------------------
  120. #pragma export (VBTimer::isStarted())
  121. Boolean VBTimer::isStarted() const
  122. {
  123.   return iIsStarted;
  124. }
  125.  
  126. //------------------------------------------------------------------------------
  127. // VBTimer :: isStopped
  128. //------------------------------------------------------------------------------
  129. #pragma export (VBTimer::isStopped())
  130. Boolean VBTimer::isStopped() const
  131. {
  132.   return iIsStopped;
  133. }
  134.  
  135. //------------------------------------------------------------------------------
  136. // VBTimer :: stop
  137. //------------------------------------------------------------------------------
  138. #pragma export (VBTimer::stop())
  139. VBTimer& VBTimer::stop()
  140. {
  141.   iTimer->stop();
  142.   notifyObservers(INotificationEvent(VBTimer::stoppedEvent, *this));
  143.   return *this;
  144. }
  145.  
  146. //------------------------------------------------------------------------------
  147. // VBTimer :: start
  148. //------------------------------------------------------------------------------
  149. #pragma export (VBTimer::start())
  150. VBTimer& VBTimer::start()
  151. {
  152.   iTimer->start(iVBTimerFn);
  153.   notifyObservers(INotificationEvent(VBTimer::startedEvent, *this));
  154.   return *this;
  155. }
  156.  
  157.