home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / VISBUILD / RAPSHEET / CPPOV23 / ILSTSEEN.CPP < prev    next >
Text File  |  1995-05-14  |  6KB  |  174 lines

  1. //****************************************************************************
  2. // ILastSeen Class - C++ Source File (ilstseen.cpp)                          *
  3. //                                                                           *
  4. // COPYRIGHT: Copyright (C) International Business Machines Corp., 1994,1995 *
  5. //                                                                           *
  6. // DISCLAIMER OF WARRANTIES:                                                 *
  7. //   The following [enclosed] code is sample code created by IBM             *
  8. //   Corporation.  This sample code is not part of any standard IBM product  *
  9. //   and is provided to you solely for the purpose of assisting you in the   *
  10. //   development of your applications.  The code is provided "AS IS",        *
  11. //   without warranty of any kind.  IBM shall not be liable for any damages  *
  12. //   arising out of your use of the sample code, even if they have been      *
  13. //   advised of the possibility of such damages.                             *
  14. //****************************************************************************
  15. //NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
  16. //
  17.  
  18. #include "ilstseen.hpp"
  19. #ifndef _INOTIFEV_
  20.    #include "inotifev.hpp"
  21. #endif
  22.  
  23. /****************************************************************************
  24.  * Constructors
  25.  ****************************************************************************/
  26. ILastSeen :: ILastSeen() :
  27.     dLocation(""),
  28.     dWitness(""),
  29.     dDate(""),
  30.     dComment(""),
  31.     iAddress(new IAddress()) 
  32. {
  33. }
  34.  
  35. /****************************************************************************
  36.  * Destructor
  37.  ****************************************************************************/
  38. ILastSeen :: ~ILastSeen()
  39. {
  40. }
  41.  
  42.  
  43. /****************************************************************************
  44.  * Events
  45.  ****************************************************************************/
  46.  
  47. INotificationId ILastSeen::locationID = "ILastSeen::location";
  48. INotificationId ILastSeen::witnessID  = "ILastSeen::witness";
  49. INotificationId ILastSeen::dateID     = "ILastSeen::date";
  50. INotificationId ILastSeen::commentID  = "ILastSeen::comment";
  51. INotificationId ILastSeen::addressId  = "ILastSeen::address";
  52.  
  53. /****************************************************************************
  54.  * Attribute Access Member Functions
  55.  ****************************************************************************/
  56. /*------------------------------------------------------------------
  57.  * location
  58.  *-----------------------------------------------------------------*/
  59. IString ILastSeen :: location() const
  60. {
  61.   return dLocation;
  62. }
  63.  
  64. ILastSeen &  ILastSeen :: 
  65.   setLocation(const IString & iLocation)
  66. {
  67.   if (dLocation != iLocation)
  68.   {
  69.      dLocation = iLocation;
  70.      notifyObservers(INotificationEvent(ILastSeen::locationID, *this, true,
  71.                                         IEventData((char *)iLocation)));
  72.  
  73.   }
  74.   else
  75.      notifyObservers(INotificationEvent(ILastSeen::locationID, *this, false));
  76.   return *this;
  77. }
  78.  
  79. /*------------------------------------------------------------------
  80.  * witness
  81.  *-----------------------------------------------------------------*/
  82. IString ILastSeen :: witness() const
  83. {
  84.   return dWitness;
  85. }
  86.  
  87. ILastSeen &  ILastSeen :: 
  88.   setWitness(const IString & iWitness)
  89. {
  90.   if (dWitness != iWitness)
  91.   {
  92.      dWitness = iWitness;
  93.      notifyObservers(INotificationEvent(ILastSeen::witnessID, *this, true,
  94.                                         IEventData((char *)iWitness)));
  95.   }
  96.   else
  97.      notifyObservers(INotificationEvent(ILastSeen::witnessID, *this, false));
  98.   return *this;
  99. }
  100.  
  101. /*------------------------------------------------------------------
  102.  * dateLastSeen
  103.  *-----------------------------------------------------------------*/
  104. IString ILastSeen :: dateLastSeen() const
  105. {
  106.   return dDate;
  107. }
  108.  
  109. ILastSeen &  ILastSeen :: 
  110.   setDateLastSeen(const IString & iDateLastSeen)
  111. {
  112.   if (dDate != iDateLastSeen)
  113.   {
  114.      dDate = iDateLastSeen;
  115.      notifyObservers(INotificationEvent(ILastSeen::dateID, *this, true,
  116.                                         IEventData((char *)iDateLastSeen)));
  117.   }
  118.   else
  119.      notifyObservers(INotificationEvent(ILastSeen::dateID, *this, false));
  120.   return *this;
  121. }
  122.  
  123.  
  124. /*------------------------------------------------------------------
  125.  * comment
  126.  *-----------------------------------------------------------------*/
  127. IString ILastSeen :: comment() const
  128. {
  129.   return dComment;
  130. }
  131.  
  132. ILastSeen &  ILastSeen :: 
  133.   setComment(const IString & iComment)
  134. {
  135.   if (dComment != iComment)
  136.   {
  137.      dComment = iComment;
  138.      notifyObservers(INotificationEvent(ILastSeen::commentID, *this, true,
  139.                                         IEventData((char *)iComment)));
  140.   }
  141.   else
  142.      notifyObservers(INotificationEvent(ILastSeen::commentID, *this, false));
  143.   return *this;
  144. }
  145.  
  146.  
  147. /*-----------------------------------------------------------------
  148.  * address()
  149.  *-----------------------------------------------------------------*/
  150. IAddress * ILastSeen::address() const
  151. {
  152.   return iAddress;
  153. }
  154.  
  155. ILastSeen & ILastSeen::setAddress(IAddress * aAddress)
  156. {
  157.   if (iAddress != aAddress)
  158.   {
  159.     iAddress = aAddress;
  160.     notifyObservers(INotificationEvent(ILastSeen::addressId, *this));
  161.   } // endif
  162.   return *this;
  163. }
  164.  
  165. /*-----------------------------------------------------------------
  166.  * asString()
  167.  *-----------------------------------------------------------------*/
  168. IString  ILastSeen :: asString() const
  169. {
  170.   // Only return location. Its the only thing that will be in  the list box
  171.   // The other fields will be in entry fields.
  172.   return (dLocation);
  173. }
  174.