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

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  19. #pragma pack (4)
  20.  
  21. // ---
  22. // IVSequenceImpl
  23. // ---
  24.  
  25. // public members
  26.  
  27. template <class VInherited>
  28. IVSequenceImpl <VInherited>::
  29. IVSequenceImpl (Ops& ops, INumber numberOfElements)
  30. : VInherited (ops, numberOfElements)
  31. {
  32. }
  33.  
  34. template <class VInherited>
  35. IVSequenceImpl <VInherited>::
  36. IVSequenceImpl
  37.   (Ops& ops, IVSequenceImpl <VInherited> const& collection)
  38. : VInherited (ops, collection)
  39. {
  40. }
  41.  
  42. template <class VInherited>
  43. IBoolean
  44. IVSequenceImpl <VInherited>::
  45. Add (void const* element, ICursorImpl& cursor)
  46. { IBoolean isEnabled = IsEnabledForNotification ();
  47.   DisableNotification ();
  48.   IBoolean hasBeenAdded = VInherited::Add (element, cursor);
  49.   EnableNotification (isEnabled);
  50.   if (hasBeenAdded && HasObservers ()) {
  51.     NotifyOfAddAt (cursor);
  52.   }
  53.   return hasBeenAdded;
  54. }
  55.  
  56. template <class VInherited>
  57. void
  58. IVSequenceImpl <VInherited>::
  59. AddAllFrom (IACollectionImpl const& collection)
  60. { IBoolean isEnabled = IsEnabledForNotification ();
  61.   DisableNotification ();
  62.   VInherited::AddAllFrom (collection);
  63.   EnableNotification (isEnabled);
  64.   if (HasObservers ()) {
  65.     NotifyOfModification ();
  66.   }
  67. }
  68.  
  69. template <class VInherited>
  70. void
  71. IVSequenceImpl <VInherited>::
  72. AddAsFirst (void const* element, ICursorImpl& cursor)
  73. { VInherited::AddAsFirst (element, cursor);
  74.   if (HasObservers ()) {
  75.     NotifyOfAddAt (cursor);
  76.   }
  77. }
  78.  
  79. template <class VInherited>
  80. void
  81. IVSequenceImpl <VInherited>::
  82. AddAsLast (void const* element, ICursorImpl& cursor)
  83. { VInherited::AddAsLast (element, cursor);
  84.   if (HasObservers ()) {
  85.     NotifyOfAddAt (cursor);
  86.   }
  87. }
  88.  
  89. template <class VInherited>
  90. void
  91. IVSequenceImpl <VInherited>::
  92. AddAsNext (void const* element, ICursorImpl& cursor)
  93. { VInherited::AddAsNext (element, cursor);
  94.   if (HasObservers ()) {
  95.     NotifyOfAddAt (cursor);
  96.   }
  97. }
  98.  
  99. template <class VInherited>
  100. void
  101. IVSequenceImpl <VInherited>::
  102. AddAsPrevious (void const* element, ICursorImpl& cursor)
  103. { VInherited::AddAsPrevious (element, cursor);
  104.   if (HasObservers ()) {
  105.     NotifyOfAddAt (cursor);
  106.   }
  107. }
  108.  
  109. template <class VInherited>
  110. void
  111. IVSequenceImpl <VInherited>::
  112. AddAtPosition (IPosition position,
  113.                void const* element,
  114.                ICursorImpl& cursor)
  115. { VInherited::AddAtPosition (position, element, cursor);
  116.   if (HasObservers ()) {
  117.     NotifyOfAddAt (cursor);
  118.   }
  119. }
  120.  
  121. template <class VInherited>
  122. void
  123. IVSequenceImpl <VInherited>::
  124. Copy (IACollectionImpl const& collection)
  125. { IBoolean isEnabled = IsEnabledForNotification ();
  126.   DisableNotification ();
  127.   VInherited::Copy (collection);
  128.   EnableNotification (isEnabled);
  129.   if (HasObservers ()) {
  130.     NotifyOfModification ();
  131.   }
  132. }
  133.  
  134. template <class VInherited>
  135. INumber
  136. IVSequenceImpl <VInherited>::
  137. RemoveAll ()
  138. { INumber result = VInherited::RemoveAll ();
  139.   if (result > 0 && HasObservers ()) {
  140.     NotifyOfModification ();
  141.   }
  142.   return result;
  143. }
  144.  
  145. template <class VInherited>
  146. INumber
  147. IVSequenceImpl <VInherited>::
  148. RemoveAll (IPredFunc predFunc, void* addArg)
  149. { INumber result = VInherited::RemoveAll (predFunc, addArg);
  150.   if (result > 0 && HasObservers ()) {
  151.     NotifyOfModification ();
  152.   }
  153.   return result;
  154. }
  155.  
  156. template <class VInherited>
  157. void
  158. IVSequenceImpl <VInherited>::
  159. RemoveAt (ICursorImpl& cursor)
  160. { if (HasObservers ()) {
  161.     NotifyOfRemoveAt (cursor);
  162.   }
  163.   VInherited::RemoveAt (cursor);
  164. }
  165.  
  166. template <class VInherited>
  167. void
  168. IVSequenceImpl <VInherited>::
  169. RemoveAtPosition (IPosition position)
  170. { if (HasObservers ()) {
  171.     SetToPosition (position, CursorOf (*this));
  172.     NotifyOfRemoveAt (CursorOf (*this));
  173.   }
  174.   VInherited::RemoveAtPosition (position);
  175. }
  176.  
  177. template <class VInherited>
  178. void
  179. IVSequenceImpl <VInherited>::
  180. RemoveFirst ()
  181. { if (HasObservers ()) {
  182.     SetToFirst (CursorOf (*this));
  183.     NotifyOfRemoveAt (CursorOf (*this));
  184.   }
  185.   VInherited::RemoveFirst ();
  186. }
  187.  
  188. template <class VInherited>
  189. void
  190. IVSequenceImpl <VInherited>::
  191. RemoveLast ()
  192. { if (HasObservers ()) {
  193.     SetToLast (CursorOf (*this));
  194.     NotifyOfRemoveAt (CursorOf (*this));
  195.   }
  196.   VInherited::RemoveLast ();
  197. }
  198.  
  199. template <class VInherited>
  200. void
  201. IVSequenceImpl <VInherited>::
  202. ReplaceAt (ICursorImpl const& cursor, void const* element)
  203. { if (HasObservers ()) {
  204. #if defined (ICLCC_COMPAT_IVB)
  205.     NotifyOfRemoveAt (cursor); // to be removed in a future release
  206. #else
  207.     NotifyOfReplaceAt (cursor, element);
  208. #endif
  209.   }
  210.   VInherited::ReplaceAt (cursor, element);
  211. #if defined (ICLCC_COMPAT_IVB)
  212.   if (HasObservers ()) {
  213.     NotifyOfAddAt (cursor); // to be removed in a future release
  214.   }
  215. #endif
  216. }
  217.  
  218. template <class VInherited>
  219. void
  220. IVSequenceImpl <VInherited>::
  221. Reverse ()
  222. { VInherited::Reverse ();
  223.   if (HasObservers ()) {
  224.     NotifyOfModification ();
  225.   }
  226. }
  227.  
  228. template <class VInherited>
  229. void
  230. IVSequenceImpl <VInherited>::
  231. Sort (ICompFunc compFunc, void* addArg)
  232. { VInherited::Sort (compFunc, addArg);
  233.   if (HasObservers ()) {
  234.     NotifyOfModification ();
  235.   }
  236. }
  237.  
  238. #pragma info (restore)
  239. #pragma pack ()
  240.